connid

package
v1.128.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package connid owns connection identity: the several names one connection carries, which surface keys on which, and which half of the configuration owns it.

It is separate from pkg/connview, which builds the list_connections view, because the two answer different questions — that one presents connections to a caller, this one decides which connection a name means. Every defect in this area has been a call site holding one name and using it where another belongs, so the names are distinct types and Resolver is the only translation between them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bound

type Bound string

Bound is the name a call binds a connection by.

type Connection

type Connection struct {
	Kind     string
	Instance Instance
	Bound    Bound
	// FileDeclared marks a connection the platform configuration file declares.
	// The file is the only place it can be changed or removed: a stored record
	// for one reaches the running process but is discarded at the next restart,
	// and deleting that record drops the connection from every live toolkit
	// until a restart puts it back. False means the connection store
	// contributed it, which is also what a resolver with no Declarer reports.
	FileDeclared bool
	// Toolkit is the name of the registered toolkit serving this connection,
	// which is a third identity and not interchangeable with either of the
	// other two. For a single-connection toolkit it equals Instance. For a
	// multi-connection toolkit it is the aggregate toolkit's own name while
	// each Instance is one of its connections, so it names no connection at
	// all — yet the connection source map holds entries under it, seeded from
	// per-kind configuration, and a connection with no entry of its own falls
	// back to it. It is a plain string because nothing translates to or from
	// it; it is only ever compared with itself.
	Toolkit string
	// Live reports whether a registered toolkit currently serves this
	// connection. A stored record whose kind is disabled, or whose toolkit
	// failed to build, resolves with Live false rather than being absent:
	// callers that must not invent a mapping for a connection nothing serves
	// check this instead of re-deriving it from the registry.
	Live bool
}

Connection is one connection's identity: both of its names, its kind, and which half of the configuration owns it. Resolver is the only thing that builds one, so the pairing is established in a single place.

func (Connection) IsFile

func (c Connection) IsFile() bool

IsFile reports whether the configuration file declares this connection.

type Declarer

type Declarer interface {
	DeclaresConnection(kind, instance string) bool
}

Declarer reports whether the platform configuration file declares an instance of a kind. *platform.Config satisfies it. It is an interface so connview does not import the platform package, which imports connview.

A nil Declarer declares nothing, so every connection resolves as the store's.

type Instance

type Instance string

Instance is the name a connection is configured and stored under.

type Resolver

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

Resolver answers connection-identity questions against a fixed view of the live toolkits: which name a call binds an instance by, which instance a bound name belongs to, and who owns either.

It holds no mutable state and is cheap to construct, so callers build one per operation from the registry rather than caching a view that a hot-added connection would make stale.

func NewResolver

func NewResolver(toolkits []registry.Toolkit, declared Declarer) *Resolver

NewResolver returns a Resolver over the given toolkits. Both arguments may be nil: no toolkits resolves every connection to itself and not live, and no Declarer resolves every connection as the store's.

func (*Resolver) All

func (r *Resolver) All(kind string) []Connection

All enumerates every connection the registered toolkits of a kind serve. An empty kind enumerates every kind.

func (*Resolver) ByBound

func (r *Resolver) ByBound(kind string, bound Bound) (Connection, bool)

ByBound resolves the connection a tool call's argument, a persona rule, or a source-map lookup names. The second result is false when no live toolkit serves that name, which is the case a caller must not paper over by assuming the bound name is also an instance.

func (*Resolver) ByInstance

func (r *Resolver) ByInstance(kind string, inst Instance) Connection

ByInstance resolves the connection a stored record or an instances key names.

An instance no live toolkit claims resolves to itself with Live false rather than to nothing: the caller still needs to know who owns it, and a record for a disabled kind still has to answer under some name. Its own name is also the only safe fallback, because inventing a different bound name for a connection nothing serves would file it where no lookup will ever arrive. Toolkit is that same name, which is what it would be if a single-connection toolkit for the instance were registered; nothing reads it while Live is false.

Jump to

Keyboard shortcuts

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