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