Documentation
¶
Overview ¶
Package connections builds and supervises connector adapters for every declared connection (§10). Adapters are constructed from injected factories, so this package never depends on concrete connectors; external credentials are resolved here and stay in the platform process.
Credentials are refreshed independently of configuration (refresh.go): a changed secret is validated before it replaces the credential in use, and a replacement that fails validation is never activated.
Index ¶
- Constants
- Variables
- type Factories
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Communication(orgID, key string) (connectors.Communication, error)
- func (m *Manager) Credentials(orgID string) map[string]runtimeapi.CredentialStatus
- func (m *Manager) Model(orgID, key string) (connectors.Model, error)
- func (m *Manager) RefreshNow(ctx context.Context, orgID, key string) bool
- func (m *Manager) Remove(orgID string)
- func (m *Manager) Sync(ctx context.Context, orgID string, declared map[string]spec.Connection)
- func (m *Manager) SyncManifest(ctx context.Context, orgID string, manifest *compile.Manifest)
- func (m *Manager) Tracker(orgID, key string) (connectors.Tracker, error)
- func (m *Manager) Verify(ctx context.Context, orgID string, manifest *compile.Manifest) runtimeapi.VerifyResponse
- type Options
- type SinkFactory
Constants ¶
const ( DefaultRefreshInterval = 60 * time.Second DefaultGrace = 10 * time.Minute DefaultMaxStale = 24 * time.Hour DefaultHealthyWait = 30 * time.Second // ForcedRefreshInterval rate-limits refreshes triggered by // authentication failures, per connection. ForcedRefreshInterval = 30 * time.Second )
Defaults for Options.
Variables ¶
var ErrNotConfigured = errors.New("connection not available")
ErrNotConfigured means the connection is not declared or has no usable adapter; the wrapped error says why.
Functions ¶
This section is empty.
Types ¶
type Factories ¶
type Factories struct {
Communication map[string]func(connectors.Config) (connectors.Communication, error)
Tracker map[string]func(connectors.Config) (connectors.Tracker, error)
Model map[string]func(connectors.Config) (connectors.Model, error)
}
Factories construct adapters by adapter name.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the adapters of all organisations.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops every ingress, refresh and watch loop and waits for them.
func (*Manager) Communication ¶
func (m *Manager) Communication(orgID, key string) (connectors.Communication, error)
Communication returns the communication adapter of a connection.
func (*Manager) Credentials ¶ added in v0.2.0
func (m *Manager) Credentials(orgID string) map[string]runtimeapi.CredentialStatus
Credentials reports the credential refresh state of the organisation's connections.
func (*Manager) Model ¶
func (m *Manager) Model(orgID, key string) (connectors.Model, error)
Model returns the model adapter of a connection.
func (*Manager) RefreshNow ¶ added in v0.2.0
RefreshNow re-resolves a connection's credential after an authentication failure. It reports whether a different credential is now in use, in which case the caller may retry a request that was definitely rejected. It runs at most once per ForcedRefreshInterval per connection.
func (*Manager) Sync ¶
Sync (re)builds the organisation's adapters so they match its declared connections. A changed declaration is rebuilt; an unchanged one is kept and, if it is unavailable, retried through the same validated refresh that handles rotation, so a credential known to be invalid is never reactivated.
func (*Manager) SyncManifest ¶ added in v0.2.0
SyncManifest syncs the organisation's connections from its compiled manifest, including the models and APIs its seats use, which model connections verify.
func (*Manager) Tracker ¶
func (m *Manager) Tracker(orgID, key string) (connectors.Tracker, error)
Tracker returns the work-tracker adapter of a connection.
func (*Manager) Verify ¶
func (m *Manager) Verify(ctx context.Context, orgID string, manifest *compile.Manifest) runtimeapi.VerifyResponse
Verify re-checks the organisation's connections, ingress and bindings without creating business work or sending messages (§5.4).
type Options ¶ added in v0.2.0
type Options struct {
Factories Factories
Secrets connectors.Secrets
Sinks SinkFactory
Log *slog.Logger
// RefreshInterval is how often every credential is re-resolved: the
// Vault poll, and the backstop for missed Kubernetes watch events.
RefreshInterval time.Duration
// Grace is how long the previous credential stays in use after its
// replacement failed validation or its secret was deleted.
Grace time.Duration
// MaxStale is how long the current credential stays in use while its
// secret cannot be read or a replacement cannot be validated.
MaxStale time.Duration
// HealthyWait bounds how long a replacement ingress connection may take
// to come up before the previous one is stopped.
HealthyWait time.Duration
// Now is the clock; nil uses time.Now.
Now func() time.Time
}
Options configure a Manager. Zero durations take the defaults.
type SinkFactory ¶
type SinkFactory func(orgID string) connectors.IngressSink
SinkFactory returns the ingress sink for an organisation's communication connections.