github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/StopPositionRequest.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 StopPositionRequest struct { 13 ControlSessionId int64 14 CorrelationId int64 15 RecordingId int64 16 } 17 18 func (s *StopPositionRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 19 if doRangeCheck { 20 if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil { 21 return err 22 } 23 } 24 if err := _m.WriteInt64(_w, s.ControlSessionId); err != nil { 25 return err 26 } 27 if err := _m.WriteInt64(_w, s.CorrelationId); err != nil { 28 return err 29 } 30 if err := _m.WriteInt64(_w, s.RecordingId); err != nil { 31 return err 32 } 33 return nil 34 } 35 36 func (s *StopPositionRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 37 if !s.ControlSessionIdInActingVersion(actingVersion) { 38 s.ControlSessionId = s.ControlSessionIdNullValue() 39 } else { 40 if err := _m.ReadInt64(_r, &s.ControlSessionId); err != nil { 41 return err 42 } 43 } 44 if !s.CorrelationIdInActingVersion(actingVersion) { 45 s.CorrelationId = s.CorrelationIdNullValue() 46 } else { 47 if err := _m.ReadInt64(_r, &s.CorrelationId); err != nil { 48 return err 49 } 50 } 51 if !s.RecordingIdInActingVersion(actingVersion) { 52 s.RecordingId = s.RecordingIdNullValue() 53 } else { 54 if err := _m.ReadInt64(_r, &s.RecordingId); err != nil { 55 return err 56 } 57 } 58 if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() { 59 io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength())) 60 } 61 if doRangeCheck { 62 if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil { 63 return err 64 } 65 } 66 return nil 67 } 68 69 func (s *StopPositionRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 70 if s.ControlSessionIdInActingVersion(actingVersion) { 71 if s.ControlSessionId < s.ControlSessionIdMinValue() || s.ControlSessionId > s.ControlSessionIdMaxValue() { 72 return fmt.Errorf("Range check failed on s.ControlSessionId (%v < %v > %v)", s.ControlSessionIdMinValue(), s.ControlSessionId, s.ControlSessionIdMaxValue()) 73 } 74 } 75 if s.CorrelationIdInActingVersion(actingVersion) { 76 if s.CorrelationId < s.CorrelationIdMinValue() || s.CorrelationId > s.CorrelationIdMaxValue() { 77 return fmt.Errorf("Range check failed on s.CorrelationId (%v < %v > %v)", s.CorrelationIdMinValue(), s.CorrelationId, s.CorrelationIdMaxValue()) 78 } 79 } 80 if s.RecordingIdInActingVersion(actingVersion) { 81 if s.RecordingId < s.RecordingIdMinValue() || s.RecordingId > s.RecordingIdMaxValue() { 82 return fmt.Errorf("Range check failed on s.RecordingId (%v < %v > %v)", s.RecordingIdMinValue(), s.RecordingId, s.RecordingIdMaxValue()) 83 } 84 } 85 return nil 86 } 87 88 func StopPositionRequestInit(s *StopPositionRequest) { 89 return 90 } 91 92 func (*StopPositionRequest) SbeBlockLength() (blockLength uint16) { 93 return 24 94 } 95 96 func (*StopPositionRequest) SbeTemplateId() (templateId uint16) { 97 return 15 98 } 99 100 func (*StopPositionRequest) SbeSchemaId() (schemaId uint16) { 101 return 101 102 } 103 104 func (*StopPositionRequest) SbeSchemaVersion() (schemaVersion uint16) { 105 return 6 106 } 107 108 func (*StopPositionRequest) SbeSemanticType() (semanticType []byte) { 109 return []byte("") 110 } 111 112 func (*StopPositionRequest) ControlSessionIdId() uint16 { 113 return 1 114 } 115 116 func (*StopPositionRequest) ControlSessionIdSinceVersion() uint16 { 117 return 0 118 } 119 120 func (s *StopPositionRequest) ControlSessionIdInActingVersion(actingVersion uint16) bool { 121 return actingVersion >= s.ControlSessionIdSinceVersion() 122 } 123 124 func (*StopPositionRequest) ControlSessionIdDeprecated() uint16 { 125 return 0 126 } 127 128 func (*StopPositionRequest) ControlSessionIdMetaAttribute(meta int) string { 129 switch meta { 130 case 1: 131 return "" 132 case 2: 133 return "" 134 case 3: 135 return "" 136 case 4: 137 return "required" 138 } 139 return "" 140 } 141 142 func (*StopPositionRequest) ControlSessionIdMinValue() int64 { 143 return math.MinInt64 + 1 144 } 145 146 func (*StopPositionRequest) ControlSessionIdMaxValue() int64 { 147 return math.MaxInt64 148 } 149 150 func (*StopPositionRequest) ControlSessionIdNullValue() int64 { 151 return math.MinInt64 152 } 153 154 func (*StopPositionRequest) CorrelationIdId() uint16 { 155 return 2 156 } 157 158 func (*StopPositionRequest) CorrelationIdSinceVersion() uint16 { 159 return 0 160 } 161 162 func (s *StopPositionRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 163 return actingVersion >= s.CorrelationIdSinceVersion() 164 } 165 166 func (*StopPositionRequest) CorrelationIdDeprecated() uint16 { 167 return 0 168 } 169 170 func (*StopPositionRequest) CorrelationIdMetaAttribute(meta int) string { 171 switch meta { 172 case 1: 173 return "" 174 case 2: 175 return "" 176 case 3: 177 return "" 178 case 4: 179 return "required" 180 } 181 return "" 182 } 183 184 func (*StopPositionRequest) CorrelationIdMinValue() int64 { 185 return math.MinInt64 + 1 186 } 187 188 func (*StopPositionRequest) CorrelationIdMaxValue() int64 { 189 return math.MaxInt64 190 } 191 192 func (*StopPositionRequest) CorrelationIdNullValue() int64 { 193 return math.MinInt64 194 } 195 196 func (*StopPositionRequest) RecordingIdId() uint16 { 197 return 3 198 } 199 200 func (*StopPositionRequest) RecordingIdSinceVersion() uint16 { 201 return 0 202 } 203 204 func (s *StopPositionRequest) RecordingIdInActingVersion(actingVersion uint16) bool { 205 return actingVersion >= s.RecordingIdSinceVersion() 206 } 207 208 func (*StopPositionRequest) RecordingIdDeprecated() uint16 { 209 return 0 210 } 211 212 func (*StopPositionRequest) RecordingIdMetaAttribute(meta int) string { 213 switch meta { 214 case 1: 215 return "" 216 case 2: 217 return "" 218 case 3: 219 return "" 220 case 4: 221 return "required" 222 } 223 return "" 224 } 225 226 func (*StopPositionRequest) RecordingIdMinValue() int64 { 227 return math.MinInt64 + 1 228 } 229 230 func (*StopPositionRequest) RecordingIdMaxValue() int64 { 231 return math.MaxInt64 232 } 233 234 func (*StopPositionRequest) RecordingIdNullValue() int64 { 235 return math.MinInt64 236 }