github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/ControlResponse.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 ControlResponse struct { 13 ControlSessionId int64 14 CorrelationId int64 15 RelevantId int64 16 Code ControlResponseCodeEnum 17 Version int32 18 ErrorMessage []uint8 19 } 20 21 func (c *ControlResponse) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 22 if doRangeCheck { 23 if err := c.RangeCheck(c.SbeSchemaVersion(), c.SbeSchemaVersion()); err != nil { 24 return err 25 } 26 } 27 if err := _m.WriteInt64(_w, c.ControlSessionId); err != nil { 28 return err 29 } 30 if err := _m.WriteInt64(_w, c.CorrelationId); err != nil { 31 return err 32 } 33 if err := _m.WriteInt64(_w, c.RelevantId); err != nil { 34 return err 35 } 36 if err := c.Code.Encode(_m, _w); err != nil { 37 return err 38 } 39 if err := _m.WriteInt32(_w, c.Version); err != nil { 40 return err 41 } 42 if err := _m.WriteUint32(_w, uint32(len(c.ErrorMessage))); err != nil { 43 return err 44 } 45 if err := _m.WriteBytes(_w, c.ErrorMessage); err != nil { 46 return err 47 } 48 return nil 49 } 50 51 func (c *ControlResponse) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 52 if !c.ControlSessionIdInActingVersion(actingVersion) { 53 c.ControlSessionId = c.ControlSessionIdNullValue() 54 } else { 55 if err := _m.ReadInt64(_r, &c.ControlSessionId); err != nil { 56 return err 57 } 58 } 59 if !c.CorrelationIdInActingVersion(actingVersion) { 60 c.CorrelationId = c.CorrelationIdNullValue() 61 } else { 62 if err := _m.ReadInt64(_r, &c.CorrelationId); err != nil { 63 return err 64 } 65 } 66 if !c.RelevantIdInActingVersion(actingVersion) { 67 c.RelevantId = c.RelevantIdNullValue() 68 } else { 69 if err := _m.ReadInt64(_r, &c.RelevantId); err != nil { 70 return err 71 } 72 } 73 if c.CodeInActingVersion(actingVersion) { 74 if err := c.Code.Decode(_m, _r, actingVersion); err != nil { 75 return err 76 } 77 } 78 if !c.VersionInActingVersion(actingVersion) { 79 c.Version = c.VersionNullValue() 80 } else { 81 if err := _m.ReadInt32(_r, &c.Version); err != nil { 82 return err 83 } 84 } 85 if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() { 86 io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength())) 87 } 88 89 if c.ErrorMessageInActingVersion(actingVersion) { 90 var ErrorMessageLength uint32 91 if err := _m.ReadUint32(_r, &ErrorMessageLength); err != nil { 92 return err 93 } 94 if cap(c.ErrorMessage) < int(ErrorMessageLength) { 95 c.ErrorMessage = make([]uint8, ErrorMessageLength) 96 } 97 c.ErrorMessage = c.ErrorMessage[:ErrorMessageLength] 98 if err := _m.ReadBytes(_r, c.ErrorMessage); err != nil { 99 return err 100 } 101 } 102 if doRangeCheck { 103 if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil { 104 return err 105 } 106 } 107 return nil 108 } 109 110 func (c *ControlResponse) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 111 if c.ControlSessionIdInActingVersion(actingVersion) { 112 if c.ControlSessionId < c.ControlSessionIdMinValue() || c.ControlSessionId > c.ControlSessionIdMaxValue() { 113 return fmt.Errorf("Range check failed on c.ControlSessionId (%v < %v > %v)", c.ControlSessionIdMinValue(), c.ControlSessionId, c.ControlSessionIdMaxValue()) 114 } 115 } 116 if c.CorrelationIdInActingVersion(actingVersion) { 117 if c.CorrelationId < c.CorrelationIdMinValue() || c.CorrelationId > c.CorrelationIdMaxValue() { 118 return fmt.Errorf("Range check failed on c.CorrelationId (%v < %v > %v)", c.CorrelationIdMinValue(), c.CorrelationId, c.CorrelationIdMaxValue()) 119 } 120 } 121 if c.RelevantIdInActingVersion(actingVersion) { 122 if c.RelevantId < c.RelevantIdMinValue() || c.RelevantId > c.RelevantIdMaxValue() { 123 return fmt.Errorf("Range check failed on c.RelevantId (%v < %v > %v)", c.RelevantIdMinValue(), c.RelevantId, c.RelevantIdMaxValue()) 124 } 125 } 126 if err := c.Code.RangeCheck(actingVersion, schemaVersion); err != nil { 127 return err 128 } 129 if c.VersionInActingVersion(actingVersion) { 130 if c.Version != c.VersionNullValue() && (c.Version < c.VersionMinValue() || c.Version > c.VersionMaxValue()) { 131 return fmt.Errorf("Range check failed on c.Version (%v < %v > %v)", c.VersionMinValue(), c.Version, c.VersionMaxValue()) 132 } 133 } 134 return nil 135 } 136 137 func ControlResponseInit(c *ControlResponse) { 138 c.Version = 0 139 return 140 } 141 142 func (*ControlResponse) SbeBlockLength() (blockLength uint16) { 143 return 32 144 } 145 146 func (*ControlResponse) SbeTemplateId() (templateId uint16) { 147 return 1 148 } 149 150 func (*ControlResponse) SbeSchemaId() (schemaId uint16) { 151 return 101 152 } 153 154 func (*ControlResponse) SbeSchemaVersion() (schemaVersion uint16) { 155 return 6 156 } 157 158 func (*ControlResponse) SbeSemanticType() (semanticType []byte) { 159 return []byte("") 160 } 161 162 func (*ControlResponse) ControlSessionIdId() uint16 { 163 return 1 164 } 165 166 func (*ControlResponse) ControlSessionIdSinceVersion() uint16 { 167 return 0 168 } 169 170 func (c *ControlResponse) ControlSessionIdInActingVersion(actingVersion uint16) bool { 171 return actingVersion >= c.ControlSessionIdSinceVersion() 172 } 173 174 func (*ControlResponse) ControlSessionIdDeprecated() uint16 { 175 return 0 176 } 177 178 func (*ControlResponse) ControlSessionIdMetaAttribute(meta int) string { 179 switch meta { 180 case 1: 181 return "" 182 case 2: 183 return "" 184 case 3: 185 return "" 186 case 4: 187 return "required" 188 } 189 return "" 190 } 191 192 func (*ControlResponse) ControlSessionIdMinValue() int64 { 193 return math.MinInt64 + 1 194 } 195 196 func (*ControlResponse) ControlSessionIdMaxValue() int64 { 197 return math.MaxInt64 198 } 199 200 func (*ControlResponse) ControlSessionIdNullValue() int64 { 201 return math.MinInt64 202 } 203 204 func (*ControlResponse) CorrelationIdId() uint16 { 205 return 2 206 } 207 208 func (*ControlResponse) CorrelationIdSinceVersion() uint16 { 209 return 0 210 } 211 212 func (c *ControlResponse) CorrelationIdInActingVersion(actingVersion uint16) bool { 213 return actingVersion >= c.CorrelationIdSinceVersion() 214 } 215 216 func (*ControlResponse) CorrelationIdDeprecated() uint16 { 217 return 0 218 } 219 220 func (*ControlResponse) CorrelationIdMetaAttribute(meta int) string { 221 switch meta { 222 case 1: 223 return "" 224 case 2: 225 return "" 226 case 3: 227 return "" 228 case 4: 229 return "required" 230 } 231 return "" 232 } 233 234 func (*ControlResponse) CorrelationIdMinValue() int64 { 235 return math.MinInt64 + 1 236 } 237 238 func (*ControlResponse) CorrelationIdMaxValue() int64 { 239 return math.MaxInt64 240 } 241 242 func (*ControlResponse) CorrelationIdNullValue() int64 { 243 return math.MinInt64 244 } 245 246 func (*ControlResponse) RelevantIdId() uint16 { 247 return 3 248 } 249 250 func (*ControlResponse) RelevantIdSinceVersion() uint16 { 251 return 0 252 } 253 254 func (c *ControlResponse) RelevantIdInActingVersion(actingVersion uint16) bool { 255 return actingVersion >= c.RelevantIdSinceVersion() 256 } 257 258 func (*ControlResponse) RelevantIdDeprecated() uint16 { 259 return 0 260 } 261 262 func (*ControlResponse) RelevantIdMetaAttribute(meta int) string { 263 switch meta { 264 case 1: 265 return "" 266 case 2: 267 return "" 268 case 3: 269 return "" 270 case 4: 271 return "required" 272 } 273 return "" 274 } 275 276 func (*ControlResponse) RelevantIdMinValue() int64 { 277 return math.MinInt64 + 1 278 } 279 280 func (*ControlResponse) RelevantIdMaxValue() int64 { 281 return math.MaxInt64 282 } 283 284 func (*ControlResponse) RelevantIdNullValue() int64 { 285 return math.MinInt64 286 } 287 288 func (*ControlResponse) CodeId() uint16 { 289 return 4 290 } 291 292 func (*ControlResponse) CodeSinceVersion() uint16 { 293 return 0 294 } 295 296 func (c *ControlResponse) CodeInActingVersion(actingVersion uint16) bool { 297 return actingVersion >= c.CodeSinceVersion() 298 } 299 300 func (*ControlResponse) CodeDeprecated() uint16 { 301 return 0 302 } 303 304 func (*ControlResponse) CodeMetaAttribute(meta int) string { 305 switch meta { 306 case 1: 307 return "" 308 case 2: 309 return "" 310 case 3: 311 return "" 312 case 4: 313 return "required" 314 } 315 return "" 316 } 317 318 func (*ControlResponse) VersionId() uint16 { 319 return 5 320 } 321 322 func (*ControlResponse) VersionSinceVersion() uint16 { 323 return 4 324 } 325 326 func (c *ControlResponse) VersionInActingVersion(actingVersion uint16) bool { 327 return actingVersion >= c.VersionSinceVersion() 328 } 329 330 func (*ControlResponse) VersionDeprecated() uint16 { 331 return 0 332 } 333 334 func (*ControlResponse) VersionMetaAttribute(meta int) string { 335 switch meta { 336 case 1: 337 return "" 338 case 2: 339 return "" 340 case 3: 341 return "" 342 case 4: 343 return "optional" 344 } 345 return "" 346 } 347 348 func (*ControlResponse) VersionMinValue() int32 { 349 return 2 350 } 351 352 func (*ControlResponse) VersionMaxValue() int32 { 353 return 16777215 354 } 355 356 func (*ControlResponse) VersionNullValue() int32 { 357 return 0 358 } 359 360 func (*ControlResponse) ErrorMessageMetaAttribute(meta int) string { 361 switch meta { 362 case 1: 363 return "" 364 case 2: 365 return "" 366 case 3: 367 return "" 368 case 4: 369 return "required" 370 } 371 return "" 372 } 373 374 func (*ControlResponse) ErrorMessageSinceVersion() uint16 { 375 return 0 376 } 377 378 func (c *ControlResponse) ErrorMessageInActingVersion(actingVersion uint16) bool { 379 return actingVersion >= c.ErrorMessageSinceVersion() 380 } 381 382 func (*ControlResponse) ErrorMessageDeprecated() uint16 { 383 return 0 384 } 385 386 func (ControlResponse) ErrorMessageCharacterEncoding() string { 387 return "US-ASCII" 388 } 389 390 func (ControlResponse) ErrorMessageHeaderLength() uint64 { 391 return 4 392 }