Documentation ¶
Index ¶
- Variables
- type App
- type Connection
- type Connector
- func (c *Connector) CreateNetRecord(ctx context.Context, body format.Node, token thread.Token) (net.ThreadRecord, error)
- func (c *Connector) GetNetRecordCreateTime(ctx context.Context, rec net.ThreadRecord) (int64, error)
- func (c *Connector) HandleNetRecord(ctx context.Context, rec net.ThreadRecord) error
- func (c *Connector) ThreadID() thread.ID
- func (c *Connector) Token() net.Token
- func (c *Connector) Validate(token thread.Token, readOnly bool) error
- func (c *Connector) ValidateNetRecordBody(ctx context.Context, body format.Node, identity thread.PubKey) error
- type LocalEvent
- type LocalEventListener
- type LocalEventsBus
- type Net
Constants ¶
This section is empty.
Variables ¶
var ( // ErrThreadInUse indicates an operation could not be completed because the // thread is bound to an app. ErrThreadInUse = errors.New("thread is in use") // ErrInvalidNetRecordBody indicates the app determined the record body should not be accepted. ErrInvalidNetRecordBody = errors.New("app denied net record body") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface { // ValidateNetRecordBody provides the app an opportunity to validate the contents // of a record before it's committed to a thread log. // identity is the author's public key. ValidateNetRecordBody(ctx context.Context, body format.Node, identity thread.PubKey) error // HandleNetRecord handles an inbound thread record from net. HandleNetRecord(ctx context.Context, rec net.ThreadRecord, key thread.Key) error // GetNetRecordCreateTime calls the connection app's GetNetRecordCreateTime to parse the record createtime. GetNetRecordCreateTime(ctx context.Context, rec net.ThreadRecord, key thread.Key) (int64, error) }
App provides a bidirectional hook for thread-based apps.
type Connection ¶
Connection receives new thread records, which are pumped to the app.
type Connector ¶
type Connector struct { Net Net // contains filtered or unexported fields }
Connector connects an app to a thread.
func NewConnector ¶
NewConnector creates bidirectional connection between an app and a thread.
func (*Connector) CreateNetRecord ¶
func (c *Connector) CreateNetRecord(ctx context.Context, body format.Node, token thread.Token) (net.ThreadRecord, error)
CreateNetRecord calls net.CreateRecord while supplying thread ID and API token.
func (*Connector) GetNetRecordCreateTime ¶ added in v0.1.1
func (c *Connector) GetNetRecordCreateTime(ctx context.Context, rec net.ThreadRecord) (int64, error)
GetNetRecordCreateTime calls the connection app's GetNetRecordCreateTime to parse the record createtime.
func (*Connector) HandleNetRecord ¶
HandleNetRecord calls the connection app's HandleNetRecord while supplying thread key.
type LocalEvent ¶
LocalEvent wraps an IPLD node and auth for delivery to a thread.
type LocalEventListener ¶
type LocalEventListener struct {
// contains filtered or unexported fields
}
LocalEventListener notifies about new locally generated events.
func (*LocalEventListener) Channel ¶
func (l *LocalEventListener) Channel() <-chan *LocalEvent
Channel returns an unbuffered channel to receive local events.
func (*LocalEventListener) Discard ¶
func (l *LocalEventListener) Discard()
Discard indicates that no further events will be received and ready for being garbage collected.
type LocalEventsBus ¶
type LocalEventsBus struct {
// contains filtered or unexported fields
}
LocalEventsBus wraps a broadcaster for local events.
func NewLocalEventsBus ¶
func NewLocalEventsBus() *LocalEventsBus
NewLocalEventsBus returns a new bus for local event.
func (*LocalEventsBus) Discard ¶
func (leb *LocalEventsBus) Discard()
Discard the bus, closing all listeners.
func (*LocalEventsBus) Listen ¶
func (leb *LocalEventsBus) Listen() *LocalEventListener
Listen returns a local event listener.
func (*LocalEventsBus) Send ¶
func (leb *LocalEventsBus) Send(event *LocalEvent) error
Send an IPLD node and thread auth into the bus. These are received by the app connector and written to the underlying thread.
type Net ¶
type Net interface { net.Net // ConnectApp returns an app<->thread connector. ConnectApp(App, thread.ID) (*Connector, error) // Validate thread ID and token against the net host. // If token is present and was issued the net host (is valid), the embedded public key is returned. // If token is not present, both the returned public key and error will be nil. Validate(id thread.ID, token thread.Token, readOnly bool) (thread.PubKey, error) // Exchange thread records with peers that have the thread. Exchange(ctx context.Context, id thread.ID) error }
Net adds the ability to connect an app to a thread.