sequence

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sequence contains sequence box implementation.

Index

Constants

This section is empty.

Variables

View Source
var ErrGap = xerrors.Errorf("gap")

ErrGap says that there is a gap in the sequence that must be recovered manually.

Functions

This section is empty.

Types

type Box

type Box struct {
	// contains filtered or unexported fields
}

Box helps to apply updates in correct order.

func New

func New(cfg Config) *Box

New creates new sequence box.

func (*Box) DisableBuffering

func (b *Box) DisableBuffering()

DisableBuffering disables buffer mode. Should be called after the difference has been received.

Transitions:

  • buffer -> normal

func (*Box) EnableBuffering

func (b *Box) EnableBuffering()

EnableBuffering enables buffer mode. Should be called before fetching diffs.

Transitions:

  • normal -> buffer
  • fastgap -> buffer

func (*Box) ExtractBuffer

func (b *Box) ExtractBuffer() []interface{}

ExtractBuffer returns buffered updates.

func (*Box) GetState

func (b *Box) GetState() int

GetState returns current box state.

func (*Box) Handle

func (b *Box) Handle(u Update) error

Handle handles update. Transitions:

  • normal -> fastgap

func (*Box) SetState

func (b *Box) SetState(state int)

SetState manually sets new box state.

type Config

type Config struct {
	InitialState   int
	FastgapTimeout time.Duration
	Apply          func(state int, updates []interface{}) error
	Logger         *zap.Logger
	// contains filtered or unexported fields
}

Config is the sequence box config.

type ResultError

type ResultError struct {
	Err error
}

ResultError allows apply-functions to pass errors through the box without affecting it.

func (*ResultError) Error

func (e *ResultError) Error() string

func (*ResultError) Unwrap

func (e *ResultError) Unwrap() error

Unwrap implements error unwrap interface.

type Update

type Update struct {
	// Pts, PtsCount
	// Qts, 1
	// Seq, (Seq-SeqStart+1)
	State, Count int
	Value        interface{}
}

Update struct.

Jump to

Keyboard shortcuts

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