sequence

package
v0.9.7-patch3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValid

func IsValid(str string) bool

IsValid Returns true if the given string is a valid ExternalSeqNo

Types

type ExternalSeqNo

type ExternalSeqNo struct {
	Time   int64 // Redis assigned time
	Seq    int64 // Redis assigned sequence
	SubSeq int   // Index of message in our eventSequence
	Last   bool  // flag to indicate if this is the las message in the subsequence
}

ExternalSeqNo is a sequence number that we pass to end users

func FromRedisId

func FromRedisId(redisId string, subSeq int, last bool) (*ExternalSeqNo, error)

FromRedisId creates an ExternalSeqNo from the redis string, subsequence and last index flag

func Parse

func Parse(str string) (*ExternalSeqNo, error)

Parse parses an external sequence number which should be of the form "Time:Seq:SubSeq:last". The empty string will be interpreted as "0:0:0" which is the initial sequence number An error will be returned if the sequence number cannot be parsed

func (*ExternalSeqNo) IsAfter

func (e *ExternalSeqNo) IsAfter(other *ExternalSeqNo) bool

IsAfter returns true if this ExternalSeqNo is after the other. ordering is by time then sequence, then subsequence. isLast is not considered.

func (*ExternalSeqNo) PrevRedisId

func (e *ExternalSeqNo) PrevRedisId() string

PrevRedisId returns the redis id that we would have to query *from* in order to guarantee that we would receive subsequent messages. Note that this is somewhat complex as if this message is not the last message In the event sequence we need to make sure we refetch the redis message referenced in this seqNo. If the message is the last sequence number then the redis id is the current message Else if the redis SubSeq is greater than zero we need to decrement the SubSeq by one Else if Time is greater than zero then we need to decrement the time by one Else we just need to return the initial sequence

func (*ExternalSeqNo) RedisString

func (e *ExternalSeqNo) RedisString() string

func (*ExternalSeqNo) String

func (e *ExternalSeqNo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL