github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/SessionConnectRequest.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 SessionConnectRequest struct { 13 CorrelationId int64 14 ResponseStreamId int32 15 Version int32 16 ResponseChannel []uint8 17 EncodedCredentials []uint8 18 } 19 20 func (s *SessionConnectRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 21 if doRangeCheck { 22 if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil { 23 return err 24 } 25 } 26 if err := _m.WriteInt64(_w, s.CorrelationId); err != nil { 27 return err 28 } 29 if err := _m.WriteInt32(_w, s.ResponseStreamId); err != nil { 30 return err 31 } 32 if err := _m.WriteInt32(_w, s.Version); err != nil { 33 return err 34 } 35 if err := _m.WriteUint32(_w, uint32(len(s.ResponseChannel))); err != nil { 36 return err 37 } 38 if err := _m.WriteBytes(_w, s.ResponseChannel); err != nil { 39 return err 40 } 41 if err := _m.WriteUint32(_w, uint32(len(s.EncodedCredentials))); err != nil { 42 return err 43 } 44 if err := _m.WriteBytes(_w, s.EncodedCredentials); err != nil { 45 return err 46 } 47 return nil 48 } 49 50 func (s *SessionConnectRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 51 if !s.CorrelationIdInActingVersion(actingVersion) { 52 s.CorrelationId = s.CorrelationIdNullValue() 53 } else { 54 if err := _m.ReadInt64(_r, &s.CorrelationId); err != nil { 55 return err 56 } 57 } 58 if !s.ResponseStreamIdInActingVersion(actingVersion) { 59 s.ResponseStreamId = s.ResponseStreamIdNullValue() 60 } else { 61 if err := _m.ReadInt32(_r, &s.ResponseStreamId); err != nil { 62 return err 63 } 64 } 65 if !s.VersionInActingVersion(actingVersion) { 66 s.Version = s.VersionNullValue() 67 } else { 68 if err := _m.ReadInt32(_r, &s.Version); err != nil { 69 return err 70 } 71 } 72 if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() { 73 io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength())) 74 } 75 76 if s.ResponseChannelInActingVersion(actingVersion) { 77 var ResponseChannelLength uint32 78 if err := _m.ReadUint32(_r, &ResponseChannelLength); err != nil { 79 return err 80 } 81 if cap(s.ResponseChannel) < int(ResponseChannelLength) { 82 s.ResponseChannel = make([]uint8, ResponseChannelLength) 83 } 84 s.ResponseChannel = s.ResponseChannel[:ResponseChannelLength] 85 if err := _m.ReadBytes(_r, s.ResponseChannel); err != nil { 86 return err 87 } 88 } 89 90 if s.EncodedCredentialsInActingVersion(actingVersion) { 91 var EncodedCredentialsLength uint32 92 if err := _m.ReadUint32(_r, &EncodedCredentialsLength); err != nil { 93 return err 94 } 95 if cap(s.EncodedCredentials) < int(EncodedCredentialsLength) { 96 s.EncodedCredentials = make([]uint8, EncodedCredentialsLength) 97 } 98 s.EncodedCredentials = s.EncodedCredentials[:EncodedCredentialsLength] 99 if err := _m.ReadBytes(_r, s.EncodedCredentials); err != nil { 100 return err 101 } 102 } 103 if doRangeCheck { 104 if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil { 105 return err 106 } 107 } 108 return nil 109 } 110 111 func (s *SessionConnectRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 112 if s.CorrelationIdInActingVersion(actingVersion) { 113 if s.CorrelationId < s.CorrelationIdMinValue() || s.CorrelationId > s.CorrelationIdMaxValue() { 114 return fmt.Errorf("Range check failed on s.CorrelationId (%v < %v > %v)", s.CorrelationIdMinValue(), s.CorrelationId, s.CorrelationIdMaxValue()) 115 } 116 } 117 if s.ResponseStreamIdInActingVersion(actingVersion) { 118 if s.ResponseStreamId < s.ResponseStreamIdMinValue() || s.ResponseStreamId > s.ResponseStreamIdMaxValue() { 119 return fmt.Errorf("Range check failed on s.ResponseStreamId (%v < %v > %v)", s.ResponseStreamIdMinValue(), s.ResponseStreamId, s.ResponseStreamIdMaxValue()) 120 } 121 } 122 if s.VersionInActingVersion(actingVersion) { 123 if s.Version != s.VersionNullValue() && (s.Version < s.VersionMinValue() || s.Version > s.VersionMaxValue()) { 124 return fmt.Errorf("Range check failed on s.Version (%v < %v > %v)", s.VersionMinValue(), s.Version, s.VersionMaxValue()) 125 } 126 } 127 for idx, ch := range s.ResponseChannel { 128 if ch > 127 { 129 return fmt.Errorf("s.ResponseChannel[%d]=%d failed ASCII validation", idx, ch) 130 } 131 } 132 return nil 133 } 134 135 func SessionConnectRequestInit(s *SessionConnectRequest) { 136 s.Version = 0 137 return 138 } 139 140 func (*SessionConnectRequest) SbeBlockLength() (blockLength uint16) { 141 return 16 142 } 143 144 func (*SessionConnectRequest) SbeTemplateId() (templateId uint16) { 145 return 3 146 } 147 148 func (*SessionConnectRequest) SbeSchemaId() (schemaId uint16) { 149 return 111 150 } 151 152 func (*SessionConnectRequest) SbeSchemaVersion() (schemaVersion uint16) { 153 return 8 154 } 155 156 func (*SessionConnectRequest) SbeSemanticType() (semanticType []byte) { 157 return []byte("") 158 } 159 160 func (*SessionConnectRequest) CorrelationIdId() uint16 { 161 return 1 162 } 163 164 func (*SessionConnectRequest) CorrelationIdSinceVersion() uint16 { 165 return 0 166 } 167 168 func (s *SessionConnectRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 169 return actingVersion >= s.CorrelationIdSinceVersion() 170 } 171 172 func (*SessionConnectRequest) CorrelationIdDeprecated() uint16 { 173 return 0 174 } 175 176 func (*SessionConnectRequest) CorrelationIdMetaAttribute(meta int) string { 177 switch meta { 178 case 1: 179 return "" 180 case 2: 181 return "" 182 case 3: 183 return "" 184 case 4: 185 return "required" 186 } 187 return "" 188 } 189 190 func (*SessionConnectRequest) CorrelationIdMinValue() int64 { 191 return math.MinInt64 + 1 192 } 193 194 func (*SessionConnectRequest) CorrelationIdMaxValue() int64 { 195 return math.MaxInt64 196 } 197 198 func (*SessionConnectRequest) CorrelationIdNullValue() int64 { 199 return math.MinInt64 200 } 201 202 func (*SessionConnectRequest) ResponseStreamIdId() uint16 { 203 return 2 204 } 205 206 func (*SessionConnectRequest) ResponseStreamIdSinceVersion() uint16 { 207 return 0 208 } 209 210 func (s *SessionConnectRequest) ResponseStreamIdInActingVersion(actingVersion uint16) bool { 211 return actingVersion >= s.ResponseStreamIdSinceVersion() 212 } 213 214 func (*SessionConnectRequest) ResponseStreamIdDeprecated() uint16 { 215 return 0 216 } 217 218 func (*SessionConnectRequest) ResponseStreamIdMetaAttribute(meta int) string { 219 switch meta { 220 case 1: 221 return "" 222 case 2: 223 return "" 224 case 3: 225 return "" 226 case 4: 227 return "required" 228 } 229 return "" 230 } 231 232 func (*SessionConnectRequest) ResponseStreamIdMinValue() int32 { 233 return math.MinInt32 + 1 234 } 235 236 func (*SessionConnectRequest) ResponseStreamIdMaxValue() int32 { 237 return math.MaxInt32 238 } 239 240 func (*SessionConnectRequest) ResponseStreamIdNullValue() int32 { 241 return math.MinInt32 242 } 243 244 func (*SessionConnectRequest) VersionId() uint16 { 245 return 3 246 } 247 248 func (*SessionConnectRequest) VersionSinceVersion() uint16 { 249 return 2 250 } 251 252 func (s *SessionConnectRequest) VersionInActingVersion(actingVersion uint16) bool { 253 return actingVersion >= s.VersionSinceVersion() 254 } 255 256 func (*SessionConnectRequest) VersionDeprecated() uint16 { 257 return 0 258 } 259 260 func (*SessionConnectRequest) VersionMetaAttribute(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 "optional" 270 } 271 return "" 272 } 273 274 func (*SessionConnectRequest) VersionMinValue() int32 { 275 return 1 276 } 277 278 func (*SessionConnectRequest) VersionMaxValue() int32 { 279 return 16777215 280 } 281 282 func (*SessionConnectRequest) VersionNullValue() int32 { 283 return 0 284 } 285 286 func (*SessionConnectRequest) ResponseChannelMetaAttribute(meta int) string { 287 switch meta { 288 case 1: 289 return "" 290 case 2: 291 return "" 292 case 3: 293 return "" 294 case 4: 295 return "required" 296 } 297 return "" 298 } 299 300 func (*SessionConnectRequest) ResponseChannelSinceVersion() uint16 { 301 return 0 302 } 303 304 func (s *SessionConnectRequest) ResponseChannelInActingVersion(actingVersion uint16) bool { 305 return actingVersion >= s.ResponseChannelSinceVersion() 306 } 307 308 func (*SessionConnectRequest) ResponseChannelDeprecated() uint16 { 309 return 0 310 } 311 312 func (SessionConnectRequest) ResponseChannelCharacterEncoding() string { 313 return "US-ASCII" 314 } 315 316 func (SessionConnectRequest) ResponseChannelHeaderLength() uint64 { 317 return 4 318 } 319 320 func (*SessionConnectRequest) EncodedCredentialsMetaAttribute(meta int) string { 321 switch meta { 322 case 1: 323 return "" 324 case 2: 325 return "" 326 case 3: 327 return "" 328 case 4: 329 return "required" 330 } 331 return "" 332 } 333 334 func (*SessionConnectRequest) EncodedCredentialsSinceVersion() uint16 { 335 return 0 336 } 337 338 func (s *SessionConnectRequest) EncodedCredentialsInActingVersion(actingVersion uint16) bool { 339 return actingVersion >= s.EncodedCredentialsSinceVersion() 340 } 341 342 func (*SessionConnectRequest) EncodedCredentialsDeprecated() uint16 { 343 return 0 344 } 345 346 func (SessionConnectRequest) EncodedCredentialsCharacterEncoding() string { 347 return "null" 348 } 349 350 func (SessionConnectRequest) EncodedCredentialsHeaderLength() uint64 { 351 return 4 352 }