Documentation ¶
Overview ¶
This package implements the DEJE Next protocol. For more information, read the docs below, or README.md.
This software is currently in a round of refactoring, and as such, the API is *very* subject to change. You can expect it to become simpler in the next few weeks, such that it's fairly easy to create a new document or sync an existing one from the network, and pass all changes on to a UI.
Index ¶
- func GetRouterAndTopic(deje_url string) (router, topic string, err error)
- type Client
- type OnConnectCallback
- type OnEventCallback
- type OnReTipCallback
- type SimpleClient
- func (sc *SimpleClient) Connect(url string) error
- func (sc *SimpleClient) Export() interface{}
- func (sc *SimpleClient) GetDoc() *document.Document
- func (sc *SimpleClient) GetTopic() string
- func (sc *SimpleClient) Log(args ...interface{})
- func (sc *SimpleClient) Promote(ev document.Event) error
- func (sc *SimpleClient) Publish(data interface{}) error
- func (sc *SimpleClient) PublishEvents() error
- func (sc *SimpleClient) PublishTimestamps() error
- func (sc *SimpleClient) ReTip()
- func (sc *SimpleClient) RequestEvents() error
- func (sc *SimpleClient) RequestTimestamps() error
- func (sc *SimpleClient) SetPrimitiveCallback(c state.OnPrimitiveCallback)
- func (sc *SimpleClient) SetRetipCallback(c OnReTipCallback)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRouterAndTopic ¶
Given a deje:// URL, return router URL and DEJE topic.
Types ¶
type Client ¶
type Client struct { Doc *document.Document Topic string // contains filtered or unexported fields }
Contains a document and a WAMP connection.
func (*Client) Connect ¶
Connect to a WAMP router. This also calls the 'connect' callback on success.
func (*Client) SetConnectCallback ¶
func (c *Client) SetConnectCallback(callback OnConnectCallback)
Set callback to be executed when a successful connection has been made to a WAMP router.
func (*Client) SetEventCallback ¶
func (c *Client) SetEventCallback(callback OnEventCallback)
Set callback to be executed when a published event is received.
type OnConnectCallback ¶
type OnConnectCallback func(sessionId string)
When a session connects, this callback is provided with the session ID value. sessionId is just a server-chosen string.
type OnEventCallback ¶
type OnEventCallback func(event interface{})
Called when another peer in the same WAMP topic publishes a JSON-compatible event to all subscribers.
type OnReTipCallback ¶
An optional callback to be called whenever we reanalyze which event is tip.
type SimpleClient ¶
Wraps the low-level capabilities of the basic Client to provide an easier, more useful API to downstream code.
func NewSimpleClient ¶
func NewSimpleClient(topic string, logger *log.Logger) *SimpleClient
Unless you want to manually specify router URL and topic separately, you should probably use Open() instead of NewSimpleClient().
func Open ¶
func Open(deje_url string, logger *log.Logger, cb state.OnPrimitiveCallback) (*SimpleClient, error)
The preferred way to create SimpleClients. Handles the Connect() call, and uses GetRouterAndTopic() to turn a single deje://... URL into a router URL and topic.
func (*SimpleClient) Connect ¶
func (sc *SimpleClient) Connect(url string) error
Connect and immediately request timestamps.
func (*SimpleClient) Export ¶
func (sc *SimpleClient) Export() interface{}
Return the current contents of the document.
func (*SimpleClient) GetDoc ¶
func (sc *SimpleClient) GetDoc() *document.Document
Get the Document object owned by this Client.
func (*SimpleClient) GetTopic ¶
func (sc *SimpleClient) GetTopic() string
Get the Topic of the underlying Client.
func (*SimpleClient) Log ¶
func (sc *SimpleClient) Log(args ...interface{})
func (*SimpleClient) Promote ¶
func (sc *SimpleClient) Promote(ev document.Event) error
Navigate the Document to an Event, and promote it as the tip.
func (*SimpleClient) Publish ¶
func (sc *SimpleClient) Publish(data interface{}) error
func (*SimpleClient) PublishEvents ¶
func (sc *SimpleClient) PublishEvents() error
func (*SimpleClient) PublishTimestamps ¶
func (sc *SimpleClient) PublishTimestamps() error
func (*SimpleClient) ReTip ¶
func (sc *SimpleClient) ReTip()
func (*SimpleClient) RequestEvents ¶
func (sc *SimpleClient) RequestEvents() error
func (*SimpleClient) RequestTimestamps ¶
func (sc *SimpleClient) RequestTimestamps() error
func (*SimpleClient) SetPrimitiveCallback ¶
func (sc *SimpleClient) SetPrimitiveCallback(c state.OnPrimitiveCallback)
Set a callback for when primitives are applied to the document state.
func (*SimpleClient) SetRetipCallback ¶
func (sc *SimpleClient) SetRetipCallback(c OnReTipCallback)
Set a callback for when we reanalyze which event is tip. This may be called multiple times with the same result tip.
Directories ¶
Path | Synopsis |
---|---|
demo
|
|
DEJE Documents and events.
|
DEJE Documents and events. |
Model for the state of a DEJE Document.
|
Model for the state of a DEJE Document. |
Retrieval and processing of timestamps.
|
Retrieval and processing of timestamps. |
Contains standalone utility functions used by go-deje for the sake of convenience.
|
Contains standalone utility functions used by go-deje for the sake of convenience. |