Documentation
¶
Index ¶
- Constants
- type Bus
- func (b *Bus) ActorSystem() *actor.ActorSystem
- func (b *Bus) AgentKV() nats.KeyValue
- func (b *Bus) BoardKV() nats.KeyValue
- func (b *Bus) ClientPort() int
- func (b *Bus) Close()
- func (b *Bus) Codecs() *msg.CodecRegistry
- func (b *Bus) Conn() *nats.Conn
- func (b *Bus) FleetKV() nats.KeyValue
- func (b *Bus) GuestOf() (GuestOf, bool)
- func (b *Bus) JS() nats.JetStreamContext
- func (b *Bus) PaneKV() nats.KeyValue
- func (b *Bus) PipelineKV() nats.KeyValue
- func (b *Bus) Publisher() *msg.NATSPublisher
- func (b *Bus) SecretKV() nats.KeyValue
- func (b *Bus) VariableKV() nats.KeyValue
- func (b *Bus) WorkspaceKV() nats.KeyValue
- type Config
- type GuestOf
- type HostIdentity
Constants ¶
const HostIdentitySubject = "rysh.bus.host.identity"
HostIdentitySubject is answered by the daemon that OWNS an embedded NATS server, so a guest can tell whose store it is writing into.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus wraps either an embedded NATS server or an external connection. It exposes a plain *nats.Conn, two JetStream KV buckets, a proto.actor ActorSystem, a CodecRegistry, and a NATSPublisher.
func (*Bus) ActorSystem ¶
func (b *Bus) ActorSystem() *actor.ActorSystem
ActorSystem returns the proto.actor ActorSystem.
func (*Bus) BoardKV ¶ added in v0.2.4
BoardKV returns the per-session agents-board history bucket. It may be nil when JetStream is unavailable, in which case the board is live-only: posts are delivered and rendered but do not survive a restart.
func (*Bus) ClientPort ¶
ClientPort returns the TCP port external CLI clients can connect to. Returns 0 if no TCP listener is available (e.g. external NATS mode).
func (*Bus) Close ¶
func (b *Bus) Close()
Close shuts down the ActorSystem, drains the connection, and shuts down the embedded server (if any).
func (*Bus) FleetKV ¶ added in v0.2.6
FleetKV returns the per-session fleet registry bucket (design 028).
func (*Bus) GuestOf ¶ added in v0.2.11
GuestOf returns what this Bus knows about the server it joined as a guest; ok is false (and the value empty) when the Bus owns its server or is an external client.
func (*Bus) PipelineKV ¶
PipelineKV returns the KV bucket for pipeline prompt persistence.
func (*Bus) Publisher ¶
func (b *Bus) Publisher() *msg.NATSPublisher
Publisher returns the NATSPublisher for sending typed messages.
func (*Bus) SecretKV ¶
SecretKV returns the per-session secret store bucket. It may be nil when JetStream is unavailable, in which case secret resolution falls back to config + environment only.
func (*Bus) VariableKV ¶
VariableKV returns the per-session variable store bucket. It may be nil when JetStream is unavailable, in which case variable resolution falls back to config + environment only.
func (*Bus) WorkspaceKV ¶
WorkspaceKV returns the KV bucket for workspace state.
type Config ¶
type Config struct {
Mode string // "embedded" or "external"
URL string // NATS URL, used when Mode == "external"
DataDir string // JetStream storage directory (empty = auto)
SessionName string // used to isolate data dirs per session
// Port is the TCP port for the embedded NATS server. 0 means
// kernel-assigned: a private server on a free port, never a probe of an
// existing one. The 24242 default belongs to config, not to this package —
// defaulting here is what once sent `port: 0` test daemons into the
// developer's live NATS.
Port int
// Attach marks a client of a session some other process owns — the TUI of
// `rysh attach`. The owning daemon has already declared every bucket, so an
// attaching Bus looks them up instead: one StreamInfo per bucket rather than
// an AccountInfo plus a stream create. A slow shared server used to fail
// attach outright at "create rysh-workspace-<session> KV: context deadline
// exceeded" while the daemon itself was fine.
Attach bool
// Workspace is this daemon's project root (the session record's Path). A
// guest compares it with the host's; an owner answers it on
// HostIdentitySubject. Design 028 §9 limit 7.
Workspace string
// HostQueryTimeout bounds a guest's question to the host daemon (0 = 300ms).
HostQueryTimeout time.Duration
// Logger receives the guest/host identity lines (nil = slog.Default()).
Logger *slog.Logger
}
Config holds the settings needed to initialise a Bus.
type GuestOf ¶ added in v0.2.11
type GuestOf struct {
ServerID string `json:"server_id"`
ServerName string `json:"server_name,omitempty"`
Port int `json:"port"`
HostSession string `json:"host_session"` // "unknown" when the host did not answer
HostWorkspace string `json:"host_workspace,omitempty"` // likewise; omitted from the public view
HostPID int `json:"host_pid,omitempty"`
UnknownReason string `json:"unknown_reason,omitempty"`
Pending bool `json:"pending,omitempty"` // the host query is still in flight
// Mismatch is the WARN-worthy case: the host belongs to another WORKSPACE
// (ORDER-13, root-0273). Warning is set with it, and only with it.
Mismatch bool `json:"mismatch"`
// SessionMismatch / WorkspaceMismatch say exactly what differs. A host that
// is another session of the SAME workspace (the desktop sidecar's daemon
// under its own session name) is recorded in Note, at INFO, not warned.
SessionMismatch bool `json:"session_mismatch"`
WorkspaceMismatch bool `json:"workspace_mismatch"`
Note string `json:"note,omitempty"`
Warning string `json:"warning,omitempty"`
}
GuestOf describes the server a guest Bus joined. Its JSON field names are what /health and `##rysh status` show under "guest_of".
type HostIdentity ¶ added in v0.2.11
type HostIdentity struct {
Session string `json:"session"`
Workspace string `json:"workspace"`
PID int `json:"pid"`
}
HostIdentity is the owning daemon's answer on HostIdentitySubject.