integration

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package integration is wowapi's external-provider framework: modules register a Provider ADAPTER per provider key (a payment gateway, an SMS gateway, an identity source, …); per-tenant/platform rows in integration_providers hold the non-secret config plus a credential REFERENCE (never plaintext); and the kernel resolves an adapter + its config + its resolved credential on demand and aggregates provider health for readiness.

Anti-corruption boundary: the adapter is where a provider's payloads are translated to kernel/module types — provider types never cross into services. Contract: blueprint 07 §6.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Key      string
	Kind     string
	Settings map[string]any
	// Credential is the resolved secret as a config.Secret, so it is structurally
	// redacted — it never appears in logs, %v, JSON, or dumps (roadmap S4/CA-14).
	// Unwrap the plaintext with the Secret's reveal accessor at the point of use;
	// IsZero when there is no credential_ref.
	Credential config.Secret
	IsPlatform bool // true when resolved from the platform (tenant_id NULL) row
}

Config is a resolved provider instance: identity, non-secret settings, and the resolved credential (from the row's credential_ref via the secrets provider). Credential is never logged.

type Provider

type Provider interface {
	Key() string  // "core.stripe" — module.name
	Kind() string // one of validKinds
	// HealthCheck probes the live provider using the resolved config. A non-nil
	// error marks the provider degraded (surfaced in readiness detail, non-fatal).
	HealthCheck(ctx context.Context, cfg Config) error
}

Provider is the adapter a module registers for one provider key. Concrete per-kind behavior lives behind interfaces the module defines; the kernel needs only identity and a health probe.

type Registry

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

Registry collects provider adapters during module registration.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty provider registry.

func (*Registry) Err

func (r *Registry) Err() error

Err returns accumulated registration errors joined, or nil.

func (*Registry) Get

func (r *Registry) Get(key string) (Provider, bool)

Get returns the registered adapter for key.

func (*Registry) Keys

func (r *Registry) Keys() []string

Keys returns registered provider keys, sorted.

func (*Registry) Register

func (r *Registry) Register(module string, p Provider)

Register adds a provider adapter. A malformed/foreign-module key, an invalid kind, or a duplicate is recorded and surfaced by Err().

type Store

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

Store reads/writes integration_providers rows and resolves a provider's config + credential. Config reads run on the caller's TenantDB (RLS: a tenant sees its own rows + platform defaults); writes run with platform privilege (provider config is behavior-changing, kept off the module role — SEC-13).

func NewStore

func NewStore(reg *Registry, sec secrets.Provider, idgen model.IDGen) *Store

NewStore wires the store. secrets may be nil (credential resolution then errors if a row carries a credential_ref).

func (*Store) HealthChecks

func (s *Store) HealthChecks(ctx context.Context, db database.TenantDB) map[string]error

HealthChecks probes every registered provider that has an active config row visible to the caller's tenant. Returns key → error (nil = healthy). A provider with no config row is skipped (not enabled for this tenant). Non-fatal: intended for readiness detail.

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, db database.TenantDB, key string) (Config, error)

Resolve loads the active config for key (a tenant override wins over the platform default) and resolves its credential. Runs on the caller's TenantDB.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, db database.DBTX, in UpsertIn) (uuid.UUID, error)

Upsert inserts or updates a provider config row (platform privilege). Returns the row id.

type UpsertIn

type UpsertIn struct {
	TenantID      uuid.UUID
	Key           string
	Kind          string
	Settings      map[string]any
	CredentialRef string // a secretref://... string, or "" for none
}

UpsertIn describes a provider config row. TenantID zero → a platform-wide row (tenant_id NULL); non-zero → a tenant override (the DBTX must be bound to that tenant so RLS admits the write).

Jump to

Keyboard shortcuts

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