memory

package
v0.4.25 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package memory provides the memory implementation of the sync package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) NewLocker

func (c *Coordinator) NewLocker(
	_ context.Context,
	key sync.Key,
) (sync.Locker, error)

NewLocker creates locker of the given key.

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 NewPubSub

func NewPubSub() *PubSub

NewPubSub creates an instance of PubSub.

func (*PubSub) ClientIDs added in v0.4.5

func (m *PubSub) ClientIDs(documentRefKey types.DocRefKey) []*time.ActorID

ClientIDs returns the clients of the given document.

func (*PubSub) Publish

func (m *PubSub) Publish(
	ctx context.Context,
	publisherID *time.ActorID,
	event sync.DocEvent,
)

Publish publishes the given event.

func (*PubSub) Subscribe

func (m *PubSub) Subscribe(
	ctx context.Context,
	subscriber *time.ActorID,
	documentRefKey types.DocRefKey,
) (*sync.Subscription, error)

Subscribe subscribes to the given document keys.

func (*PubSub) Unsubscribe

func (m *PubSub) Unsubscribe(
	ctx context.Context,
	documentRefKey types.DocRefKey,
	sub *sync.Subscription,
)

Unsubscribe unsubscribes the given docKeys.

Jump to

Keyboard shortcuts

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