github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/ClusterActionRequest.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 ClusterActionRequest struct {
    13  	LeadershipTermId int64
    14  	LogPosition      int64
    15  	Timestamp        int64
    16  	Action           ClusterActionEnum
    17  }
    18  
    19  func (c *ClusterActionRequest) 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.LeadershipTermId); 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.Timestamp); err != nil {
    32  		return err
    33  	}
    34  	if err := c.Action.Encode(_m, _w); err != nil {
    35  		return err
    36  	}
    37  	return nil
    38  }
    39  
    40  func (c *ClusterActionRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    41  	if !c.LeadershipTermIdInActingVersion(actingVersion) {
    42  		c.LeadershipTermId = c.LeadershipTermIdNullValue()
    43  	} else {
    44  		if err := _m.ReadInt64(_r, &c.LeadershipTermId); 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.TimestampInActingVersion(actingVersion) {
    56  		c.Timestamp = c.TimestampNullValue()
    57  	} else {
    58  		if err := _m.ReadInt64(_r, &c.Timestamp); err != nil {
    59  			return err
    60  		}
    61  	}
    62  	if c.ActionInActingVersion(actingVersion) {
    63  		if err := c.Action.Decode(_m, _r, actingVersion); err != nil {
    64  			return err
    65  		}
    66  	}
    67  	if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() {
    68  		io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength()))
    69  	}
    70  	if doRangeCheck {
    71  		if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil {
    72  			return err
    73  		}
    74  	}
    75  	return nil
    76  }
    77  
    78  func (c *ClusterActionRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
    79  	if c.LeadershipTermIdInActingVersion(actingVersion) {
    80  		if c.LeadershipTermId < c.LeadershipTermIdMinValue() || c.LeadershipTermId > c.LeadershipTermIdMaxValue() {
    81  			return fmt.Errorf("Range check failed on c.LeadershipTermId (%v < %v > %v)", c.LeadershipTermIdMinValue(), c.LeadershipTermId, c.LeadershipTermIdMaxValue())
    82  		}
    83  	}
    84  	if c.LogPositionInActingVersion(actingVersion) {
    85  		if c.LogPosition < c.LogPositionMinValue() || c.LogPosition > c.LogPositionMaxValue() {
    86  			return fmt.Errorf("Range check failed on c.LogPosition (%v < %v > %v)", c.LogPositionMinValue(), c.LogPosition, c.LogPositionMaxValue())
    87  		}
    88  	}
    89  	if c.TimestampInActingVersion(actingVersion) {
    90  		if c.Timestamp < c.TimestampMinValue() || c.Timestamp > c.TimestampMaxValue() {
    91  			return fmt.Errorf("Range check failed on c.Timestamp (%v < %v > %v)", c.TimestampMinValue(), c.Timestamp, c.TimestampMaxValue())
    92  		}
    93  	}
    94  	if err := c.Action.RangeCheck(actingVersion, schemaVersion); err != nil {
    95  		return err
    96  	}
    97  	return nil
    98  }
    99  
   100  func ClusterActionRequestInit(c *ClusterActionRequest) {
   101  	return
   102  }
   103  
   104  func (*ClusterActionRequest) SbeBlockLength() (blockLength uint16) {
   105  	return 28
   106  }
   107  
   108  func (*ClusterActionRequest) SbeTemplateId() (templateId uint16) {
   109  	return 23
   110  }
   111  
   112  func (*ClusterActionRequest) SbeSchemaId() (schemaId uint16) {
   113  	return 111
   114  }
   115  
   116  func (*ClusterActionRequest) SbeSchemaVersion() (schemaVersion uint16) {
   117  	return 8
   118  }
   119  
   120  func (*ClusterActionRequest) SbeSemanticType() (semanticType []byte) {
   121  	return []byte("")
   122  }
   123  
   124  func (*ClusterActionRequest) LeadershipTermIdId() uint16 {
   125  	return 1
   126  }
   127  
   128  func (*ClusterActionRequest) LeadershipTermIdSinceVersion() uint16 {
   129  	return 0
   130  }
   131  
   132  func (c *ClusterActionRequest) LeadershipTermIdInActingVersion(actingVersion uint16) bool {
   133  	return actingVersion >= c.LeadershipTermIdSinceVersion()
   134  }
   135  
   136  func (*ClusterActionRequest) LeadershipTermIdDeprecated() uint16 {
   137  	return 0
   138  }
   139  
   140  func (*ClusterActionRequest) 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 (*ClusterActionRequest) LeadershipTermIdMinValue() int64 {
   155  	return math.MinInt64 + 1
   156  }
   157  
   158  func (*ClusterActionRequest) LeadershipTermIdMaxValue() int64 {
   159  	return math.MaxInt64
   160  }
   161  
   162  func (*ClusterActionRequest) LeadershipTermIdNullValue() int64 {
   163  	return math.MinInt64
   164  }
   165  
   166  func (*ClusterActionRequest) LogPositionId() uint16 {
   167  	return 2
   168  }
   169  
   170  func (*ClusterActionRequest) LogPositionSinceVersion() uint16 {
   171  	return 0
   172  }
   173  
   174  func (c *ClusterActionRequest) LogPositionInActingVersion(actingVersion uint16) bool {
   175  	return actingVersion >= c.LogPositionSinceVersion()
   176  }
   177  
   178  func (*ClusterActionRequest) LogPositionDeprecated() uint16 {
   179  	return 0
   180  }
   181  
   182  func (*ClusterActionRequest) LogPositionMetaAttribute(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 (*ClusterActionRequest) LogPositionMinValue() int64 {
   197  	return math.MinInt64 + 1
   198  }
   199  
   200  func (*ClusterActionRequest) LogPositionMaxValue() int64 {
   201  	return math.MaxInt64
   202  }
   203  
   204  func (*ClusterActionRequest) LogPositionNullValue() int64 {
   205  	return math.MinInt64
   206  }
   207  
   208  func (*ClusterActionRequest) TimestampId() uint16 {
   209  	return 3
   210  }
   211  
   212  func (*ClusterActionRequest) TimestampSinceVersion() uint16 {
   213  	return 0
   214  }
   215  
   216  func (c *ClusterActionRequest) TimestampInActingVersion(actingVersion uint16) bool {
   217  	return actingVersion >= c.TimestampSinceVersion()
   218  }
   219  
   220  func (*ClusterActionRequest) TimestampDeprecated() uint16 {
   221  	return 0
   222  }
   223  
   224  func (*ClusterActionRequest) 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 (*ClusterActionRequest) TimestampMinValue() int64 {
   239  	return math.MinInt64 + 1
   240  }
   241  
   242  func (*ClusterActionRequest) TimestampMaxValue() int64 {
   243  	return math.MaxInt64
   244  }
   245  
   246  func (*ClusterActionRequest) TimestampNullValue() int64 {
   247  	return math.MinInt64
   248  }
   249  
   250  func (*ClusterActionRequest) ActionId() uint16 {
   251  	return 4
   252  }
   253  
   254  func (*ClusterActionRequest) ActionSinceVersion() uint16 {
   255  	return 0
   256  }
   257  
   258  func (c *ClusterActionRequest) ActionInActingVersion(actingVersion uint16) bool {
   259  	return actingVersion >= c.ActionSinceVersion()
   260  }
   261  
   262  func (*ClusterActionRequest) ActionDeprecated() uint16 {
   263  	return 0
   264  }
   265  
   266  func (*ClusterActionRequest) ActionMetaAttribute(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  }