Documentation
¶
Overview ¶
Package bridge owns connectivity authority, never agent execution or sessions, and defines the non-owning, versioned Orb instance attachments it routes.
Index ¶
- func Code(err error) string
- func ConnectClient(ctx context.Context, stream net.Conn, key ed25519.PrivateKey, expected string) (*protocol.Conn, error)
- func Fail(code string) error
- func InvitationCode(inv Invitation) string
- func JSON(v any) json.RawMessage
- func Keepalive(ctx context.Context, c *protocol.Conn, every time.Duration)
- func ParsePeerID(id string) (ed25519.PublicKey, error)
- func PeerID(key ed25519.PublicKey) string
- func ValidateCall(c Call) error
- type Bridge
- func (b *Bridge) AddGrant(g Grant) error
- func (b *Bridge) Admin(_ context.Context, method string, params json.RawMessage) (json.RawMessage, error)
- func (b *Bridge) Allowed(p Principal, id, permission string) bool
- func (b *Bridge) Approve(id, claimant string) error
- func (b *Bridge) Attach(id, credential, boot string, endpoint Endpoint) (string, error)
- func (b *Bridge) Authorize(r Request) bool
- func (b *Bridge) Available(id string) bool
- func (b *Bridge) Block(peer string) error
- func (b *Bridge) Call(ctx context.Context, p Principal, call Call) (json.RawMessage, error)
- func (b *Bridge) Catalog(p Principal) []Instance
- func (b *Bridge) Changes() <-chan struct{}
- func (b *Bridge) Claim(peer, id, token string, locators ...string) (Invitation, error)
- func (b *Bridge) Close() error
- func (b *Bridge) Connect(ctx context.Context, stream net.Conn, expected string, server bool) (*protocol.Conn, string, error)
- func (b *Bridge) Connection(peer string) *protocol.Conn
- func (b *Bridge) Contacts(peer, scope string) ([]Record, error)
- func (b *Bridge) Detach(id, generation string)
- func (b *Bridge) Enroll(alias, group string) (Instance, string, error)
- func (b *Bridge) Handle(ctx context.Context, peer, method string, params json.RawMessage) (json.RawMessage, error)
- func (b *Bridge) Hello() Hello
- func (b *Bridge) Invite(grants []Grant) (Invitation, error)
- func (b *Bridge) Known(peer string) bool
- func (b *Bridge) MergeContact(sender string, r Record) (bool, error)
- func (b *Bridge) Outbound(instance, peer string, call Call) (Subject, error)
- func (b *Bridge) PairStatus(peer, id string) (Invitation, error)
- func (b *Bridge) PeerID() string
- func (b *Bridge) PeerLocator(peer string) (string, error)
- func (b *Bridge) PersonalGroup() string
- func (b *Bridge) Principal() Principal
- func (b *Bridge) PublishContact(scope, name string, endpoints []Locator, withdraw bool) (Record, error)
- func (b *Bridge) Retire(ids []string) (int, error)
- func (b *Bridge) SavePeer(peer, locator string) error
- func (b *Bridge) SaveTransportState(raw json.RawMessage) error
- func (b *Bridge) SetHost(h Host)
- func (b *Bridge) SetName(name string)
- func (b *Bridge) SetScope(id string, peers []string) error
- func (b *Bridge) TLSConfig(expected string, server bool) (*tls.Config, error)
- func (b *Bridge) TransportState() json.RawMessage
- type Call
- type Contact
- type Endpoint
- type Error
- type Event
- type Expected
- type Grant
- type Hello
- type Host
- type Instance
- type Invitation
- type Ledger
- type Local
- type Locator
- type Model
- type Peers
- func (ps *Peers) Admin(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
- func (ps *Peers) Greet()
- func (ps *Peers) Peer(ctx context.Context, id, locator string) (*protocol.Conn, error)
- func (ps *Peers) Reconcile()
- func (ps *Peers) Remote(ctx context.Context, id, method string, p any) (json.RawMessage, error)
- type Principal
- type Receipt
- type Record
- type Request
- type Stream
- type Subject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectClient ¶ added in v0.11.0
func ConnectClient(ctx context.Context, stream net.Conn, key ed25519.PrivateKey, expected string) (*protocol.Conn, error)
ConnectClient opens an outbound-only connection. It starts no listener or Bridge service, and rejects remote calls into the client. The caller owns key storage.
func InvitationCode ¶ added in v0.19.3
func InvitationCode(inv Invitation) string
InvitationCode is what a joining device copies or scans: only what it uses, so grants stay with the inviter and the QR code stays small.
func JSON ¶ added in v0.11.0
func JSON(v any) json.RawMessage
func Keepalive ¶ added in v0.19.1
keepalive pings a peer connection until the connection or the service ends, and closes it when the peer stops answering. A peer that restarted or lost its network leaves a half-open connection behind; without this, the next call on it would wait out its timeout before anything redialled.
func ValidateCall ¶ added in v0.11.0
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
func (*Bridge) Admin ¶
func (b *Bridge) Admin(_ context.Context, method string, params json.RawMessage) (json.RawMessage, error)
Admin is deliberately absent from the remote routing table. Hosts expose it only after local-owner authentication.
func (*Bridge) Claim ¶
func (b *Bridge) Claim(peer, id, token string, locators ...string) (Invitation, error)
func (*Bridge) Connect ¶
func (b *Bridge) Connect(ctx context.Context, stream net.Conn, expected string, server bool) (*protocol.Conn, string, error)
Connect authenticates a caller-supplied stream. It never creates a listener, locates a profile, or starts an agent runtime.
func (*Bridge) Connection ¶
Connection returns an existing authenticated channel in either direction.
func (*Bridge) Handle ¶
func (b *Bridge) Handle(ctx context.Context, peer, method string, params json.RawMessage) (json.RawMessage, error)
func (*Bridge) Known ¶ added in v0.13.2
Known reports whether peer is one this Bridge deals with beyond pairing: a saved peer, one holding a grant, or a member of a scope.
func (*Bridge) PairStatus ¶
func (b *Bridge) PairStatus(peer, id string) (Invitation, error)
func (*Bridge) PersonalGroup ¶
func (*Bridge) PublishContact ¶
func (*Bridge) Retire ¶ added in v0.12.1
Retire removes the named instances or, with none named, every throwaway instance whose Orb has gone: one that attached once, is not attached now, and no grant names. It returns how many it removed.
func (*Bridge) SaveTransportState ¶
func (b *Bridge) SaveTransportState(raw json.RawMessage) error
func (*Bridge) SetName ¶ added in v0.19.3
SetName is what this machine is called on its peers' screens ("Baudouin's MacBook Pro").
func (*Bridge) TransportState ¶
func (b *Bridge) TransportState() json.RawMessage
type Contact ¶
type Contact struct {
Schema string `json:"schema"`
Scope string `json:"scope_id"`
Peer string `json:"peer_id"`
Revision string `json:"revision"`
Name string `json:"display_name"`
Protocols []string `json:"protocols"`
Endpoints []Locator `json:"endpoints"`
Withdrawn bool `json:"withdrawn"`
Extensions map[string]json.RawMessage `json:"extensions,omitempty"`
}
type Endpoint ¶ added in v0.11.0
type Endpoint interface {
Invoke(context.Context, string, json.RawMessage) (json.RawMessage, error)
Close() error
}
Endpoint is implemented by in-process attachments and native IPC clients. Close releases remote availability; it never disposes the attached runtime.
type Event ¶ added in v0.11.0
type Event struct {
Cursor string `json:"cursor"`
Data json.RawMessage `json:"data"`
}
type Grant ¶
type Grant struct {
ID string `json:"grant_id,omitempty"`
Principal Principal `json:"principal"`
GroupID string `json:"group_id,omitempty"`
IncludeFuture bool `json:"include_future"`
Instances []string `json:"instances,omitempty"`
Permissions []string `json:"permissions"`
Destination string `json:"destination,omitempty"`
}
func ConversationGrant ¶ added in v0.19.1
ConversationGrant is control of every conversation without the machine: what a joining Orb gives back to the Orb it joined, which never asked for more.
type Host ¶ added in v0.13.0
type Host func(ctx context.Context, p Principal, method string, params json.RawMessage) (json.RawMessage, error)
Host serves a peer's machine-level calls — the threads stored on this machine, and starting Orb in a folder — for principals whose grant includes host.launch.
type Invitation ¶
type Invitation struct {
ClaimantLocator string `json:"claimant_locator,omitempty"`
ID string `json:"invitation_id"`
PeerID string `json:"peer_id"`
Token string `json:"token,omitempty"`
Locator string `json:"locator,omitempty"`
Expires int64 `json:"expires"`
Grants []Grant `json:"grants"`
Claimant string `json:"claimant,omitempty"`
Status string `json:"status"`
}
func ParseInvitation ¶ added in v0.19.3
func ParseInvitation(text string) (Invitation, error)
ParseInvitation reads an invitation from its code, its JSON, or a message that holds the code.
type Ledger ¶ added in v0.11.0
type Ledger struct {
// contains filtered or unexported fields
}
func OpenLedger ¶ added in v0.11.0
type Local ¶ added in v0.11.0
type Local struct {
// contains filtered or unexported fields
}
Local is a non-owning in-process registration channel. Closing it fences delivery without closing the runtime adapter or its operation ledger.
type Peers ¶ added in v0.19.1
type Peers struct {
Bridge *Bridge
// Dial opens a stream to peer at locator.
Dial func(ctx context.Context, peer, locator string) (net.Conn, error)
// Locator is where peers reach this Bridge; WebURL, when set, replaces it
// in invitations.
Locator func() (string, error)
WebURL string
// Forget drops what this machine keeps of a peer the owner blocked.
Forget func(ctx context.Context, peer string) error
// contains filtered or unexported fields
}
Peers keeps a Bridge's channels to its peers over the transports its host supplies: it dials them, retries a call once on a fresh channel, pings channels so dead ones close, greets known peers at start, exchanges contact records with scope members, and serves the owner calls that need the network (invite, join, remote, publish).
func (*Peers) Admin ¶ added in v0.19.1
func (ps *Peers) Admin(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
type Receipt ¶ added in v0.11.0
type Receipt struct {
InstanceID string `json:"instance_id"`
SessionID string `json:"session_id,omitempty"`
Method string `json:"method"`
Expected Expected `json:"expected"`
AcceptedAt int64 `json:"accepted_at"`
OperationID string `json:"operation_id"`
Status string `json:"status"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Digest string `json:"digest"`
}