runtime

package
v1.15.0 Latest Latest
Warning

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

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

Documentation

Overview

Package runtime wires the integrations services into one executable runtime

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIntegrationIDRequired indicates resolution requires an explicit integration ID
	ErrIntegrationIDRequired = errors.New("integrations/runtime: integration id required")
	// ErrInstallationRequired indicates the installation record dependency is missing
	ErrInstallationRequired = errors.New("integrations/runtime: installation required")
	// ErrInstallationNotFound indicates no matching installation could be resolved
	ErrInstallationNotFound = errors.New("integrations/runtime: installation not found")
	// ErrInstallationDefinitionMismatch indicates the resolved installation does not match the requested definition
	ErrInstallationDefinitionMismatch = errors.New("integrations/runtime: installation definition mismatch")
	// ErrConnectionRequired indicates the installation operation requires a credential-selected connection
	ErrConnectionRequired = errors.New("integrations/runtime: connection required")
	// ErrConnectionNotFound indicates the requested connection could not be resolved for the definition
	ErrConnectionNotFound = errors.New("integrations/runtime: connection not found")
	// ErrDefinitionNotFound indicates the requested integration definition is not registered
	ErrDefinitionNotFound = errors.New("integrations/runtime: definition not found")
	// ErrOperationNotFound indicates the requested operation is not registered for the definition
	ErrOperationNotFound = errors.New("integrations/runtime: operation not found")
	// ErrOperationConfigInvalid indicates the operation config payload failed schema validation
	ErrOperationConfigInvalid = errors.New("integrations/runtime: operation config invalid")
	// ErrUserInputInvalid indicates the user input payload failed schema validation
	ErrUserInputInvalid = errors.New("integrations/runtime: user input invalid")
	// ErrCredentialInvalid indicates the credential payload failed schema validation
	ErrCredentialInvalid = errors.New("integrations/runtime: credential invalid")
	// ErrCredentialNotDeclared indicates the credential is not declared on the resolved connection
	ErrCredentialNotDeclared = errors.New("integrations/runtime: credential not declared on connection")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// DB is the Ent client used by run stores and direct installation queries
	DB *ent.Client
	// Gala is the event runtime used for operation dispatch and execution
	Gala *gala.Gala
	// Registry overrides the default empty definition registry when provided
	Registry *registry.Registry
	// DefinitionBuilders override the built-in catalog when provided
	DefinitionBuilders []registry.Builder
	// Keystore provides credential persistence and installation-scoped client pooling
	Keystore *keystore.Store
	// RedisClient provides the shared Redis client used for ephemeral integration auth state
	RedisClient *redis.Client
	// CatalogConfig supplies operator-level credentials for all built-in definitions
	CatalogConfig catalog.Config
}

Config defines the dependencies required to build the integrations runtime

type IntegrationLookup

type IntegrationLookup struct {
	// IntegrationID is the unique identifier of the integration installation and required
	IntegrationID string
	// OwnerID scopes the integration to a specific owner, if provided
	OwnerID string
	// DefinitionID validates the integration belongs to a specific definition, if provided
	DefinitionID string
}

IntegrationLookup holds the query constraints for resolving an integration

type PostExecutionHook

type PostExecutionHook func(ctx context.Context, envelope operations.Envelope, err error)

PostExecutionHook is called after HandleOperation completes with the processed envelope and any execution error

type Runtime

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

Runtime bundles the integrations services behind a do injector

func New

func New(config Config) (*Runtime, error)

New wires the integrations runtime

func NewForTesting

func NewForTesting(reg *registry.Registry) *Runtime

NewForTesting constructs a Runtime backed only by the supplied registry Use only in unit tests that exercise registry lookup without executing operations

func (*Runtime) BeginAuth

BeginAuth starts one definition auth flow through the runtime-managed keymaker service

func (*Runtime) Catalog

func (r *Runtime) Catalog() []types.DefinitionSpec

Catalog returns all registered definition specs in stable id order

func (*Runtime) CompleteAuth

CompleteAuth completes one definition auth flow through the runtime-managed keymaker service

func (*Runtime) DB

func (r *Runtime) DB() *ent.Client

DB returns the Ent client from the injector

func (*Runtime) Definition

func (r *Runtime) Definition(id string) (types.Definition, bool)

Definition returns one definition by canonical identifier

func (*Runtime) Disconnect

func (r *Runtime) Disconnect(ctx context.Context, installation *ent.Integration) (types.DisconnectResult, error)

Disconnect executes the teardown flow for one installation

func (*Runtime) Dispatch

Dispatch enqueues one integration operation through the runtime-managed dispatcher

func (*Runtime) DispatchWebhookEvent

func (r *Runtime) DispatchWebhookEvent(ctx context.Context, integration *ent.Integration, webhookName string, event types.WebhookReceivedEvent) error

DispatchWebhookEvent emits one normalized integration webhook event through Gala

func (*Runtime) EnsureInstallation

func (r *Runtime) EnsureInstallation(ctx context.Context, ownerID, integrationID string, def types.Definition) (*ent.Integration, bool, error)

EnsureInstallation returns an existing installation when integrationID is provided, or creates a new one

func (*Runtime) EnsureWebhook

func (r *Runtime) EnsureWebhook(ctx context.Context, integration *ent.Integration, webhookName string, previousIntegrationID string) (*ent.IntegrationWebhook, error)

EnsureWebhook returns the persisted webhook row for one integration and definition webhook

func (*Runtime) ExecuteOperation

func (r *Runtime) ExecuteOperation(ctx context.Context, integration *ent.Integration, operation types.OperationRegistration, credentials types.CredentialBindings, config json.RawMessage) (json.RawMessage, error)

ExecuteOperation runs one integration operation inline without run tracking

func (*Runtime) FinalizeWebhookDelivery

func (r *Runtime) FinalizeWebhookDelivery(ctx context.Context, webhook *ent.IntegrationWebhook, deliveryID string, status string, deliveryErr error) error

FinalizeWebhookDelivery updates persisted delivery metadata for one webhook endpoint

func (*Runtime) Gala

func (r *Runtime) Gala() *gala.Gala

Gala returns the event runtime from the injector

func (*Runtime) HandleOperation

func (r *Runtime) HandleOperation(ctx context.Context, envelope operations.Envelope) error

HandleOperation executes one queued operation envelope through the runtime-managed dependencies

func (*Runtime) HandleReconcile

func (r *Runtime) HandleReconcile(ctx context.Context, envelope operations.ReconcileEnvelope) (int, error)

HandleReconcile executes one reconcilable operation inline and returns the number of records processed as the delta for adaptive scheduling

func (*Runtime) HandleWebhookEvent

func (r *Runtime) HandleWebhookEvent(ctx context.Context, envelope operations.WebhookEnvelope) error

HandleWebhookEvent processes one emitted integration webhook envelope

func (*Runtime) LoadCredential

func (r *Runtime) LoadCredential(ctx context.Context, installation *ent.Integration, credentialRef types.CredentialSlotID) (types.CredentialSet, bool, error)

LoadCredential resolves one persisted credential slot for one installation

func (*Runtime) PrepareWebhookDelivery

func (r *Runtime) PrepareWebhookDelivery(ctx context.Context, webhook *ent.IntegrationWebhook, deliveryID string) (bool, error)

PrepareWebhookDelivery records one delivery idempotency key when present

func (*Runtime) Reconcile

func (r *Runtime) Reconcile(ctx context.Context, installation *ent.Integration, userInput json.RawMessage, credentialRef types.CredentialSlotID, credential *types.CredentialSet, installationInput json.RawMessage) error

Reconcile reconciles installation user input and/or one credential update

func (*Runtime) Registry

func (r *Runtime) Registry() *registry.Registry

Registry returns the definition registry

func (*Runtime) ResolveIntegration

func (r *Runtime) ResolveIntegration(ctx context.Context, lookup IntegrationLookup) (*ent.Integration, error)

ResolveIntegration resolves one integration by explicit ID with optional owner and definition cross-checks

func (*Runtime) ResolveWebhookByEndpoint

func (r *Runtime) ResolveWebhookByEndpoint(ctx context.Context, endpointID string) (*ent.IntegrationWebhook, error)

ResolveWebhookByEndpoint returns the persisted inbound webhook row for the given endpoint ID

func (*Runtime) SetPostExecutionHook

func (r *Runtime) SetPostExecutionHook(hook PostExecutionHook)

SetPostExecutionHook registers a callback invoked after each HandleOperation call

Jump to

Keyboard shortcuts

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