service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package service holds connectionforge's operations: create, get, list, rename, test and disconnect. Each checks authorization through the host's cf.Authorizer and records an audit event.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidInput = errors.New("service: invalid input")

ErrInvalidInput is returned for input that does not match the provider's manifest.

View Source
var ErrNotAudited = errors.New("service: the change was made but its event was not recorded")

ErrNotAudited wraps an audit failure after an operation succeeded: the change was made, and the gap in the trail must be treated as an incident.

Functions

func NewUUID

func NewUUID() string

NewUUID returns a random (version 4) UUID.

Types

type CreateInput

type CreateInput struct {
	Owner       cf.OwnerID
	Actor       cf.Principal
	Provider    string
	AuthMethod  string
	DisplayName string
	// Fields are the method's inputs, by field name.
	Fields   map[string]cf.Secret
	Metadata map[string]string
}

CreateInput is a new connection.

type Options

type Options struct {
	Store      cf.Store
	Broker     *broker.Broker
	Providers  *provider.Registry
	Authorizer cf.Authorizer
	Auditor    cf.Auditor
	Clock      cf.Clock
	// NewID returns a new connection ID. The default is a random UUID.
	NewID func() string
}

Options configures a Service.

type ReconnectInput added in v0.2.0

type ReconnectInput struct {
	Owner cf.OwnerID
	Actor cf.Principal
	ID    string
	// Fields are the auth method's inputs, by field name, as for Create.
	Fields map[string]cf.Secret
}

ReconnectInput is a replacement credential for an existing connection.

type Service

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

Service runs connection operations.

func New

func New(o Options) (*Service, error)

New returns a service.

func (*Service) Bind added in v0.2.0

func (s *Service) Bind(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string, consumer cf.Consumer, purpose string) error

Bind records that a consumer uses a connection for a purpose. It is idempotent and requires use: whoever may use a connection may say that a feature depends on it.

func (*Service) Bindings added in v0.2.0

func (s *Service) Bindings(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) ([]cf.Binding, error)

Bindings lists what depends on a connection, so a person can see what a disconnect would stop. It requires view.

func (*Service) Create

func (s *Service) Create(ctx context.Context, in CreateInput) (cf.Connection, error)

Create validates the credential with the provider and, if it is accepted, stores the connection and its sealed credential. A rejected credential stores nothing.

func (*Service) Disconnect

func (s *Service) Disconnect(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)

Disconnect destroys a connection's credentials and marks it disconnected. The record stays, so the audit trail and bindings keep their reference.

func (*Service) Get

func (s *Service) Get(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)

Get returns a connection the actor may view.

func (*Service) List

func (s *Service) List(ctx context.Context, owner cf.OwnerID, actor cf.Principal, f cf.Filter) ([]cf.Connection, error)

List returns the owner's connections that the actor may view.

func (*Service) Reconnect added in v0.2.0

func (s *Service) Reconnect(ctx context.Context, in ReconnectInput) (cf.Connection, error)

Reconnect replaces a connection's credential with a new one, keeping the connection, so what is bound to it keeps working. The new credential is validated with the provider first; if it is rejected, or belongs to a different account, nothing changes. On success the previous versions stay until the connection's credentials are destroyed, the connection is `connected` again with fresh health, and a connection that needed attention, or was disconnected, is usable.

It also recovers a connection whose sealed credential can no longer be read, since the new one is sealed without opening the old.

func (*Service) Rename

func (s *Service) Rename(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id, name string) (cf.Connection, error)

Rename changes a connection's display name.

func (*Service) Test

func (s *Service) Test(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)

Test validates a connection's credential with its provider and records the result as health. A permanent failure moves the connection to needs_attention and a success moves it back to connected; a transient failure changes only health. The validation outcome is in the returned connection's health, not in the error.

func (*Service) Unbind added in v0.2.0

func (s *Service) Unbind(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string, consumer cf.Consumer, purpose string) error

Unbind removes a binding. It requires use and is not an error when none exists.

Jump to

Keyboard shortcuts

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