github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/StartRecordingRequest.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 StartRecordingRequest struct {
    13  	ControlSessionId int64
    14  	CorrelationId    int64
    15  	StreamId         int32
    16  	SourceLocation   SourceLocationEnum
    17  	Channel          []uint8
    18  }
    19  
    20  func (s *StartRecordingRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    21  	if doRangeCheck {
    22  		if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil {
    23  			return err
    24  		}
    25  	}
    26  	if err := _m.WriteInt64(_w, s.ControlSessionId); err != nil {
    27  		return err
    28  	}
    29  	if err := _m.WriteInt64(_w, s.CorrelationId); err != nil {
    30  		return err
    31  	}
    32  	if err := _m.WriteInt32(_w, s.StreamId); err != nil {
    33  		return err
    34  	}
    35  	if err := s.SourceLocation.Encode(_m, _w); err != nil {
    36  		return err
    37  	}
    38  	if err := _m.WriteUint32(_w, uint32(len(s.Channel))); err != nil {
    39  		return err
    40  	}
    41  	if err := _m.WriteBytes(_w, s.Channel); err != nil {
    42  		return err
    43  	}
    44  	return nil
    45  }
    46  
    47  func (s *StartRecordingRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    48  	if !s.ControlSessionIdInActingVersion(actingVersion) {
    49  		s.ControlSessionId = s.ControlSessionIdNullValue()
    50  	} else {
    51  		if err := _m.ReadInt64(_r, &s.ControlSessionId); err != nil {
    52  			return err
    53  		}
    54  	}
    55  	if !s.CorrelationIdInActingVersion(actingVersion) {
    56  		s.CorrelationId = s.CorrelationIdNullValue()
    57  	} else {
    58  		if err := _m.ReadInt64(_r, &s.CorrelationId); err != nil {
    59  			return err
    60  		}
    61  	}
    62  	if !s.StreamIdInActingVersion(actingVersion) {
    63  		s.StreamId = s.StreamIdNullValue()
    64  	} else {
    65  		if err := _m.ReadInt32(_r, &s.StreamId); err != nil {
    66  			return err
    67  		}
    68  	}
    69  	if s.SourceLocationInActingVersion(actingVersion) {
    70  		if err := s.SourceLocation.Decode(_m, _r, actingVersion); err != nil {
    71  			return err
    72  		}
    73  	}
    74  	if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() {
    75  		io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength()))
    76  	}
    77  
    78  	if s.ChannelInActingVersion(actingVersion) {
    79  		var ChannelLength uint32
    80  		if err := _m.ReadUint32(_r, &ChannelLength); err != nil {
    81  			return err
    82  		}
    83  		if cap(s.Channel) < int(ChannelLength) {
    84  			s.Channel = make([]uint8, ChannelLength)
    85  		}
    86  		s.Channel = s.Channel[:ChannelLength]
    87  		if err := _m.ReadBytes(_r, s.Channel); err != nil {
    88  			return err
    89  		}
    90  	}
    91  	if doRangeCheck {
    92  		if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil {
    93  			return err
    94  		}
    95  	}
    96  	return nil
    97  }
    98  
    99  func (s *StartRecordingRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
   100  	if s.ControlSessionIdInActingVersion(actingVersion) {
   101  		if s.ControlSessionId < s.ControlSessionIdMinValue() || s.ControlSessionId > s.ControlSessionIdMaxValue() {
   102  			return fmt.Errorf("Range check failed on s.ControlSessionId (%v < %v > %v)", s.ControlSessionIdMinValue(), s.ControlSessionId, s.ControlSessionIdMaxValue())
   103  		}
   104  	}
   105  	if s.CorrelationIdInActingVersion(actingVersion) {
   106  		if s.CorrelationId < s.CorrelationIdMinValue() || s.CorrelationId > s.CorrelationIdMaxValue() {
   107  			return fmt.Errorf("Range check failed on s.CorrelationId (%v < %v > %v)", s.CorrelationIdMinValue(), s.CorrelationId, s.CorrelationIdMaxValue())
   108  		}
   109  	}
   110  	if s.StreamIdInActingVersion(actingVersion) {
   111  		if s.StreamId < s.StreamIdMinValue() || s.StreamId > s.StreamIdMaxValue() {
   112  			return fmt.Errorf("Range check failed on s.StreamId (%v < %v > %v)", s.StreamIdMinValue(), s.StreamId, s.StreamIdMaxValue())
   113  		}
   114  	}
   115  	if err := s.SourceLocation.RangeCheck(actingVersion, schemaVersion); err != nil {
   116  		return err
   117  	}
   118  	return nil
   119  }
   120  
   121  func StartRecordingRequestInit(s *StartRecordingRequest) {
   122  	return
   123  }
   124  
   125  func (*StartRecordingRequest) SbeBlockLength() (blockLength uint16) {
   126  	return 24
   127  }
   128  
   129  func (*StartRecordingRequest) SbeTemplateId() (templateId uint16) {
   130  	return 4
   131  }
   132  
   133  func (*StartRecordingRequest) SbeSchemaId() (schemaId uint16) {
   134  	return 101
   135  }
   136  
   137  func (*StartRecordingRequest) SbeSchemaVersion() (schemaVersion uint16) {
   138  	return 6
   139  }
   140  
   141  func (*StartRecordingRequest) SbeSemanticType() (semanticType []byte) {
   142  	return []byte("")
   143  }
   144  
   145  func (*StartRecordingRequest) ControlSessionIdId() uint16 {
   146  	return 1
   147  }
   148  
   149  func (*StartRecordingRequest) ControlSessionIdSinceVersion() uint16 {
   150  	return 0
   151  }
   152  
   153  func (s *StartRecordingRequest) ControlSessionIdInActingVersion(actingVersion uint16) bool {
   154  	return actingVersion >= s.ControlSessionIdSinceVersion()
   155  }
   156  
   157  func (*StartRecordingRequest) ControlSessionIdDeprecated() uint16 {
   158  	return 0
   159  }
   160  
   161  func (*StartRecordingRequest) ControlSessionIdMetaAttribute(meta int) string {
   162  	switch meta {
   163  	case 1:
   164  		return ""
   165  	case 2:
   166  		return ""
   167  	case 3:
   168  		return ""
   169  	case 4:
   170  		return "required"
   171  	}
   172  	return ""
   173  }
   174  
   175  func (*StartRecordingRequest) ControlSessionIdMinValue() int64 {
   176  	return math.MinInt64 + 1
   177  }
   178  
   179  func (*StartRecordingRequest) ControlSessionIdMaxValue() int64 {
   180  	return math.MaxInt64
   181  }
   182  
   183  func (*StartRecordingRequest) ControlSessionIdNullValue() int64 {
   184  	return math.MinInt64
   185  }
   186  
   187  func (*StartRecordingRequest) CorrelationIdId() uint16 {
   188  	return 2
   189  }
   190  
   191  func (*StartRecordingRequest) CorrelationIdSinceVersion() uint16 {
   192  	return 0
   193  }
   194  
   195  func (s *StartRecordingRequest) CorrelationIdInActingVersion(actingVersion uint16) bool {
   196  	return actingVersion >= s.CorrelationIdSinceVersion()
   197  }
   198  
   199  func (*StartRecordingRequest) CorrelationIdDeprecated() uint16 {
   200  	return 0
   201  }
   202  
   203  func (*StartRecordingRequest) CorrelationIdMetaAttribute(meta int) string {
   204  	switch meta {
   205  	case 1:
   206  		return ""
   207  	case 2:
   208  		return ""
   209  	case 3:
   210  		return ""
   211  	case 4:
   212  		return "required"
   213  	}
   214  	return ""
   215  }
   216  
   217  func (*StartRecordingRequest) CorrelationIdMinValue() int64 {
   218  	return math.MinInt64 + 1
   219  }
   220  
   221  func (*StartRecordingRequest) CorrelationIdMaxValue() int64 {
   222  	return math.MaxInt64
   223  }
   224  
   225  func (*StartRecordingRequest) CorrelationIdNullValue() int64 {
   226  	return math.MinInt64
   227  }
   228  
   229  func (*StartRecordingRequest) StreamIdId() uint16 {
   230  	return 3
   231  }
   232  
   233  func (*StartRecordingRequest) StreamIdSinceVersion() uint16 {
   234  	return 0
   235  }
   236  
   237  func (s *StartRecordingRequest) StreamIdInActingVersion(actingVersion uint16) bool {
   238  	return actingVersion >= s.StreamIdSinceVersion()
   239  }
   240  
   241  func (*StartRecordingRequest) StreamIdDeprecated() uint16 {
   242  	return 0
   243  }
   244  
   245  func (*StartRecordingRequest) StreamIdMetaAttribute(meta int) string {
   246  	switch meta {
   247  	case 1:
   248  		return ""
   249  	case 2:
   250  		return ""
   251  	case 3:
   252  		return ""
   253  	case 4:
   254  		return "required"
   255  	}
   256  	return ""
   257  }
   258  
   259  func (*StartRecordingRequest) StreamIdMinValue() int32 {
   260  	return math.MinInt32 + 1
   261  }
   262  
   263  func (*StartRecordingRequest) StreamIdMaxValue() int32 {
   264  	return math.MaxInt32
   265  }
   266  
   267  func (*StartRecordingRequest) StreamIdNullValue() int32 {
   268  	return math.MinInt32
   269  }
   270  
   271  func (*StartRecordingRequest) SourceLocationId() uint16 {
   272  	return 4
   273  }
   274  
   275  func (*StartRecordingRequest) SourceLocationSinceVersion() uint16 {
   276  	return 0
   277  }
   278  
   279  func (s *StartRecordingRequest) SourceLocationInActingVersion(actingVersion uint16) bool {
   280  	return actingVersion >= s.SourceLocationSinceVersion()
   281  }
   282  
   283  func (*StartRecordingRequest) SourceLocationDeprecated() uint16 {
   284  	return 0
   285  }
   286  
   287  func (*StartRecordingRequest) SourceLocationMetaAttribute(meta int) string {
   288  	switch meta {
   289  	case 1:
   290  		return ""
   291  	case 2:
   292  		return ""
   293  	case 3:
   294  		return ""
   295  	case 4:
   296  		return "required"
   297  	}
   298  	return ""
   299  }
   300  
   301  func (*StartRecordingRequest) ChannelMetaAttribute(meta int) string {
   302  	switch meta {
   303  	case 1:
   304  		return ""
   305  	case 2:
   306  		return ""
   307  	case 3:
   308  		return ""
   309  	case 4:
   310  		return "required"
   311  	}
   312  	return ""
   313  }
   314  
   315  func (*StartRecordingRequest) ChannelSinceVersion() uint16 {
   316  	return 0
   317  }
   318  
   319  func (s *StartRecordingRequest) ChannelInActingVersion(actingVersion uint16) bool {
   320  	return actingVersion >= s.ChannelSinceVersion()
   321  }
   322  
   323  func (*StartRecordingRequest) ChannelDeprecated() uint16 {
   324  	return 0
   325  }
   326  
   327  func (StartRecordingRequest) ChannelCharacterEncoding() string {
   328  	return "US-ASCII"
   329  }
   330  
   331  func (StartRecordingRequest) ChannelHeaderLength() uint64 {
   332  	return 4
   333  }