Documentation ¶
Index ¶
- Constants
- Variables
- type Counter
- type DataStructure
- type DataType
- type LogFunc
- type Options
- type Set
- type TypeManager
- func (tm *TypeManager) Contains() map[string]DataStructure
- func (tm *TypeManager) GetCounter(name string) (*Counter, error)
- func (tm *TypeManager) GetSet(name string) (*Set, error)
- func (tm *TypeManager) Init(ctx context.Context) error
- func (tm *TypeManager) NewCounter(name string) *Counter
- func (tm *TypeManager) NewSet(name string) *Set
- func (tm *TypeManager) Stop()
Constants ¶
const ( DefaultSnapshotInterval = 10 * time.Minute DefaultOutputQueueSize = 100 // number of outgoing log messages to queue before sending blocks )
Options defaults
Variables ¶
var ErrInitAborted = errors.New("init was aborted")
ErrInitAborted is returned when Init is aborted via context
var ErrNoSuchCounter = errors.New("no such counter found")
ErrNoSuchCounter is returned when a named counter doesn't exist
var ErrNoSuchSet = errors.New("no such set found")
ErrNoSuchSet is returned when a named set doesn't exist
var ErrSendWouldHaveBlocked = errors.New("write to output channel would have blocked")
ErrSendWouldHaveBlocked is an error indicating that the output queue was full
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct { Name string // contains filtered or unexported fields }
Counter implements a PN Counter CRDT
type DataStructure ¶
DataStructure contains information about an extant data stucture
type LogFunc ¶
type LogFunc func(string, ...interface{})
LogFunc is a function that logs a formatted string somewhere
type Options ¶
type Options struct { Brokers []string Topic string OutputQueueSize uint SnapshotInterval time.Duration LogFunction LogFunc FailOnBlockingSend bool // If output queue is full, fail instead of blocking on send }
Options is the configuration for a TypeManager
type Set ¶
type Set struct { Name string // contains filtered or unexported fields }
Set implements a LWW set (removal-biased)
type TypeManager ¶
type TypeManager struct {
// contains filtered or unexported fields
}
TypeManager is an object that manages CRDT types
func NewTypeManager ¶
func NewTypeManager(ops Options) (*TypeManager, error)
NewTypeManager returns a TypeManager using the options provided
func (*TypeManager) Contains ¶
func (tm *TypeManager) Contains() map[string]DataStructure
Contains returns all known data structures as a map of name to DataStructure
func (*TypeManager) GetCounter ¶
func (tm *TypeManager) GetCounter(name string) (*Counter, error)
GetCounter returns a counter that already exists in the log
func (*TypeManager) GetSet ¶
func (tm *TypeManager) GetSet(name string) (*Set, error)
GetSet returns a set that already exists in the log
func (*TypeManager) Init ¶
func (tm *TypeManager) Init(ctx context.Context) error
Init synchronously reads through the event logs and populates TypeManager with any existing data structures and values. If the event log is sizeable, this could block for a substantial period of time.
func (*TypeManager) NewCounter ¶
func (tm *TypeManager) NewCounter(name string) *Counter
NewCounter creates and returns a new Counter if it doesn't exist, or the existing counter with that name.
func (*TypeManager) NewSet ¶
func (tm *TypeManager) NewSet(name string) *Set
NewSet creates and returns a new Set if it doesn't exist, or the existing set with that name.