github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/AdminRequest.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 AdminRequest struct { 13 LeadershipTermId int64 14 ClusterSessionId int64 15 CorrelationId int64 16 RequestType AdminRequestTypeEnum 17 Payload []uint8 18 } 19 20 func (a *AdminRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 21 if doRangeCheck { 22 if err := a.RangeCheck(a.SbeSchemaVersion(), a.SbeSchemaVersion()); err != nil { 23 return err 24 } 25 } 26 if err := _m.WriteInt64(_w, a.LeadershipTermId); err != nil { 27 return err 28 } 29 if err := _m.WriteInt64(_w, a.ClusterSessionId); err != nil { 30 return err 31 } 32 if err := _m.WriteInt64(_w, a.CorrelationId); err != nil { 33 return err 34 } 35 if err := a.RequestType.Encode(_m, _w); err != nil { 36 return err 37 } 38 if err := _m.WriteUint32(_w, uint32(len(a.Payload))); err != nil { 39 return err 40 } 41 if err := _m.WriteBytes(_w, a.Payload); err != nil { 42 return err 43 } 44 return nil 45 } 46 47 func (a *AdminRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 48 if !a.LeadershipTermIdInActingVersion(actingVersion) { 49 a.LeadershipTermId = a.LeadershipTermIdNullValue() 50 } else { 51 if err := _m.ReadInt64(_r, &a.LeadershipTermId); err != nil { 52 return err 53 } 54 } 55 if !a.ClusterSessionIdInActingVersion(actingVersion) { 56 a.ClusterSessionId = a.ClusterSessionIdNullValue() 57 } else { 58 if err := _m.ReadInt64(_r, &a.ClusterSessionId); err != nil { 59 return err 60 } 61 } 62 if !a.CorrelationIdInActingVersion(actingVersion) { 63 a.CorrelationId = a.CorrelationIdNullValue() 64 } else { 65 if err := _m.ReadInt64(_r, &a.CorrelationId); err != nil { 66 return err 67 } 68 } 69 if a.RequestTypeInActingVersion(actingVersion) { 70 if err := a.RequestType.Decode(_m, _r, actingVersion); err != nil { 71 return err 72 } 73 } 74 if actingVersion > a.SbeSchemaVersion() && blockLength > a.SbeBlockLength() { 75 io.CopyN(ioutil.Discard, _r, int64(blockLength-a.SbeBlockLength())) 76 } 77 78 if a.PayloadInActingVersion(actingVersion) { 79 var PayloadLength uint32 80 if err := _m.ReadUint32(_r, &PayloadLength); err != nil { 81 return err 82 } 83 if cap(a.Payload) < int(PayloadLength) { 84 a.Payload = make([]uint8, PayloadLength) 85 } 86 a.Payload = a.Payload[:PayloadLength] 87 if err := _m.ReadBytes(_r, a.Payload); err != nil { 88 return err 89 } 90 } 91 if doRangeCheck { 92 if err := a.RangeCheck(actingVersion, a.SbeSchemaVersion()); err != nil { 93 return err 94 } 95 } 96 return nil 97 } 98 99 func (a *AdminRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 100 if a.LeadershipTermIdInActingVersion(actingVersion) { 101 if a.LeadershipTermId < a.LeadershipTermIdMinValue() || a.LeadershipTermId > a.LeadershipTermIdMaxValue() { 102 return fmt.Errorf("Range check failed on a.LeadershipTermId (%v < %v > %v)", a.LeadershipTermIdMinValue(), a.LeadershipTermId, a.LeadershipTermIdMaxValue()) 103 } 104 } 105 if a.ClusterSessionIdInActingVersion(actingVersion) { 106 if a.ClusterSessionId < a.ClusterSessionIdMinValue() || a.ClusterSessionId > a.ClusterSessionIdMaxValue() { 107 return fmt.Errorf("Range check failed on a.ClusterSessionId (%v < %v > %v)", a.ClusterSessionIdMinValue(), a.ClusterSessionId, a.ClusterSessionIdMaxValue()) 108 } 109 } 110 if a.CorrelationIdInActingVersion(actingVersion) { 111 if a.CorrelationId < a.CorrelationIdMinValue() || a.CorrelationId > a.CorrelationIdMaxValue() { 112 return fmt.Errorf("Range check failed on a.CorrelationId (%v < %v > %v)", a.CorrelationIdMinValue(), a.CorrelationId, a.CorrelationIdMaxValue()) 113 } 114 } 115 if err := a.RequestType.RangeCheck(actingVersion, schemaVersion); err != nil { 116 return err 117 } 118 return nil 119 } 120 121 func AdminRequestInit(a *AdminRequest) { 122 return 123 } 124 125 func (*AdminRequest) SbeBlockLength() (blockLength uint16) { 126 return 28 127 } 128 129 func (*AdminRequest) SbeTemplateId() (templateId uint16) { 130 return 26 131 } 132 133 func (*AdminRequest) SbeSchemaId() (schemaId uint16) { 134 return 111 135 } 136 137 func (*AdminRequest) SbeSchemaVersion() (schemaVersion uint16) { 138 return 8 139 } 140 141 func (*AdminRequest) SbeSemanticType() (semanticType []byte) { 142 return []byte("") 143 } 144 145 func (*AdminRequest) LeadershipTermIdId() uint16 { 146 return 1 147 } 148 149 func (*AdminRequest) LeadershipTermIdSinceVersion() uint16 { 150 return 0 151 } 152 153 func (a *AdminRequest) LeadershipTermIdInActingVersion(actingVersion uint16) bool { 154 return actingVersion >= a.LeadershipTermIdSinceVersion() 155 } 156 157 func (*AdminRequest) LeadershipTermIdDeprecated() uint16 { 158 return 0 159 } 160 161 func (*AdminRequest) LeadershipTermIdMetaAttribute(meta int) string { 162 switch meta { 163 case 1: 164 return "" 165 case 2: 166 return "" 167 case 3: 168 return "" 169 case 4: 170 return "required" 171 } 172 return "" 173 } 174 175 func (*AdminRequest) LeadershipTermIdMinValue() int64 { 176 return math.MinInt64 + 1 177 } 178 179 func (*AdminRequest) LeadershipTermIdMaxValue() int64 { 180 return math.MaxInt64 181 } 182 183 func (*AdminRequest) LeadershipTermIdNullValue() int64 { 184 return math.MinInt64 185 } 186 187 func (*AdminRequest) ClusterSessionIdId() uint16 { 188 return 2 189 } 190 191 func (*AdminRequest) ClusterSessionIdSinceVersion() uint16 { 192 return 0 193 } 194 195 func (a *AdminRequest) ClusterSessionIdInActingVersion(actingVersion uint16) bool { 196 return actingVersion >= a.ClusterSessionIdSinceVersion() 197 } 198 199 func (*AdminRequest) ClusterSessionIdDeprecated() uint16 { 200 return 0 201 } 202 203 func (*AdminRequest) ClusterSessionIdMetaAttribute(meta int) string { 204 switch meta { 205 case 1: 206 return "" 207 case 2: 208 return "" 209 case 3: 210 return "" 211 case 4: 212 return "required" 213 } 214 return "" 215 } 216 217 func (*AdminRequest) ClusterSessionIdMinValue() int64 { 218 return math.MinInt64 + 1 219 } 220 221 func (*AdminRequest) ClusterSessionIdMaxValue() int64 { 222 return math.MaxInt64 223 } 224 225 func (*AdminRequest) ClusterSessionIdNullValue() int64 { 226 return math.MinInt64 227 } 228 229 func (*AdminRequest) CorrelationIdId() uint16 { 230 return 3 231 } 232 233 func (*AdminRequest) CorrelationIdSinceVersion() uint16 { 234 return 0 235 } 236 237 func (a *AdminRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 238 return actingVersion >= a.CorrelationIdSinceVersion() 239 } 240 241 func (*AdminRequest) CorrelationIdDeprecated() uint16 { 242 return 0 243 } 244 245 func (*AdminRequest) CorrelationIdMetaAttribute(meta int) string { 246 switch meta { 247 case 1: 248 return "" 249 case 2: 250 return "" 251 case 3: 252 return "" 253 case 4: 254 return "required" 255 } 256 return "" 257 } 258 259 func (*AdminRequest) CorrelationIdMinValue() int64 { 260 return math.MinInt64 + 1 261 } 262 263 func (*AdminRequest) CorrelationIdMaxValue() int64 { 264 return math.MaxInt64 265 } 266 267 func (*AdminRequest) CorrelationIdNullValue() int64 { 268 return math.MinInt64 269 } 270 271 func (*AdminRequest) RequestTypeId() uint16 { 272 return 4 273 } 274 275 func (*AdminRequest) RequestTypeSinceVersion() uint16 { 276 return 0 277 } 278 279 func (a *AdminRequest) RequestTypeInActingVersion(actingVersion uint16) bool { 280 return actingVersion >= a.RequestTypeSinceVersion() 281 } 282 283 func (*AdminRequest) RequestTypeDeprecated() uint16 { 284 return 0 285 } 286 287 func (*AdminRequest) RequestTypeMetaAttribute(meta int) string { 288 switch meta { 289 case 1: 290 return "" 291 case 2: 292 return "" 293 case 3: 294 return "" 295 case 4: 296 return "required" 297 } 298 return "" 299 } 300 301 func (*AdminRequest) PayloadMetaAttribute(meta int) string { 302 switch meta { 303 case 1: 304 return "" 305 case 2: 306 return "" 307 case 3: 308 return "" 309 case 4: 310 return "required" 311 } 312 return "" 313 } 314 315 func (*AdminRequest) PayloadSinceVersion() uint16 { 316 return 0 317 } 318 319 func (a *AdminRequest) PayloadInActingVersion(actingVersion uint16) bool { 320 return actingVersion >= a.PayloadSinceVersion() 321 } 322 323 func (*AdminRequest) PayloadDeprecated() uint16 { 324 return 0 325 } 326 327 func (AdminRequest) PayloadCharacterEncoding() string { 328 return "null" 329 } 330 331 func (AdminRequest) PayloadHeaderLength() uint64 { 332 return 4 333 }