github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/KeepAliveRequest.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 KeepAliveRequest struct { 13 ControlSessionId int64 14 CorrelationId int64 15 } 16 17 func (k *KeepAliveRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 18 if doRangeCheck { 19 if err := k.RangeCheck(k.SbeSchemaVersion(), k.SbeSchemaVersion()); err != nil { 20 return err 21 } 22 } 23 if err := _m.WriteInt64(_w, k.ControlSessionId); err != nil { 24 return err 25 } 26 if err := _m.WriteInt64(_w, k.CorrelationId); err != nil { 27 return err 28 } 29 return nil 30 } 31 32 func (k *KeepAliveRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 33 if !k.ControlSessionIdInActingVersion(actingVersion) { 34 k.ControlSessionId = k.ControlSessionIdNullValue() 35 } else { 36 if err := _m.ReadInt64(_r, &k.ControlSessionId); err != nil { 37 return err 38 } 39 } 40 if !k.CorrelationIdInActingVersion(actingVersion) { 41 k.CorrelationId = k.CorrelationIdNullValue() 42 } else { 43 if err := _m.ReadInt64(_r, &k.CorrelationId); err != nil { 44 return err 45 } 46 } 47 if actingVersion > k.SbeSchemaVersion() && blockLength > k.SbeBlockLength() { 48 io.CopyN(ioutil.Discard, _r, int64(blockLength-k.SbeBlockLength())) 49 } 50 if doRangeCheck { 51 if err := k.RangeCheck(actingVersion, k.SbeSchemaVersion()); err != nil { 52 return err 53 } 54 } 55 return nil 56 } 57 58 func (k *KeepAliveRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 59 if k.ControlSessionIdInActingVersion(actingVersion) { 60 if k.ControlSessionId < k.ControlSessionIdMinValue() || k.ControlSessionId > k.ControlSessionIdMaxValue() { 61 return fmt.Errorf("Range check failed on k.ControlSessionId (%v < %v > %v)", k.ControlSessionIdMinValue(), k.ControlSessionId, k.ControlSessionIdMaxValue()) 62 } 63 } 64 if k.CorrelationIdInActingVersion(actingVersion) { 65 if k.CorrelationId < k.CorrelationIdMinValue() || k.CorrelationId > k.CorrelationIdMaxValue() { 66 return fmt.Errorf("Range check failed on k.CorrelationId (%v < %v > %v)", k.CorrelationIdMinValue(), k.CorrelationId, k.CorrelationIdMaxValue()) 67 } 68 } 69 return nil 70 } 71 72 func KeepAliveRequestInit(k *KeepAliveRequest) { 73 return 74 } 75 76 func (*KeepAliveRequest) SbeBlockLength() (blockLength uint16) { 77 return 16 78 } 79 80 func (*KeepAliveRequest) SbeTemplateId() (templateId uint16) { 81 return 61 82 } 83 84 func (*KeepAliveRequest) SbeSchemaId() (schemaId uint16) { 85 return 101 86 } 87 88 func (*KeepAliveRequest) SbeSchemaVersion() (schemaVersion uint16) { 89 return 6 90 } 91 92 func (*KeepAliveRequest) SbeSemanticType() (semanticType []byte) { 93 return []byte("") 94 } 95 96 func (*KeepAliveRequest) ControlSessionIdId() uint16 { 97 return 1 98 } 99 100 func (*KeepAliveRequest) ControlSessionIdSinceVersion() uint16 { 101 return 0 102 } 103 104 func (k *KeepAliveRequest) ControlSessionIdInActingVersion(actingVersion uint16) bool { 105 return actingVersion >= k.ControlSessionIdSinceVersion() 106 } 107 108 func (*KeepAliveRequest) ControlSessionIdDeprecated() uint16 { 109 return 0 110 } 111 112 func (*KeepAliveRequest) ControlSessionIdMetaAttribute(meta int) string { 113 switch meta { 114 case 1: 115 return "" 116 case 2: 117 return "" 118 case 3: 119 return "" 120 case 4: 121 return "required" 122 } 123 return "" 124 } 125 126 func (*KeepAliveRequest) ControlSessionIdMinValue() int64 { 127 return math.MinInt64 + 1 128 } 129 130 func (*KeepAliveRequest) ControlSessionIdMaxValue() int64 { 131 return math.MaxInt64 132 } 133 134 func (*KeepAliveRequest) ControlSessionIdNullValue() int64 { 135 return math.MinInt64 136 } 137 138 func (*KeepAliveRequest) CorrelationIdId() uint16 { 139 return 2 140 } 141 142 func (*KeepAliveRequest) CorrelationIdSinceVersion() uint16 { 143 return 0 144 } 145 146 func (k *KeepAliveRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 147 return actingVersion >= k.CorrelationIdSinceVersion() 148 } 149 150 func (*KeepAliveRequest) CorrelationIdDeprecated() uint16 { 151 return 0 152 } 153 154 func (*KeepAliveRequest) CorrelationIdMetaAttribute(meta int) string { 155 switch meta { 156 case 1: 157 return "" 158 case 2: 159 return "" 160 case 3: 161 return "" 162 case 4: 163 return "required" 164 } 165 return "" 166 } 167 168 func (*KeepAliveRequest) CorrelationIdMinValue() int64 { 169 return math.MinInt64 + 1 170 } 171 172 func (*KeepAliveRequest) CorrelationIdMaxValue() int64 { 173 return math.MaxInt64 174 } 175 176 func (*KeepAliveRequest) CorrelationIdNullValue() int64 { 177 return math.MinInt64 178 }