Documentation ¶
Index ¶
- type Intervals
- func (i *Intervals) Add(start, end uint64)
- func (i *Intervals) Last() (end uint64)
- func (i *Intervals) MarshalBinary() (data []byte, err error)
- func (i *Intervals) Merge(m *Intervals)
- func (i *Intervals) Next() (start, end uint64)
- func (i *Intervals) String() string
- func (i *Intervals) UnmarshalBinary(data []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intervals ¶
type Intervals struct {
// contains filtered or unexported fields
}
Intervals store a list of intervals. Its purpose is to provide methods to add new intervals and retrieve missing intervals that need to be added. It may be used in synchronization of streaming data to persist retrieved data ranges between sessions.
func NewIntervals ¶
New creates a new instance of Intervals. Start argument limits the lower bound of intervals. No range bellow start bound will be added by Add method or returned by Next method. This limit may be used for tracking "live" synchronization, where the sync session starts from a specific value, and if "live" sync intervals need to be merged with historical ones, it can be safely done.
func (*Intervals) Add ¶
Add adds a new range to intervals. Range start and end are values are both inclusive.
func (*Intervals) MarshalBinary ¶
MarshalBinary encodes Intervals parameters into a semicolon separated list. The first element in the list is base36-encoded start value. The following elements are two base36-encoded value ranges separated by comma.
func (*Intervals) Next ¶
Next returns the first range interval that is not fulfilled. Returned start and end values are both inclusive, meaning that the whole range including start and end need to be added in order to full the gap in intervals. Returned value for end is 0 if the next interval is after the whole range that is stored in Intervals. Zero end value represents no limit on the next interval length.
func (*Intervals) String ¶
String returns a descriptive representation of range intervals in [] notation, as a list of two element vectors.
func (*Intervals) UnmarshalBinary ¶
UnmarshalBinary decodes data according to the Intervals.MarshalBinary format.