-
Notifications
You must be signed in to change notification settings - Fork 65
/
service.go
62 lines (45 loc) · 1.75 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package service
import (
"context"
"io"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/textileio/go-threads/core/thread"
)
// Service is the network interface for thread orchestration.
type Service interface {
API
// DAGService provides a DAG API to the network.
format.DAGService
// Host provides a network identity.
Host() host.Host
}
// API is the network interface for thread orchestration.
type API interface {
io.Closer
// GetHostID returns the host's peer id.
GetHostID(ctx context.Context) (peer.ID, error)
// CreateThread with id.
CreateThread(ctx context.Context, id thread.ID, opts ...KeyOption) (thread.Info, error)
// AddThread from a multiaddress.
AddThread(ctx context.Context, addr ma.Multiaddr, opts ...KeyOption) (thread.Info, error)
// GetThread with id.
GetThread(ctx context.Context, id thread.ID) (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, paddr ma.Multiaddr) (peer.ID, error)
// CreateRecord with body.
CreateRecord(ctx context.Context, id thread.ID, body format.Node) (ThreadRecord, error)
// AddRecord to the given log.
AddRecord(ctx context.Context, id thread.ID, lid peer.ID, rec Record) 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(ctx context.Context, opts ...SubOption) (<-chan ThreadRecord, error)
}