app

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	// LocalEventListen returns a listener that is notified of *locally generated*
	// events. Caller should call .Discard() when done.
	LocalEventListen() *LocalEventListener

	// HandleNetRecord handles an inbound thread record from net.
	HandleNetRecord(rec net.ThreadRecord, key thread.Key, lid peer.ID, timeout time.Duration) error
}

App provides a bidirectional hook for thread-based apps.

type Connection

type Connection func(context.Context, thread.ID) (<-chan net.ThreadRecord, error)

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

func NewConnector(app App, net Net, tinfo thread.Info, conn Connection) (*Connector, error)

NewConnector creates bidirectional connection between an app and a thread.

func (*Connector) Close

func (c *Connector) Close() error

Close stops the bidirectional connection between the app and thread.

func (*Connector) ThreadID

func (c *Connector) ThreadID() thread.ID

ThreadID returns the underlying thread's ID.

type LocalEvent

type LocalEvent struct {
	Node  format.Node
	Token thread.Token
}

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

Net adds the ability to connect an app to a thread.

Jump to

Keyboard shortcuts

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