github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/ConnectRequest.go (about) 1 // Generated SBE (Simple Binary Encoding) message codec 2 3 package codecs 4 5 import ( 6 "fmt" 7 "io" 8 "io/ioutil" 9 "math" 10 ) 11 12 type ConnectRequest struct { 13 CorrelationId int64 14 ResponseStreamId int32 15 Version int32 16 ResponseChannel []uint8 17 } 18 19 func (c *ConnectRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 20 if doRangeCheck { 21 if err := c.RangeCheck(c.SbeSchemaVersion(), c.SbeSchemaVersion()); err != nil { 22 return err 23 } 24 } 25 if err := _m.WriteInt64(_w, c.CorrelationId); err != nil { 26 return err 27 } 28 if err := _m.WriteInt32(_w, c.ResponseStreamId); err != nil { 29 return err 30 } 31 if err := _m.WriteInt32(_w, c.Version); err != nil { 32 return err 33 } 34 if err := _m.WriteUint32(_w, uint32(len(c.ResponseChannel))); err != nil { 35 return err 36 } 37 if err := _m.WriteBytes(_w, c.ResponseChannel); err != nil { 38 return err 39 } 40 return nil 41 } 42 43 func (c *ConnectRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 44 if !c.CorrelationIdInActingVersion(actingVersion) { 45 c.CorrelationId = c.CorrelationIdNullValue() 46 } else { 47 if err := _m.ReadInt64(_r, &c.CorrelationId); err != nil { 48 return err 49 } 50 } 51 if !c.ResponseStreamIdInActingVersion(actingVersion) { 52 c.ResponseStreamId = c.ResponseStreamIdNullValue() 53 } else { 54 if err := _m.ReadInt32(_r, &c.ResponseStreamId); err != nil { 55 return err 56 } 57 } 58 if !c.VersionInActingVersion(actingVersion) { 59 c.Version = c.VersionNullValue() 60 } else { 61 if err := _m.ReadInt32(_r, &c.Version); err != nil { 62 return err 63 } 64 } 65 if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() { 66 io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength())) 67 } 68 69 if c.ResponseChannelInActingVersion(actingVersion) { 70 var ResponseChannelLength uint32 71 if err := _m.ReadUint32(_r, &ResponseChannelLength); err != nil { 72 return err 73 } 74 if cap(c.ResponseChannel) < int(ResponseChannelLength) { 75 c.ResponseChannel = make([]uint8, ResponseChannelLength) 76 } 77 c.ResponseChannel = c.ResponseChannel[:ResponseChannelLength] 78 if err := _m.ReadBytes(_r, c.ResponseChannel); err != nil { 79 return err 80 } 81 } 82 if doRangeCheck { 83 if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil { 84 return err 85 } 86 } 87 return nil 88 } 89 90 func (c *ConnectRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 91 if c.CorrelationIdInActingVersion(actingVersion) { 92 if c.CorrelationId < c.CorrelationIdMinValue() || c.CorrelationId > c.CorrelationIdMaxValue() { 93 return fmt.Errorf("Range check failed on c.CorrelationId (%v < %v > %v)", c.CorrelationIdMinValue(), c.CorrelationId, c.CorrelationIdMaxValue()) 94 } 95 } 96 if c.ResponseStreamIdInActingVersion(actingVersion) { 97 if c.ResponseStreamId < c.ResponseStreamIdMinValue() || c.ResponseStreamId > c.ResponseStreamIdMaxValue() { 98 return fmt.Errorf("Range check failed on c.ResponseStreamId (%v < %v > %v)", c.ResponseStreamIdMinValue(), c.ResponseStreamId, c.ResponseStreamIdMaxValue()) 99 } 100 } 101 if c.VersionInActingVersion(actingVersion) { 102 if c.Version != c.VersionNullValue() && (c.Version < c.VersionMinValue() || c.Version > c.VersionMaxValue()) { 103 return fmt.Errorf("Range check failed on c.Version (%v < %v > %v)", c.VersionMinValue(), c.Version, c.VersionMaxValue()) 104 } 105 } 106 return nil 107 } 108 109 func ConnectRequestInit(c *ConnectRequest) { 110 c.Version = 0 111 return 112 } 113 114 func (*ConnectRequest) SbeBlockLength() (blockLength uint16) { 115 return 16 116 } 117 118 func (*ConnectRequest) SbeTemplateId() (templateId uint16) { 119 return 2 120 } 121 122 func (*ConnectRequest) SbeSchemaId() (schemaId uint16) { 123 return 101 124 } 125 126 func (*ConnectRequest) SbeSchemaVersion() (schemaVersion uint16) { 127 return 6 128 } 129 130 func (*ConnectRequest) SbeSemanticType() (semanticType []byte) { 131 return []byte("") 132 } 133 134 func (*ConnectRequest) CorrelationIdId() uint16 { 135 return 1 136 } 137 138 func (*ConnectRequest) CorrelationIdSinceVersion() uint16 { 139 return 0 140 } 141 142 func (c *ConnectRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 143 return actingVersion >= c.CorrelationIdSinceVersion() 144 } 145 146 func (*ConnectRequest) CorrelationIdDeprecated() uint16 { 147 return 0 148 } 149 150 func (*ConnectRequest) CorrelationIdMetaAttribute(meta int) string { 151 switch meta { 152 case 1: 153 return "" 154 case 2: 155 return "" 156 case 3: 157 return "" 158 case 4: 159 return "required" 160 } 161 return "" 162 } 163 164 func (*ConnectRequest) CorrelationIdMinValue() int64 { 165 return math.MinInt64 + 1 166 } 167 168 func (*ConnectRequest) CorrelationIdMaxValue() int64 { 169 return math.MaxInt64 170 } 171 172 func (*ConnectRequest) CorrelationIdNullValue() int64 { 173 return math.MinInt64 174 } 175 176 func (*ConnectRequest) ResponseStreamIdId() uint16 { 177 return 2 178 } 179 180 func (*ConnectRequest) ResponseStreamIdSinceVersion() uint16 { 181 return 0 182 } 183 184 func (c *ConnectRequest) ResponseStreamIdInActingVersion(actingVersion uint16) bool { 185 return actingVersion >= c.ResponseStreamIdSinceVersion() 186 } 187 188 func (*ConnectRequest) ResponseStreamIdDeprecated() uint16 { 189 return 0 190 } 191 192 func (*ConnectRequest) ResponseStreamIdMetaAttribute(meta int) string { 193 switch meta { 194 case 1: 195 return "" 196 case 2: 197 return "" 198 case 3: 199 return "" 200 case 4: 201 return "required" 202 } 203 return "" 204 } 205 206 func (*ConnectRequest) ResponseStreamIdMinValue() int32 { 207 return math.MinInt32 + 1 208 } 209 210 func (*ConnectRequest) ResponseStreamIdMaxValue() int32 { 211 return math.MaxInt32 212 } 213 214 func (*ConnectRequest) ResponseStreamIdNullValue() int32 { 215 return math.MinInt32 216 } 217 218 func (*ConnectRequest) VersionId() uint16 { 219 return 3 220 } 221 222 func (*ConnectRequest) VersionSinceVersion() uint16 { 223 return 2 224 } 225 226 func (c *ConnectRequest) VersionInActingVersion(actingVersion uint16) bool { 227 return actingVersion >= c.VersionSinceVersion() 228 } 229 230 func (*ConnectRequest) VersionDeprecated() uint16 { 231 return 0 232 } 233 234 func (*ConnectRequest) VersionMetaAttribute(meta int) string { 235 switch meta { 236 case 1: 237 return "" 238 case 2: 239 return "" 240 case 3: 241 return "" 242 case 4: 243 return "optional" 244 } 245 return "" 246 } 247 248 func (*ConnectRequest) VersionMinValue() int32 { 249 return 2 250 } 251 252 func (*ConnectRequest) VersionMaxValue() int32 { 253 return 16777215 254 } 255 256 func (*ConnectRequest) VersionNullValue() int32 { 257 return 0 258 } 259 260 func (*ConnectRequest) ResponseChannelMetaAttribute(meta int) string { 261 switch meta { 262 case 1: 263 return "" 264 case 2: 265 return "" 266 case 3: 267 return "" 268 case 4: 269 return "required" 270 } 271 return "" 272 } 273 274 func (*ConnectRequest) ResponseChannelSinceVersion() uint16 { 275 return 0 276 } 277 278 func (c *ConnectRequest) ResponseChannelInActingVersion(actingVersion uint16) bool { 279 return actingVersion >= c.ResponseChannelSinceVersion() 280 } 281 282 func (*ConnectRequest) ResponseChannelDeprecated() uint16 { 283 return 0 284 } 285 286 func (ConnectRequest) ResponseChannelCharacterEncoding() string { 287 return "US-ASCII" 288 } 289 290 func (ConnectRequest) ResponseChannelHeaderLength() uint64 { 291 return 4 292 }