github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/SessionCloseEvent.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 SessionCloseEvent struct { 13 LeadershipTermId int64 14 ClusterSessionId int64 15 Timestamp int64 16 CloseReason CloseReasonEnum 17 } 18 19 func (s *SessionCloseEvent) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 20 if doRangeCheck { 21 if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil { 22 return err 23 } 24 } 25 if err := _m.WriteInt64(_w, s.LeadershipTermId); err != nil { 26 return err 27 } 28 if err := _m.WriteInt64(_w, s.ClusterSessionId); err != nil { 29 return err 30 } 31 if err := _m.WriteInt64(_w, s.Timestamp); err != nil { 32 return err 33 } 34 if err := s.CloseReason.Encode(_m, _w); err != nil { 35 return err 36 } 37 return nil 38 } 39 40 func (s *SessionCloseEvent) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 41 if !s.LeadershipTermIdInActingVersion(actingVersion) { 42 s.LeadershipTermId = s.LeadershipTermIdNullValue() 43 } else { 44 if err := _m.ReadInt64(_r, &s.LeadershipTermId); err != nil { 45 return err 46 } 47 } 48 if !s.ClusterSessionIdInActingVersion(actingVersion) { 49 s.ClusterSessionId = s.ClusterSessionIdNullValue() 50 } else { 51 if err := _m.ReadInt64(_r, &s.ClusterSessionId); err != nil { 52 return err 53 } 54 } 55 if !s.TimestampInActingVersion(actingVersion) { 56 s.Timestamp = s.TimestampNullValue() 57 } else { 58 if err := _m.ReadInt64(_r, &s.Timestamp); err != nil { 59 return err 60 } 61 } 62 if s.CloseReasonInActingVersion(actingVersion) { 63 if err := s.CloseReason.Decode(_m, _r, actingVersion); err != nil { 64 return err 65 } 66 } 67 if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() { 68 io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength())) 69 } 70 if doRangeCheck { 71 if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil { 72 return err 73 } 74 } 75 return nil 76 } 77 78 func (s *SessionCloseEvent) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 79 if s.LeadershipTermIdInActingVersion(actingVersion) { 80 if s.LeadershipTermId < s.LeadershipTermIdMinValue() || s.LeadershipTermId > s.LeadershipTermIdMaxValue() { 81 return fmt.Errorf("Range check failed on s.LeadershipTermId (%v < %v > %v)", s.LeadershipTermIdMinValue(), s.LeadershipTermId, s.LeadershipTermIdMaxValue()) 82 } 83 } 84 if s.ClusterSessionIdInActingVersion(actingVersion) { 85 if s.ClusterSessionId < s.ClusterSessionIdMinValue() || s.ClusterSessionId > s.ClusterSessionIdMaxValue() { 86 return fmt.Errorf("Range check failed on s.ClusterSessionId (%v < %v > %v)", s.ClusterSessionIdMinValue(), s.ClusterSessionId, s.ClusterSessionIdMaxValue()) 87 } 88 } 89 if s.TimestampInActingVersion(actingVersion) { 90 if s.Timestamp < s.TimestampMinValue() || s.Timestamp > s.TimestampMaxValue() { 91 return fmt.Errorf("Range check failed on s.Timestamp (%v < %v > %v)", s.TimestampMinValue(), s.Timestamp, s.TimestampMaxValue()) 92 } 93 } 94 if err := s.CloseReason.RangeCheck(actingVersion, schemaVersion); err != nil { 95 return err 96 } 97 return nil 98 } 99 100 func SessionCloseEventInit(s *SessionCloseEvent) { 101 return 102 } 103 104 func (*SessionCloseEvent) SbeBlockLength() (blockLength uint16) { 105 return 28 106 } 107 108 func (*SessionCloseEvent) SbeTemplateId() (templateId uint16) { 109 return 22 110 } 111 112 func (*SessionCloseEvent) SbeSchemaId() (schemaId uint16) { 113 return 111 114 } 115 116 func (*SessionCloseEvent) SbeSchemaVersion() (schemaVersion uint16) { 117 return 8 118 } 119 120 func (*SessionCloseEvent) SbeSemanticType() (semanticType []byte) { 121 return []byte("") 122 } 123 124 func (*SessionCloseEvent) LeadershipTermIdId() uint16 { 125 return 1 126 } 127 128 func (*SessionCloseEvent) LeadershipTermIdSinceVersion() uint16 { 129 return 0 130 } 131 132 func (s *SessionCloseEvent) LeadershipTermIdInActingVersion(actingVersion uint16) bool { 133 return actingVersion >= s.LeadershipTermIdSinceVersion() 134 } 135 136 func (*SessionCloseEvent) LeadershipTermIdDeprecated() uint16 { 137 return 0 138 } 139 140 func (*SessionCloseEvent) LeadershipTermIdMetaAttribute(meta int) string { 141 switch meta { 142 case 1: 143 return "" 144 case 2: 145 return "" 146 case 3: 147 return "" 148 case 4: 149 return "required" 150 } 151 return "" 152 } 153 154 func (*SessionCloseEvent) LeadershipTermIdMinValue() int64 { 155 return math.MinInt64 + 1 156 } 157 158 func (*SessionCloseEvent) LeadershipTermIdMaxValue() int64 { 159 return math.MaxInt64 160 } 161 162 func (*SessionCloseEvent) LeadershipTermIdNullValue() int64 { 163 return math.MinInt64 164 } 165 166 func (*SessionCloseEvent) ClusterSessionIdId() uint16 { 167 return 2 168 } 169 170 func (*SessionCloseEvent) ClusterSessionIdSinceVersion() uint16 { 171 return 0 172 } 173 174 func (s *SessionCloseEvent) ClusterSessionIdInActingVersion(actingVersion uint16) bool { 175 return actingVersion >= s.ClusterSessionIdSinceVersion() 176 } 177 178 func (*SessionCloseEvent) ClusterSessionIdDeprecated() uint16 { 179 return 0 180 } 181 182 func (*SessionCloseEvent) ClusterSessionIdMetaAttribute(meta int) string { 183 switch meta { 184 case 1: 185 return "" 186 case 2: 187 return "" 188 case 3: 189 return "" 190 case 4: 191 return "required" 192 } 193 return "" 194 } 195 196 func (*SessionCloseEvent) ClusterSessionIdMinValue() int64 { 197 return math.MinInt64 + 1 198 } 199 200 func (*SessionCloseEvent) ClusterSessionIdMaxValue() int64 { 201 return math.MaxInt64 202 } 203 204 func (*SessionCloseEvent) ClusterSessionIdNullValue() int64 { 205 return math.MinInt64 206 } 207 208 func (*SessionCloseEvent) TimestampId() uint16 { 209 return 3 210 } 211 212 func (*SessionCloseEvent) TimestampSinceVersion() uint16 { 213 return 0 214 } 215 216 func (s *SessionCloseEvent) TimestampInActingVersion(actingVersion uint16) bool { 217 return actingVersion >= s.TimestampSinceVersion() 218 } 219 220 func (*SessionCloseEvent) TimestampDeprecated() uint16 { 221 return 0 222 } 223 224 func (*SessionCloseEvent) TimestampMetaAttribute(meta int) string { 225 switch meta { 226 case 1: 227 return "" 228 case 2: 229 return "" 230 case 3: 231 return "" 232 case 4: 233 return "required" 234 } 235 return "" 236 } 237 238 func (*SessionCloseEvent) TimestampMinValue() int64 { 239 return math.MinInt64 + 1 240 } 241 242 func (*SessionCloseEvent) TimestampMaxValue() int64 { 243 return math.MaxInt64 244 } 245 246 func (*SessionCloseEvent) TimestampNullValue() int64 { 247 return math.MinInt64 248 } 249 250 func (*SessionCloseEvent) CloseReasonId() uint16 { 251 return 4 252 } 253 254 func (*SessionCloseEvent) CloseReasonSinceVersion() uint16 { 255 return 0 256 } 257 258 func (s *SessionCloseEvent) CloseReasonInActingVersion(actingVersion uint16) bool { 259 return actingVersion >= s.CloseReasonSinceVersion() 260 } 261 262 func (*SessionCloseEvent) CloseReasonDeprecated() uint16 { 263 return 0 264 } 265 266 func (*SessionCloseEvent) CloseReasonMetaAttribute(meta int) string { 267 switch meta { 268 case 1: 269 return "" 270 case 2: 271 return "" 272 case 3: 273 return "" 274 case 4: 275 return "required" 276 } 277 return "" 278 }