Documentation ¶
Index ¶
- Constants
- func CheckContactName(x string) error
- func ForEachChannel(ctx context.Context, s ChannelAPI, persona string, fn func(string) error) error
- func ForEachEntry(ctx context.Context, s ChannelAPI, cid ChannelID, fn func(Entry) error) error
- func OpenDB(dbPath string) (*sqlx.DB, error)
- type API
- type BlockingAPI
- type ChannelAPI
- type ChannelID
- type ChannelInfo
- type ChannelWT
- type Contact
- type ContactAPI
- type CreateChannelReq
- type CreateContactReq
- type CreatePersonaReq
- type DeleteContactReq
- type Entry
- type EntryPath
- type ExpandPersonaReq
- type GetContactReq
- type GetPersonaReq
- type JoinChannelReq
- type ListChannelReq
- type ListContactReq
- type Message
- type MessageParams
- type Path
- type PeerAdded
- type PeerID
- type PeerRemoved
- type Persona
- type PersonaAPI
- type ReadReq
- type Scheme
- func (sch Scheme[T]) CanRead(ctx context.Context, s cadata.Getter, data json.RawMessage, peer PeerID) (bool, error)
- func (sch Scheme[T]) ListPeers(ctx context.Context, s cadata.Getter, data json.RawMessage) ([]PeerID, error)
- func (sch Scheme[T]) Merge(ctx context.Context, s cadata.Store, datas []json.RawMessage) (*json.RawMessage, error)
- func (sch Scheme[T]) Sync(ctx context.Context, src cadata.Getter, dst cadata.Store, data json.RawMessage) error
- func (sch Scheme[T]) Validate(ctx context.Context, s cadata.Getter, consult owldag.ConsultFunc, ...) error
- func (sch Scheme[T]) ValidateStep(ctx context.Context, s cadata.Getter, consult owldag.ConsultFunc, ...) error
- type SendReq
- type Server
- func (s *Server) Close() (retErr error)
- func (s *Server) CreateChannel(ctx context.Context, req *CreateChannelReq) error
- func (s *Server) CreateContact(ctx context.Context, req *CreateContactReq) error
- func (s *Server) CreatePersona(ctx context.Context, req *CreatePersonaReq) error
- func (s *Server) DeleteChannel(ctx context.Context, cid *ChannelID) error
- func (s *Server) DeleteContact(ctx context.Context, req *DeleteContactReq) error
- func (s *Server) DropPersona(ctx context.Context, name string) error
- func (s *Server) ExpandPersona(ctx context.Context, req *ExpandPersonaReq) error
- func (s *Server) GetChannel(ctx context.Context, cid *ChannelID) (*ChannelInfo, error)
- func (s *Server) GetContact(ctx context.Context, req *GetContactReq) (*Contact, error)
- func (s *Server) GetLocalPeer(ctx context.Context, persona string) (*PeerID, error)
- func (s *Server) GetPersona(ctx context.Context, req *GetPersonaReq) (*Persona, error)
- func (s *Server) Init(ctx context.Context) (err error)
- func (s *Server) JoinChannel(ctx context.Context, req *JoinChannelReq) error
- func (s *Server) ListChannels(ctx context.Context, req *ListChannelReq) ([]string, error)
- func (s *Server) ListContact(ctx context.Context, req *ListContactReq) ([]string, error)
- func (s *Server) ListPersonas(ctx context.Context) (ret []string, _ error)
- func (s *Server) Read(ctx context.Context, req *ReadReq) ([]Entry, error)
- func (s *Server) Send(ctx context.Context, req *SendReq) error
- func (s *Server) ShrinkPersona(ctx context.Context, req *ShrinkPersonaReq) error
- func (s *Server) Sync(ctx context.Context, req *SyncReq) error
- func (s *Server) Wait(ctx context.Context, req *WaitReq) (*WaitRes, error)
- func (s *Server) WhoIs(ctx context.Context, persona string, peerID PeerID) (string, error)
- type ShrinkPersonaReq
- type SyncReq
- type SyncTarget
- type WaitReq
- type WaitRes
- type WaitTarget
Constants ¶
const (
DirectMessageV0 = "directmsg@v0"
)
Variables ¶
This section is empty.
Functions ¶
func CheckContactName ¶
func ForEachChannel ¶
func ForEachEntry ¶
Types ¶
type API ¶
type API interface { PersonaAPI ContactAPI ChannelAPI BlockingAPI }
type BlockingAPI ¶
type BlockingAPI interface { // Sync blocks until all of the targets have completed a sync. // It returns the first error encountered syncing any of the targets Sync(ctx context.Context, req *SyncReq) error // Wait blocks until any of the targets have changed, then it returns the target that changed. Wait(ctx context.Context, req *WaitReq) (*WaitRes, error) }
type ChannelAPI ¶
type ChannelAPI interface { // CreateChannel creates a new channel with name CreateChannel(ctx context.Context, req *CreateChannelReq) error // JoinChannel joins an existing channel JoinChannel(ctx context.Context, req *JoinChannelReq) error // DeleteChannel deletes the channel with name if it exists DeleteChannel(ctx context.Context, cid *ChannelID) error // ListChannels lists channels starting with begin ListChannels(ctx context.Context, req *ListChannelReq) ([]string, error) // GetLatest returns the latest EntryIndex GetChannel(ctx context.Context, cid *ChannelID) (*ChannelInfo, error) // Send, sends a message to a channel. Send(ctx context.Context, req *SendReq) error // Read reads events from a channel Read(ctx context.Context, req *ReadReq) ([]Entry, error) }
type ChannelInfo ¶
type ContactAPI ¶
type ContactAPI interface { // CreateContact adds a contact to the contact list for persona CreateContact(ctx context.Context, req *CreateContactReq) error // RemoveContact removes a contact. DeleteContact(ctx context.Context, req *DeleteContactReq) error // ListContacts lists contacts starting with begin. ListContact(ctx context.Context, res *ListContactReq) ([]string, error) // GetContact returns information about a contact. GetContact(ctx context.Context, req *GetContactReq) (*Contact, error) }
type CreateChannelReq ¶
type CreateContactReq ¶
type CreatePersonaReq ¶
type CreatePersonaReq struct {
Name string `json:"name"`
}
type DeleteContactReq ¶
type Entry ¶
type Entry struct { Path EntryPath ID cadata.ID PeerAdded *PeerAdded PeerRemoved *PeerRemoved Message *Message }
Entry is an element in a Channel. Entries each have a unique Path.
type ExpandPersonaReq ¶
type GetContactReq ¶
type GetPersonaReq ¶
type GetPersonaReq struct {
Name string `json:"name"`
}
type JoinChannelReq ¶
type ListChannelReq ¶
type ListContactReq ¶
type ListContactReq struct {
Persona string `json:"persona"`
}
type Message ¶
type Message struct { // AuthorPeer is the PeerID that wrote the message AuthorPeer PeerID // AuthorContact is the name of the contact which the peer corresponds to (if any). AuthorContact string After []EntryPath Timestamp time.Time Type string Body json.RawMessage }
Message is a type of Entry
type MessageParams ¶
type MessageParams struct { Thread EntryPath Parent EntryPath Type string Body json.RawMessage }
MessageParams are used to create a message
func NewText ¶
func NewText(x string) MessageParams
NewText creates parameters for a simple text message
type Path ¶
type Path []uint64
Path identifies an event within a channel Paths will always have a length > 0. If the length is > 1, then all but the last element are considered the ThreadID
type PeerRemoved ¶
type PeerRemoved struct {
Peer, RemovedBy PeerID
}
PeerRemoved is a type of Entry
type Persona ¶
A Persona is a collection of inet256.IDs LocalIDs are IDs which the instance has a private key for, and can therefore send as those Peers.
type PersonaAPI ¶
type PersonaAPI interface { // CreatePersona creates a new persona called name. // If any ids are provided then the persona will not have a feed, and will attempt to join // a feed provided by one of the IDs. CreatePersona(ctx context.Context, req *CreatePersonaReq) error // GetPersona retrieves the Persona at name GetPersona(ctx context.Context, req *GetPersonaReq) (*Persona, error) // DropPersona drops all the state on the local instance associated with a persona DropPersona(ctx context.Context, name string) error // ListPersonas lists personas on the instance. ListPersonas(ctx context.Context) ([]string, error) // ExpandPersona adds a peer to the Persona at name. ExpandPersona(ctx context.Context, req *ExpandPersonaReq) error // ShrinkPersona removes a peer from the Persona at name ShrinkPersona(ctx context.Context, req *ShrinkPersonaReq) error }
type Scheme ¶
type Scheme[T any] struct { // contains filtered or unexported fields }
func (Scheme[T]) Merge ¶
func (sch Scheme[T]) Merge(ctx context.Context, s cadata.Store, datas []json.RawMessage) (*json.RawMessage, error)
func (Scheme[T]) Validate ¶
func (sch Scheme[T]) Validate(ctx context.Context, s cadata.Getter, consult owldag.ConsultFunc, data json.RawMessage) error
func (Scheme[T]) ValidateStep ¶
func (sch Scheme[T]) ValidateStep(ctx context.Context, s cadata.Getter, consult owldag.ConsultFunc, d1, d2 json.RawMessage) error
type SendReq ¶
type SendReq struct { Persona string `json:"persona"` Name string `json:"name"` Params MessageParams `json:"params"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CreateChannel ¶
func (s *Server) CreateChannel(ctx context.Context, req *CreateChannelReq) error
CreateChannel creates a new channel
func (*Server) CreateContact ¶
func (s *Server) CreateContact(ctx context.Context, req *CreateContactReq) error
CreateContact looks up the contactset for persona, then puts an entry (name, contact) in that set.
func (*Server) CreatePersona ¶
func (s *Server) CreatePersona(ctx context.Context, req *CreatePersonaReq) error
func (*Server) DeleteChannel ¶
func (*Server) DeleteContact ¶
func (s *Server) DeleteContact(ctx context.Context, req *DeleteContactReq) error
func (*Server) ExpandPersona ¶
func (s *Server) ExpandPersona(ctx context.Context, req *ExpandPersonaReq) error
func (*Server) GetChannel ¶
func (*Server) GetContact ¶
func (*Server) GetLocalPeer ¶
GetLocalPeer returns a PeerID to use for communication
func (*Server) GetPersona ¶
func (*Server) JoinChannel ¶
func (s *Server) JoinChannel(ctx context.Context, req *JoinChannelReq) error
JoinChannel adds an existing channel feed identified by cid.
func (*Server) ListChannels ¶
func (*Server) ListContact ¶
func (*Server) ListPersonas ¶
func (*Server) ShrinkPersona ¶
func (s *Server) ShrinkPersona(ctx context.Context, req *ShrinkPersonaReq) error
type ShrinkPersonaReq ¶
type SyncReq ¶
type SyncReq struct {
Targets []SyncTarget `json:"targets"`
}
type SyncTarget ¶
type WaitReq ¶
type WaitReq struct {
Targets []WaitTarget `json:"target"`
}
type WaitTarget ¶
type WaitTarget struct {
Channel *ChannelWT `json:"channel"`
}