Documentation
¶
Overview ¶
Package runtime wires the integrations services into one executable runtime
Index ¶
- Variables
- func Enabled(ctx context.Context, client *ent.Client) bool
- type Config
- type IntegrationLookup
- type PostExecutionHook
- type Runtime
- func (r *Runtime) BeginAuth(ctx context.Context, req keymaker.BeginRequest) (keymaker.BeginResponse, error)
- func (r *Runtime) Catalog() []types.DefinitionSpec
- func (r *Runtime) CompleteAuth(ctx context.Context, req keymaker.CompleteRequest) (keymaker.CompleteResult, error)
- func (r *Runtime) DB() *ent.Client
- func (r *Runtime) Definition(id string) (types.Definition, bool)
- func (r *Runtime) Disconnect(ctx context.Context, installation *ent.Integration) (types.DisconnectResult, error)
- func (r *Runtime) Dispatch(ctx context.Context, req operations.DispatchRequest) (operations.DispatchResult, error)
- func (r *Runtime) DispatchWebhookEvent(ctx context.Context, integration *ent.Integration, webhookName string, ...) error
- func (r *Runtime) EnsureInstallation(ctx context.Context, ownerID, integrationID string, def types.Definition) (*ent.Integration, bool, error)
- func (r *Runtime) EnsureWebhook(ctx context.Context, integration *ent.Integration, webhookName string, ...) (*ent.IntegrationWebhook, error)
- func (r *Runtime) ExecuteOperation(ctx context.Context, integration *ent.Integration, ...) (json.RawMessage, error)
- func (r *Runtime) FinalizeWebhookDelivery(ctx context.Context, webhook *ent.IntegrationWebhook, deliveryID string, ...) error
- func (r *Runtime) Gala() *gala.Gala
- func (r *Runtime) HandleOperation(ctx context.Context, envelope operations.Envelope) error
- func (r *Runtime) HandleReconcile(ctx context.Context, envelope operations.ReconcileEnvelope) (int, error)
- func (r *Runtime) HandleWebhookEvent(ctx context.Context, envelope operations.WebhookEnvelope) error
- func (r *Runtime) LoadCredential(ctx context.Context, installation *ent.Integration, ...) (types.CredentialSet, bool, error)
- func (r *Runtime) PrepareWebhookDelivery(ctx context.Context, webhook *ent.IntegrationWebhook, deliveryID string) (bool, error)
- func (r *Runtime) Reconcile(ctx context.Context, installation *ent.Integration, userInput json.RawMessage, ...) error
- func (r *Runtime) Registry() *registry.Registry
- func (r *Runtime) ResolveIntegration(ctx context.Context, lookup IntegrationLookup) (*ent.Integration, error)
- func (r *Runtime) ResolveWebhookByEndpoint(ctx context.Context, endpointID string) (*ent.IntegrationWebhook, error)
- func (r *Runtime) SetPostExecutionHook(hook PostExecutionHook)
Constants ¶
This section is empty.
Variables ¶
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 ¶
func Enabled ¶ added in v1.16.12
Enabled reports whether the integrations runtime is available for the given client. It checks the context first (for the original client with IntegrationsRuntime set), falling back to the provided client. This handles the case where IntegrationsRuntime is set after client initialization, since entity clients copy config by value.
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 FromClient ¶ added in v1.16.12
FromClient resolves the typed *Runtime from the client, checking the context-based client first, then falling back to the provided client
func NewForTesting ¶
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 ¶
func (r *Runtime) BeginAuth(ctx context.Context, req keymaker.BeginRequest) (keymaker.BeginResponse, error)
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 ¶
func (r *Runtime) CompleteAuth(ctx context.Context, req keymaker.CompleteRequest) (keymaker.CompleteResult, error)
CompleteAuth completes one definition auth flow through the runtime-managed keymaker service
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 ¶
func (r *Runtime) Dispatch(ctx context.Context, req operations.DispatchRequest) (operations.DispatchResult, error)
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) HandleOperation ¶
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) 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