Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Activate(ctx context.Context) error
- func (c *Client) Attach(ctx context.Context, doc *document.Document) error
- func (c *Client) Close() error
- func (c *Client) Deactivate(ctx context.Context) error
- func (c *Client) Detach(ctx context.Context, doc *document.Document) error
- func (c *Client) Dial(rpcAddr string) error
- func (c *Client) IsActive() bool
- func (c *Client) Metadata() map[string]string
- func (c *Client) Sync(ctx context.Context, keys ...*key.Key) error
- func (c *Client) Watch(ctx context.Context, docs ...*document.Document) <-chan WatchResponse
- type Option
- type WatchResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientNotActivated occurs when an inactive client executes a function // that can only be executed when activated. ErrClientNotActivated = errors.New("client is not activated") // ErrDocumentNotAttached occurs when the given document is not attached to // this client. ErrDocumentNotAttached = errors.New("document is not attached") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a normal client that can communicate with the agent. It has documents and sends changes of the document in local to the agent to synchronize with other replicas in remote.
func (*Client) Activate ¶
Activate activates this client. That is, it register itself to the agent and receives a unique ID from the agent. The given ID is used to distinguish different clients.
func (*Client) Attach ¶
Attach attaches the given document to this client. It tells the agent that this client will synchronize the given document.
func (*Client) Deactivate ¶
Deactivate deactivates this client.
func (*Client) Detach ¶
Detach detaches the given document from this client. It tells the agent that this client will no longer synchronize the given document.
To collect garbage things like CRDT tombstones left on the document, all the changes should be applied to other replicas before GC time. For this, if the document is no longer used by this client, it should be detached.
func (*Client) Sync ¶
Sync pushes local changes of the attached documents to the Agent and receives changes of the remote replica from the agent then apply them to local documents.