Documentation ¶
Index ¶
- func NonBlocking(s ops.Store) ops.Store
- func Reliable(s ops.Store, opts ...Option) ops.Store
- func Stream(store ops.Store, opts ...Option) streams.Stream
- type Config
- type Option
- func WithAutoTransform(cache ops.Cache) Option
- func WithBackoff(rng func() float64, initial, max time.Duration) Option
- func WithLog(l log.Log) Option
- func WithNonBlocking(nonBlock bool) Option
- func WithNotify(fn func(version int, pending, mergeChain []ops.Op)) Option
- func WithSession(version int, pending, mergeChain []ops.Op) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NonBlocking ¶
NonBlocking converts a regular store into a non-blocking store
This modifies the GetSince call to return immediately and fetch results asynchronously.
func Reliable ¶
Reliable is used by Stream() to work with a reliable store.
Reliable takes a store that can fail and converts it to a reliable store. All Append() calls return success immediately with background attempts to deliver/retry.
GetSince is modified to retry up to the specified timeout.
Note: the only options that affects Reliable() are WithBackoff() and WithLog()
func Stream ¶
Stream converts an ops Store into a stream.
Calling Append() on the Stream is asynchronously appended to the Store and remote changes are also automatically merged into the returned stream.
Sync works with a Transformed store. A raw store can be auto transformed via the WithAutoTransform option.
Additional sync options can be used to configure the behavior.
The returned close function can be used to shutdown the synchronization but the underlying store still needs to be separately released.
Types ¶
type Config ¶
type Config struct { // A reliable ops store. ops.Store // AutoTransform is off by default but can be set to true to // automatically transform the provided store AutoTransform bool // NonBlocking is inititally off but can be set to true to // make GetSince non-blocking NonBlocking bool ops.Cache // Session state Version int Pending []ops.Op MergeChain []ops.Op // logger log.Log // Session state notifier Notify func(version int, pending, mergeChain []ops.Op) // Backoff configures the exponential backoff settings Backoff struct { Rand func() float64 Initial, Max time.Duration } }
Config defines the configuration options for synchronization
type Option ¶
type Option func(c *Config)
Option can be used to configure Sync behavior
See WithSession and WithCloseNotify
func WithAutoTransform ¶
WithAutoTransform specifies that the initial store yields untransformed operations and must be automatically transformed.
The cache is required
func WithBackoff ¶
WithBackoff configures the binary-exponential backoff settings
func WithNonBlocking ¶
WithNonBlocking sets the non-blocking flag to true.
This makes Pull() return synchronously with any remote fetches in the background.
func WithNotify ¶
WithNotify configures a callback to be called when the session state changes. In particular, this is called when the session is closed.