Help us shape the future of Go! Take the 2026 Go Developer Survey

peer

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package peer makes a Worker object a Bridge peer (DECISIONS.md P11): a persisted identity in the object's Store, the object's own Orb attached as its orb.instance/1 service, pinned-TLS streams over the object's WebSockets, and the owner's admin surface. The object only accepts streams: it reaches another peer over the connection that peer opened.

Index

Constants

View Source
const (
	StateDocument = "/bridge/state.json"
)

Documents in the object's Store, beside settings.json and out of the file tools' reach.

Variables

StateKey is present once the object has a Bridge identity; the shim serves the unauthenticated stream route only then.

Functions

func AgentCalls

func AgentCalls(open func(context.Context) (*Peer, error)) worker.ToolsFunc

AgentCalls adds the bridge_call tool when the object's settings enable the bridge-agent-calls plugin, as on the native CLI. open returns the object's peer when the tool runs.

func Alias

func Alias(name string) string

Alias turns an object name into a Bridge instance alias.

func FullGrant

func FullGrant(peer string) bridge.Grant

FullGrant is the invitation grant `orb bridge pair invite` proposes: full control of every current and future instance.

Types

type DocumentStore

type DocumentStore struct{ Document orbhost.Document }

DocumentStore is a bridge.Store over one Store document.

func (DocumentStore) Load

func (s DocumentStore) Load() ([]byte, error)

func (DocumentStore) Save

func (s DocumentStore) Save(data []byte) error

type Peer

type Peer struct {
	// contains filtered or unexported fields
}

func Open

func Open(instance *worker.Instance, alias string) (*Peer, error)

Open loads or creates the object's Bridge identity, enrolls the object's Orb once under alias, and attaches it for this runtime's lifetime.

func (*Peer) Admin

func (p *Peer) Admin(ctx context.Context, method string, params json.RawMessage, locator string) (json.RawMessage, error)

Admin mirrors the owner methods of `orb bridge`. invite advertises locator, the object's public stream URL. The object cannot dial, so join, publish and the service lifecycle are not offered; self reports the object's identity.

func (*Peer) Call

func (p *Peer) Call(ctx context.Context, peer string, call bridge.Call) (json.RawMessage, error)

Call is the object's agent-initiated call: it needs this object's own instance grant for the destination, and a channel the destination opened.

func (*Peer) InstanceID

func (p *Peer) InstanceID() string

func (*Peer) PeerID

func (p *Peer) PeerID() string

func (*Peer) Serve

func (p *Peer) Serve(ctx context.Context, stream net.Conn) error

Serve authenticates an inbound stream as the TLS server and keeps the channel until either side closes it.

Jump to

Keyboard shortcuts

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