amazon-kinesis-client-go/kcl/sequencepair.go

32 lines
539 B
Go
Raw Normal View History

2017-08-02 19:45:23 +00:00
package kcl
import (
"math/big"
)
// SequencePair a convience way to pass around a Sequence / SubSequence pair
type SequencePair struct {
Sequence *big.Int
SubSequence int
}
func (s SequencePair) IsNil() bool {
2017-08-02 19:45:23 +00:00
return s.Sequence == nil
}
func (s SequencePair) IsLessThan(pair SequencePair) bool {
if s.IsNil() || pair.IsNil() { // empty pairs are incomparable
2017-08-02 19:45:23 +00:00
return false
}
cmp := s.Sequence.Cmp(pair.Sequence)
if cmp == -1 {
return true
}
if cmp == 1 {
return false
}
return s.SubSequence < pair.SubSequence
}