github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/cluster/codecs/SnapshotRecordings.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 SnapshotRecordings struct {
    13  	CorrelationId   int64
    14  	Snapshots       []SnapshotRecordingsSnapshots
    15  	MemberEndpoints []uint8
    16  }
    17  type SnapshotRecordingsSnapshots struct {
    18  	RecordingId         int64
    19  	LeadershipTermId    int64
    20  	TermBaseLogPosition int64
    21  	LogPosition         int64
    22  	Timestamp           int64
    23  	ServiceId           int32
    24  }
    25  
    26  func (s *SnapshotRecordings) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    27  	if doRangeCheck {
    28  		if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil {
    29  			return err
    30  		}
    31  	}
    32  	if err := _m.WriteInt64(_w, s.CorrelationId); err != nil {
    33  		return err
    34  	}
    35  	var SnapshotsBlockLength uint16 = 44
    36  	if err := _m.WriteUint16(_w, SnapshotsBlockLength); err != nil {
    37  		return err
    38  	}
    39  	var SnapshotsNumInGroup uint16 = uint16(len(s.Snapshots))
    40  	if err := _m.WriteUint16(_w, SnapshotsNumInGroup); err != nil {
    41  		return err
    42  	}
    43  	for _, prop := range s.Snapshots {
    44  		if err := prop.Encode(_m, _w); err != nil {
    45  			return err
    46  		}
    47  	}
    48  	if err := _m.WriteUint32(_w, uint32(len(s.MemberEndpoints))); err != nil {
    49  		return err
    50  	}
    51  	if err := _m.WriteBytes(_w, s.MemberEndpoints); err != nil {
    52  		return err
    53  	}
    54  	return nil
    55  }
    56  
    57  func (s *SnapshotRecordings) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    58  	if !s.CorrelationIdInActingVersion(actingVersion) {
    59  		s.CorrelationId = s.CorrelationIdNullValue()
    60  	} else {
    61  		if err := _m.ReadInt64(_r, &s.CorrelationId); err != nil {
    62  			return err
    63  		}
    64  	}
    65  	if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() {
    66  		io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength()))
    67  	}
    68  
    69  	if s.SnapshotsInActingVersion(actingVersion) {
    70  		var SnapshotsBlockLength uint16
    71  		if err := _m.ReadUint16(_r, &SnapshotsBlockLength); err != nil {
    72  			return err
    73  		}
    74  		var SnapshotsNumInGroup uint16
    75  		if err := _m.ReadUint16(_r, &SnapshotsNumInGroup); err != nil {
    76  			return err
    77  		}
    78  		if cap(s.Snapshots) < int(SnapshotsNumInGroup) {
    79  			s.Snapshots = make([]SnapshotRecordingsSnapshots, SnapshotsNumInGroup)
    80  		}
    81  		s.Snapshots = s.Snapshots[:SnapshotsNumInGroup]
    82  		for i := range s.Snapshots {
    83  			if err := s.Snapshots[i].Decode(_m, _r, actingVersion, uint(SnapshotsBlockLength)); err != nil {
    84  				return err
    85  			}
    86  		}
    87  	}
    88  
    89  	if s.MemberEndpointsInActingVersion(actingVersion) {
    90  		var MemberEndpointsLength uint32
    91  		if err := _m.ReadUint32(_r, &MemberEndpointsLength); err != nil {
    92  			return err
    93  		}
    94  		if cap(s.MemberEndpoints) < int(MemberEndpointsLength) {
    95  			s.MemberEndpoints = make([]uint8, MemberEndpointsLength)
    96  		}
    97  		s.MemberEndpoints = s.MemberEndpoints[:MemberEndpointsLength]
    98  		if err := _m.ReadBytes(_r, s.MemberEndpoints); err != nil {
    99  			return err
   100  		}
   101  	}
   102  	if doRangeCheck {
   103  		if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil {
   104  			return err
   105  		}
   106  	}
   107  	return nil
   108  }
   109  
   110  func (s *SnapshotRecordings) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
   111  	if s.CorrelationIdInActingVersion(actingVersion) {
   112  		if s.CorrelationId < s.CorrelationIdMinValue() || s.CorrelationId > s.CorrelationIdMaxValue() {
   113  			return fmt.Errorf("Range check failed on s.CorrelationId (%v < %v > %v)", s.CorrelationIdMinValue(), s.CorrelationId, s.CorrelationIdMaxValue())
   114  		}
   115  	}
   116  	for _, prop := range s.Snapshots {
   117  		if err := prop.RangeCheck(actingVersion, schemaVersion); err != nil {
   118  			return err
   119  		}
   120  	}
   121  	for idx, ch := range s.MemberEndpoints {
   122  		if ch > 127 {
   123  			return fmt.Errorf("s.MemberEndpoints[%d]=%d failed ASCII validation", idx, ch)
   124  		}
   125  	}
   126  	return nil
   127  }
   128  
   129  func SnapshotRecordingsInit(s *SnapshotRecordings) {
   130  	return
   131  }
   132  
   133  func (s *SnapshotRecordingsSnapshots) Encode(_m *SbeGoMarshaller, _w io.Writer) error {
   134  	if err := _m.WriteInt64(_w, s.RecordingId); err != nil {
   135  		return err
   136  	}
   137  	if err := _m.WriteInt64(_w, s.LeadershipTermId); err != nil {
   138  		return err
   139  	}
   140  	if err := _m.WriteInt64(_w, s.TermBaseLogPosition); err != nil {
   141  		return err
   142  	}
   143  	if err := _m.WriteInt64(_w, s.LogPosition); err != nil {
   144  		return err
   145  	}
   146  	if err := _m.WriteInt64(_w, s.Timestamp); err != nil {
   147  		return err
   148  	}
   149  	if err := _m.WriteInt32(_w, s.ServiceId); err != nil {
   150  		return err
   151  	}
   152  	return nil
   153  }
   154  
   155  func (s *SnapshotRecordingsSnapshots) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint) error {
   156  	if !s.RecordingIdInActingVersion(actingVersion) {
   157  		s.RecordingId = s.RecordingIdNullValue()
   158  	} else {
   159  		if err := _m.ReadInt64(_r, &s.RecordingId); err != nil {
   160  			return err
   161  		}
   162  	}
   163  	if !s.LeadershipTermIdInActingVersion(actingVersion) {
   164  		s.LeadershipTermId = s.LeadershipTermIdNullValue()
   165  	} else {
   166  		if err := _m.ReadInt64(_r, &s.LeadershipTermId); err != nil {
   167  			return err
   168  		}
   169  	}
   170  	if !s.TermBaseLogPositionInActingVersion(actingVersion) {
   171  		s.TermBaseLogPosition = s.TermBaseLogPositionNullValue()
   172  	} else {
   173  		if err := _m.ReadInt64(_r, &s.TermBaseLogPosition); err != nil {
   174  			return err
   175  		}
   176  	}
   177  	if !s.LogPositionInActingVersion(actingVersion) {
   178  		s.LogPosition = s.LogPositionNullValue()
   179  	} else {
   180  		if err := _m.ReadInt64(_r, &s.LogPosition); err != nil {
   181  			return err
   182  		}
   183  	}
   184  	if !s.TimestampInActingVersion(actingVersion) {
   185  		s.Timestamp = s.TimestampNullValue()
   186  	} else {
   187  		if err := _m.ReadInt64(_r, &s.Timestamp); err != nil {
   188  			return err
   189  		}
   190  	}
   191  	if !s.ServiceIdInActingVersion(actingVersion) {
   192  		s.ServiceId = s.ServiceIdNullValue()
   193  	} else {
   194  		if err := _m.ReadInt32(_r, &s.ServiceId); err != nil {
   195  			return err
   196  		}
   197  	}
   198  	if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() {
   199  		io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength()))
   200  	}
   201  	return nil
   202  }
   203  
   204  func (s *SnapshotRecordingsSnapshots) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
   205  	if s.RecordingIdInActingVersion(actingVersion) {
   206  		if s.RecordingId < s.RecordingIdMinValue() || s.RecordingId > s.RecordingIdMaxValue() {
   207  			return fmt.Errorf("Range check failed on s.RecordingId (%v < %v > %v)", s.RecordingIdMinValue(), s.RecordingId, s.RecordingIdMaxValue())
   208  		}
   209  	}
   210  	if s.LeadershipTermIdInActingVersion(actingVersion) {
   211  		if s.LeadershipTermId < s.LeadershipTermIdMinValue() || s.LeadershipTermId > s.LeadershipTermIdMaxValue() {
   212  			return fmt.Errorf("Range check failed on s.LeadershipTermId (%v < %v > %v)", s.LeadershipTermIdMinValue(), s.LeadershipTermId, s.LeadershipTermIdMaxValue())
   213  		}
   214  	}
   215  	if s.TermBaseLogPositionInActingVersion(actingVersion) {
   216  		if s.TermBaseLogPosition < s.TermBaseLogPositionMinValue() || s.TermBaseLogPosition > s.TermBaseLogPositionMaxValue() {
   217  			return fmt.Errorf("Range check failed on s.TermBaseLogPosition (%v < %v > %v)", s.TermBaseLogPositionMinValue(), s.TermBaseLogPosition, s.TermBaseLogPositionMaxValue())
   218  		}
   219  	}
   220  	if s.LogPositionInActingVersion(actingVersion) {
   221  		if s.LogPosition < s.LogPositionMinValue() || s.LogPosition > s.LogPositionMaxValue() {
   222  			return fmt.Errorf("Range check failed on s.LogPosition (%v < %v > %v)", s.LogPositionMinValue(), s.LogPosition, s.LogPositionMaxValue())
   223  		}
   224  	}
   225  	if s.TimestampInActingVersion(actingVersion) {
   226  		if s.Timestamp < s.TimestampMinValue() || s.Timestamp > s.TimestampMaxValue() {
   227  			return fmt.Errorf("Range check failed on s.Timestamp (%v < %v > %v)", s.TimestampMinValue(), s.Timestamp, s.TimestampMaxValue())
   228  		}
   229  	}
   230  	if s.ServiceIdInActingVersion(actingVersion) {
   231  		if s.ServiceId < s.ServiceIdMinValue() || s.ServiceId > s.ServiceIdMaxValue() {
   232  			return fmt.Errorf("Range check failed on s.ServiceId (%v < %v > %v)", s.ServiceIdMinValue(), s.ServiceId, s.ServiceIdMaxValue())
   233  		}
   234  	}
   235  	return nil
   236  }
   237  
   238  func SnapshotRecordingsSnapshotsInit(s *SnapshotRecordingsSnapshots) {
   239  	return
   240  }
   241  
   242  func (*SnapshotRecordings) SbeBlockLength() (blockLength uint16) {
   243  	return 8
   244  }
   245  
   246  func (*SnapshotRecordings) SbeTemplateId() (templateId uint16) {
   247  	return 73
   248  }
   249  
   250  func (*SnapshotRecordings) SbeSchemaId() (schemaId uint16) {
   251  	return 111
   252  }
   253  
   254  func (*SnapshotRecordings) SbeSchemaVersion() (schemaVersion uint16) {
   255  	return 8
   256  }
   257  
   258  func (*SnapshotRecordings) SbeSemanticType() (semanticType []byte) {
   259  	return []byte("")
   260  }
   261  
   262  func (*SnapshotRecordings) CorrelationIdId() uint16 {
   263  	return 1
   264  }
   265  
   266  func (*SnapshotRecordings) CorrelationIdSinceVersion() uint16 {
   267  	return 0
   268  }
   269  
   270  func (s *SnapshotRecordings) CorrelationIdInActingVersion(actingVersion uint16) bool {
   271  	return actingVersion >= s.CorrelationIdSinceVersion()
   272  }
   273  
   274  func (*SnapshotRecordings) CorrelationIdDeprecated() uint16 {
   275  	return 0
   276  }
   277  
   278  func (*SnapshotRecordings) CorrelationIdMetaAttribute(meta int) string {
   279  	switch meta {
   280  	case 1:
   281  		return ""
   282  	case 2:
   283  		return ""
   284  	case 3:
   285  		return ""
   286  	case 4:
   287  		return "required"
   288  	}
   289  	return ""
   290  }
   291  
   292  func (*SnapshotRecordings) CorrelationIdMinValue() int64 {
   293  	return math.MinInt64 + 1
   294  }
   295  
   296  func (*SnapshotRecordings) CorrelationIdMaxValue() int64 {
   297  	return math.MaxInt64
   298  }
   299  
   300  func (*SnapshotRecordings) CorrelationIdNullValue() int64 {
   301  	return math.MinInt64
   302  }
   303  
   304  func (*SnapshotRecordingsSnapshots) RecordingIdId() uint16 {
   305  	return 4
   306  }
   307  
   308  func (*SnapshotRecordingsSnapshots) RecordingIdSinceVersion() uint16 {
   309  	return 0
   310  }
   311  
   312  func (s *SnapshotRecordingsSnapshots) RecordingIdInActingVersion(actingVersion uint16) bool {
   313  	return actingVersion >= s.RecordingIdSinceVersion()
   314  }
   315  
   316  func (*SnapshotRecordingsSnapshots) RecordingIdDeprecated() uint16 {
   317  	return 0
   318  }
   319  
   320  func (*SnapshotRecordingsSnapshots) RecordingIdMetaAttribute(meta int) string {
   321  	switch meta {
   322  	case 1:
   323  		return ""
   324  	case 2:
   325  		return ""
   326  	case 3:
   327  		return ""
   328  	case 4:
   329  		return "required"
   330  	}
   331  	return ""
   332  }
   333  
   334  func (*SnapshotRecordingsSnapshots) RecordingIdMinValue() int64 {
   335  	return math.MinInt64 + 1
   336  }
   337  
   338  func (*SnapshotRecordingsSnapshots) RecordingIdMaxValue() int64 {
   339  	return math.MaxInt64
   340  }
   341  
   342  func (*SnapshotRecordingsSnapshots) RecordingIdNullValue() int64 {
   343  	return math.MinInt64
   344  }
   345  
   346  func (*SnapshotRecordingsSnapshots) LeadershipTermIdId() uint16 {
   347  	return 5
   348  }
   349  
   350  func (*SnapshotRecordingsSnapshots) LeadershipTermIdSinceVersion() uint16 {
   351  	return 0
   352  }
   353  
   354  func (s *SnapshotRecordingsSnapshots) LeadershipTermIdInActingVersion(actingVersion uint16) bool {
   355  	return actingVersion >= s.LeadershipTermIdSinceVersion()
   356  }
   357  
   358  func (*SnapshotRecordingsSnapshots) LeadershipTermIdDeprecated() uint16 {
   359  	return 0
   360  }
   361  
   362  func (*SnapshotRecordingsSnapshots) LeadershipTermIdMetaAttribute(meta int) string {
   363  	switch meta {
   364  	case 1:
   365  		return ""
   366  	case 2:
   367  		return ""
   368  	case 3:
   369  		return ""
   370  	case 4:
   371  		return "required"
   372  	}
   373  	return ""
   374  }
   375  
   376  func (*SnapshotRecordingsSnapshots) LeadershipTermIdMinValue() int64 {
   377  	return math.MinInt64 + 1
   378  }
   379  
   380  func (*SnapshotRecordingsSnapshots) LeadershipTermIdMaxValue() int64 {
   381  	return math.MaxInt64
   382  }
   383  
   384  func (*SnapshotRecordingsSnapshots) LeadershipTermIdNullValue() int64 {
   385  	return math.MinInt64
   386  }
   387  
   388  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionId() uint16 {
   389  	return 6
   390  }
   391  
   392  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionSinceVersion() uint16 {
   393  	return 0
   394  }
   395  
   396  func (s *SnapshotRecordingsSnapshots) TermBaseLogPositionInActingVersion(actingVersion uint16) bool {
   397  	return actingVersion >= s.TermBaseLogPositionSinceVersion()
   398  }
   399  
   400  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionDeprecated() uint16 {
   401  	return 0
   402  }
   403  
   404  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionMetaAttribute(meta int) string {
   405  	switch meta {
   406  	case 1:
   407  		return ""
   408  	case 2:
   409  		return ""
   410  	case 3:
   411  		return ""
   412  	case 4:
   413  		return "required"
   414  	}
   415  	return ""
   416  }
   417  
   418  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionMinValue() int64 {
   419  	return math.MinInt64 + 1
   420  }
   421  
   422  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionMaxValue() int64 {
   423  	return math.MaxInt64
   424  }
   425  
   426  func (*SnapshotRecordingsSnapshots) TermBaseLogPositionNullValue() int64 {
   427  	return math.MinInt64
   428  }
   429  
   430  func (*SnapshotRecordingsSnapshots) LogPositionId() uint16 {
   431  	return 7
   432  }
   433  
   434  func (*SnapshotRecordingsSnapshots) LogPositionSinceVersion() uint16 {
   435  	return 0
   436  }
   437  
   438  func (s *SnapshotRecordingsSnapshots) LogPositionInActingVersion(actingVersion uint16) bool {
   439  	return actingVersion >= s.LogPositionSinceVersion()
   440  }
   441  
   442  func (*SnapshotRecordingsSnapshots) LogPositionDeprecated() uint16 {
   443  	return 0
   444  }
   445  
   446  func (*SnapshotRecordingsSnapshots) LogPositionMetaAttribute(meta int) string {
   447  	switch meta {
   448  	case 1:
   449  		return ""
   450  	case 2:
   451  		return ""
   452  	case 3:
   453  		return ""
   454  	case 4:
   455  		return "required"
   456  	}
   457  	return ""
   458  }
   459  
   460  func (*SnapshotRecordingsSnapshots) LogPositionMinValue() int64 {
   461  	return math.MinInt64 + 1
   462  }
   463  
   464  func (*SnapshotRecordingsSnapshots) LogPositionMaxValue() int64 {
   465  	return math.MaxInt64
   466  }
   467  
   468  func (*SnapshotRecordingsSnapshots) LogPositionNullValue() int64 {
   469  	return math.MinInt64
   470  }
   471  
   472  func (*SnapshotRecordingsSnapshots) TimestampId() uint16 {
   473  	return 8
   474  }
   475  
   476  func (*SnapshotRecordingsSnapshots) TimestampSinceVersion() uint16 {
   477  	return 0
   478  }
   479  
   480  func (s *SnapshotRecordingsSnapshots) TimestampInActingVersion(actingVersion uint16) bool {
   481  	return actingVersion >= s.TimestampSinceVersion()
   482  }
   483  
   484  func (*SnapshotRecordingsSnapshots) TimestampDeprecated() uint16 {
   485  	return 0
   486  }
   487  
   488  func (*SnapshotRecordingsSnapshots) TimestampMetaAttribute(meta int) string {
   489  	switch meta {
   490  	case 1:
   491  		return ""
   492  	case 2:
   493  		return ""
   494  	case 3:
   495  		return ""
   496  	case 4:
   497  		return "required"
   498  	}
   499  	return ""
   500  }
   501  
   502  func (*SnapshotRecordingsSnapshots) TimestampMinValue() int64 {
   503  	return math.MinInt64 + 1
   504  }
   505  
   506  func (*SnapshotRecordingsSnapshots) TimestampMaxValue() int64 {
   507  	return math.MaxInt64
   508  }
   509  
   510  func (*SnapshotRecordingsSnapshots) TimestampNullValue() int64 {
   511  	return math.MinInt64
   512  }
   513  
   514  func (*SnapshotRecordingsSnapshots) ServiceIdId() uint16 {
   515  	return 9
   516  }
   517  
   518  func (*SnapshotRecordingsSnapshots) ServiceIdSinceVersion() uint16 {
   519  	return 0
   520  }
   521  
   522  func (s *SnapshotRecordingsSnapshots) ServiceIdInActingVersion(actingVersion uint16) bool {
   523  	return actingVersion >= s.ServiceIdSinceVersion()
   524  }
   525  
   526  func (*SnapshotRecordingsSnapshots) ServiceIdDeprecated() uint16 {
   527  	return 0
   528  }
   529  
   530  func (*SnapshotRecordingsSnapshots) ServiceIdMetaAttribute(meta int) string {
   531  	switch meta {
   532  	case 1:
   533  		return ""
   534  	case 2:
   535  		return ""
   536  	case 3:
   537  		return ""
   538  	case 4:
   539  		return "required"
   540  	}
   541  	return ""
   542  }
   543  
   544  func (*SnapshotRecordingsSnapshots) ServiceIdMinValue() int32 {
   545  	return math.MinInt32 + 1
   546  }
   547  
   548  func (*SnapshotRecordingsSnapshots) ServiceIdMaxValue() int32 {
   549  	return math.MaxInt32
   550  }
   551  
   552  func (*SnapshotRecordingsSnapshots) ServiceIdNullValue() int32 {
   553  	return math.MinInt32
   554  }
   555  
   556  func (*SnapshotRecordings) SnapshotsId() uint16 {
   557  	return 3
   558  }
   559  
   560  func (*SnapshotRecordings) SnapshotsSinceVersion() uint16 {
   561  	return 0
   562  }
   563  
   564  func (s *SnapshotRecordings) SnapshotsInActingVersion(actingVersion uint16) bool {
   565  	return actingVersion >= s.SnapshotsSinceVersion()
   566  }
   567  
   568  func (*SnapshotRecordings) SnapshotsDeprecated() uint16 {
   569  	return 0
   570  }
   571  
   572  func (*SnapshotRecordingsSnapshots) SbeBlockLength() (blockLength uint) {
   573  	return 44
   574  }
   575  
   576  func (*SnapshotRecordingsSnapshots) SbeSchemaVersion() (schemaVersion uint16) {
   577  	return 8
   578  }
   579  
   580  func (*SnapshotRecordings) MemberEndpointsMetaAttribute(meta int) string {
   581  	switch meta {
   582  	case 1:
   583  		return ""
   584  	case 2:
   585  		return ""
   586  	case 3:
   587  		return ""
   588  	case 4:
   589  		return "required"
   590  	}
   591  	return ""
   592  }
   593  
   594  func (*SnapshotRecordings) MemberEndpointsSinceVersion() uint16 {
   595  	return 0
   596  }
   597  
   598  func (s *SnapshotRecordings) MemberEndpointsInActingVersion(actingVersion uint16) bool {
   599  	return actingVersion >= s.MemberEndpointsSinceVersion()
   600  }
   601  
   602  func (*SnapshotRecordings) MemberEndpointsDeprecated() uint16 {
   603  	return 0
   604  }
   605  
   606  func (SnapshotRecordings) MemberEndpointsCharacterEncoding() string {
   607  	return "US-ASCII"
   608  }
   609  
   610  func (SnapshotRecordings) MemberEndpointsHeaderLength() uint64 {
   611  	return 4
   612  }