service

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOption

type AddOption func(*AddOptions)

AddOption is an add thread option.

func FollowKey

func FollowKey(key *symmetric.Key) AddOption

FollowKey allows thread record traversal.

func ReadKey

func ReadKey(key *symmetric.Key) AddOption

ReadKey allows for thread record decryption.

type AddOptions

type AddOptions struct {
	FollowKey *symmetric.Key
	ReadKey   *symmetric.Key
}

AddOptions defines options for adding a new thread.

type Event

type Event interface {
	format.Node

	// HeaderID returns the cid of the event header.
	HeaderID() cid.Cid

	// GetHeader loads and optionally decrypts the event header.
	// If no key is given, the header time and key methods will return an error.
	GetHeader(context.Context, format.DAGService, crypto.DecryptionKey) (EventHeader, error)

	// BodyID returns the cid of the event body.
	BodyID() cid.Cid

	// GetBody loads and optionally decrypts the event body.
	GetBody(context.Context, format.DAGService, crypto.DecryptionKey) (format.Node, error)
}

Event is the Block format used by threads

type EventHeader

type EventHeader interface {
	format.Node

	// Time returns the wall-clock time at which this event was created.
	Time() (*time.Time, error)

	// Key returns a single-use decryption key for the event body.
	Key() (crypto.DecryptionKey, error)
}

EventHeader is the format of the event's header object

type Record

type Record interface {
	format.Node

	// BlockID returns the cid of the node block.
	BlockID() cid.Cid

	// GetBlock loads the node block.
	GetBlock(context.Context, format.DAGService) (format.Node, error)

	// PrevID returns the cid of the previous node.
	PrevID() cid.Cid

	// Sig returns the node signature.
	Sig() []byte

	// Verify returns a non-nil error if the node signature is valid.
	Verify(pk crypto.PubKey) error
}

Record is the most basic component of a log.

type Service

type Service interface {
	io.Closer

	// Host provides a network identity.
	Host() host.Host

	// DAGService provides a DAG API to the network.
	format.DAGService

	// Store persists thread details.
	Store() lstore.Logstore

	// AddThread from a multiaddress.
	AddThread(ctx context.Context, addr ma.Multiaddr, opts ...AddOption) (thread.Info, error)

	// PullThread for new records.
	PullThread(ctx context.Context, id thread.ID) error

	// DeleteThread with id.
	DeleteThread(ctx context.Context, id thread.ID) error

	// AddFollower to a thread.
	AddFollower(ctx context.Context, id thread.ID, pid peer.ID) error

	// AddRecord with body.
	AddRecord(ctx context.Context, id thread.ID, body format.Node) (ThreadRecord, error)

	// GetRecord returns the record at cid.
	GetRecord(ctx context.Context, id thread.ID, rid cid.Cid) (Record, error)

	// Subscribe returns a read-only channel of records.
	Subscribe(opts ...SubOption) Subscription
}

Service is the network interface for thread orchestration.

type SubOption

type SubOption func(*SubOptions)

SubOption is a thread subscription option.

func ThreadID

func ThreadID(id thread.ID) SubOption

ThreadID restricts the subscription to the given thread. Use this option multiple times to build up a list of threads to subscribe to.

type SubOptions

type SubOptions struct {
	ThreadIDs thread.IDSlice
}

SubOptions defines options for a thread subscription.

type Subscription

type Subscription interface {
	// Discard closes the subscription, disabling the reception of further records.
	Discard()

	// Channel returns the channel that receives records.
	Channel() <-chan ThreadRecord
}

Subscription receives thread record updates.

type ThreadRecord

type ThreadRecord interface {
	// Value returns the underlying record.
	Value() Record

	// ThreadID returns the record's thread ID.
	ThreadID() thread.ID

	// LogID returns the record's log ID.
	LogID() peer.ID
}

ThreadRecord wraps Record within a thread and log context.

Jump to

Keyboard shortcuts

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