github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/CloseSession.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 CloseSession struct { 13 ClusterSessionId int64 14 } 15 16 func (c *CloseSession) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 17 if doRangeCheck { 18 if err := c.RangeCheck(c.SbeSchemaVersion(), c.SbeSchemaVersion()); err != nil { 19 return err 20 } 21 } 22 if err := _m.WriteInt64(_w, c.ClusterSessionId); err != nil { 23 return err 24 } 25 return nil 26 } 27 28 func (c *CloseSession) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 29 if !c.ClusterSessionIdInActingVersion(actingVersion) { 30 c.ClusterSessionId = c.ClusterSessionIdNullValue() 31 } else { 32 if err := _m.ReadInt64(_r, &c.ClusterSessionId); err != nil { 33 return err 34 } 35 } 36 if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() { 37 io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength())) 38 } 39 if doRangeCheck { 40 if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil { 41 return err 42 } 43 } 44 return nil 45 } 46 47 func (c *CloseSession) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 48 if c.ClusterSessionIdInActingVersion(actingVersion) { 49 if c.ClusterSessionId < c.ClusterSessionIdMinValue() || c.ClusterSessionId > c.ClusterSessionIdMaxValue() { 50 return fmt.Errorf("Range check failed on c.ClusterSessionId (%v < %v > %v)", c.ClusterSessionIdMinValue(), c.ClusterSessionId, c.ClusterSessionIdMaxValue()) 51 } 52 } 53 return nil 54 } 55 56 func CloseSessionInit(c *CloseSession) { 57 return 58 } 59 60 func (*CloseSession) SbeBlockLength() (blockLength uint16) { 61 return 8 62 } 63 64 func (*CloseSession) SbeTemplateId() (templateId uint16) { 65 return 30 66 } 67 68 func (*CloseSession) SbeSchemaId() (schemaId uint16) { 69 return 111 70 } 71 72 func (*CloseSession) SbeSchemaVersion() (schemaVersion uint16) { 73 return 8 74 } 75 76 func (*CloseSession) SbeSemanticType() (semanticType []byte) { 77 return []byte("") 78 } 79 80 func (*CloseSession) ClusterSessionIdId() uint16 { 81 return 1 82 } 83 84 func (*CloseSession) ClusterSessionIdSinceVersion() uint16 { 85 return 0 86 } 87 88 func (c *CloseSession) ClusterSessionIdInActingVersion(actingVersion uint16) bool { 89 return actingVersion >= c.ClusterSessionIdSinceVersion() 90 } 91 92 func (*CloseSession) ClusterSessionIdDeprecated() uint16 { 93 return 0 94 } 95 96 func (*CloseSession) ClusterSessionIdMetaAttribute(meta int) string { 97 switch meta { 98 case 1: 99 return "" 100 case 2: 101 return "" 102 case 3: 103 return "" 104 case 4: 105 return "required" 106 } 107 return "" 108 } 109 110 func (*CloseSession) ClusterSessionIdMinValue() int64 { 111 return math.MinInt64 + 1 112 } 113 114 func (*CloseSession) ClusterSessionIdMaxValue() int64 { 115 return math.MaxInt64 116 } 117 118 func (*CloseSession) ClusterSessionIdNullValue() int64 { 119 return math.MinInt64 120 }