Documentation ¶
Overview ¶
Package memory provides the memory implementation of the sync package.
Index ¶
- type BatchPublisher
- type Coordinator
- func (c *Coordinator) Close() error
- func (c *Coordinator) Members() map[string]*sync.ServerInfo
- func (c *Coordinator) NewLocker(_ context.Context, key sync.Key) (sync.Locker, error)
- func (c *Coordinator) Publish(ctx context.Context, publisherID *time.ActorID, event sync.DocEvent)
- func (c *Coordinator) Subscribe(ctx context.Context, subscriber *time.ActorID, documentRefKey types.DocRefKey) (*sync.Subscription, []*time.ActorID, error)
- func (c *Coordinator) Unsubscribe(ctx context.Context, documentRefKey types.DocRefKey, sub *sync.Subscription) error
- type PubSub
- func (m *PubSub) ClientIDs(docKey types.DocRefKey) []*time.ActorID
- func (m *PubSub) Publish(ctx context.Context, publisherID *time.ActorID, event sync.DocEvent)
- func (m *PubSub) Subscribe(ctx context.Context, subscriber *time.ActorID, docKey types.DocRefKey) (*sync.Subscription, error)
- func (m *PubSub) Unsubscribe(ctx context.Context, docKey types.DocRefKey, sub *sync.Subscription)
- type Subscriptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchPublisher ¶ added in v0.5.5
type BatchPublisher struct {
// contains filtered or unexported fields
}
BatchPublisher is a publisher that publishes events in batch.
func NewBatchPublisher ¶ added in v0.5.5
func NewBatchPublisher(subs *Subscriptions, window time.Duration) *BatchPublisher
NewBatchPublisher creates a new BatchPublisher instance.
func (*BatchPublisher) Close ¶ added in v0.5.5
func (bp *BatchPublisher) Close()
Close stops the batch publisher
func (*BatchPublisher) Publish ¶ added in v0.5.5
func (bp *BatchPublisher) Publish(event sync.DocEvent)
Publish adds the given event to the batch. If the batch is full, it publishes the batch.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator is a memory-based implementation of sync.Coordinator.
func NewCoordinator ¶
func NewCoordinator(serverInfo *sync.ServerInfo) *Coordinator
NewCoordinator creates an instance of Coordinator.
func (*Coordinator) Close ¶
func (c *Coordinator) Close() error
Close closes all resources of this Coordinator.
func (*Coordinator) Members ¶
func (c *Coordinator) Members() map[string]*sync.ServerInfo
Members returns the members of this cluster.
func (*Coordinator) Publish ¶
func (c *Coordinator) Publish( ctx context.Context, publisherID *time.ActorID, event sync.DocEvent, )
Publish publishes the given event.
func (*Coordinator) Subscribe ¶
func (c *Coordinator) Subscribe( ctx context.Context, subscriber *time.ActorID, documentRefKey types.DocRefKey, ) (*sync.Subscription, []*time.ActorID, error)
Subscribe subscribes to the given documents.
func (*Coordinator) Unsubscribe ¶
func (c *Coordinator) Unsubscribe( ctx context.Context, documentRefKey types.DocRefKey, sub *sync.Subscription, ) error
Unsubscribe unsubscribes the given documents.
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub is the memory implementation of PubSub, used for single server.
func (*PubSub) Subscribe ¶
func (m *PubSub) Subscribe( ctx context.Context, subscriber *time.ActorID, docKey types.DocRefKey, ) (*sync.Subscription, error)
Subscribe subscribes to the given document keys.
func (*PubSub) Unsubscribe ¶
func (m *PubSub) Unsubscribe( ctx context.Context, docKey types.DocRefKey, sub *sync.Subscription, )
Unsubscribe unsubscribes the given docKeys.
type Subscriptions ¶ added in v0.5.4
type Subscriptions struct {
// contains filtered or unexported fields
}
Subscriptions is a map of Subscriptions.
func (*Subscriptions) Close ¶ added in v0.5.5
func (s *Subscriptions) Close()
Close closes the subscriptions.
func (*Subscriptions) Delete ¶ added in v0.5.4
func (s *Subscriptions) Delete(id string)
Delete deletes the subscription of the given id.
func (*Subscriptions) Len ¶ added in v0.5.4
func (s *Subscriptions) Len() int
Len returns the length of these subscriptions.
func (*Subscriptions) Publish ¶ added in v0.5.4
func (s *Subscriptions) Publish(event sync.DocEvent)
Publish publishes the given event.
func (*Subscriptions) Set ¶ added in v0.5.4
func (s *Subscriptions) Set(sub *sync.Subscription)
Set adds the given subscription.
func (*Subscriptions) Values ¶ added in v0.5.4
func (s *Subscriptions) Values() []*sync.Subscription
Values returns the values of these subscriptions.