exec

package
v0.56.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAbsoluteURLNotAllowed rejects a script request carrying an absolute
	// URL: adapter scripts reach only their own system's base URL.
	ErrAbsoluteURLNotAllowed = errors.New("integration: absolute URLs are not allowed; use a path relative to the system base URL")

	// ErrRedirectModeUnsupported rejects the fetch redirect modes the scoped
	// client does not implement ("error" and "manual").
	ErrRedirectModeUnsupported = errors.New("integration: only the default 'follow' redirect mode is supported")

	// ErrOutputNotSerializable rejects a script return value that cannot be
	// represented as JSON (functions, cycles).
	ErrOutputNotSerializable = errors.New("integration: script output is not JSON-serializable")

	// ErrEnvelopeRequestNotObject rejects a request envelope script that did
	// not return the request object.
	ErrEnvelopeRequestNotObject = errors.New("integration: request envelope script must return the request object")

	// ErrReplayDispatchUnrecorded fails a replayed dispatch the original
	// delivery never reached the business handler with — a script edited to
	// dispatch more often than the delivery it replays.
	ErrReplayDispatchUnrecorded = errors.New("integration: the replayed delivery recorded no handler result for this dispatch")
)
View Source
var (
	// ErrBlankHandlerContract rejects an inbound handler with no contract code.
	ErrBlankHandlerContract = errors.New("integration: inbound handler declares no contract code")
	// ErrDuplicateHandlerContract rejects two inbound handlers claiming the
	// same contract.
	ErrDuplicateHandlerContract = errors.New("integration: duplicate inbound handler for contract")
)

Registration faults raised while building the inbound handler index; they surface as fx start-up errors.

View Source
var ErrInvalidCodesOption = errors.New("codes: invalid options")

ErrInvalidCodesOption rejects a codes.* options argument: more than one object, an empty object, several keys, a non-true flag, or an unknown key.

Functions

func NewReplayer added in v0.55.0

func NewReplayer(invoker *Invoker, receiver *Receiver) integration.Replayer

NewReplayer creates the replayer over the engine's two execution flows.

func NewTableRouteResolver

func NewTableRouteResolver(db orm.DB) integration.RouteResolver

NewTableRouteResolver builds the table-backed route resolver. Replace it via fx.Decorate when routing lives elsewhere.

Types

type ConnectionCheck

type ConnectionCheck struct {
	HTTP     *HTTPProbe     `json:"http,omitempty"`
	Database *DatabaseProbe `json:"database,omitempty"`
}

ConnectionCheck is the outcome of probing a system's configured transports; each probe is present iff the system configures that transport. Probe failures are data (Reachable=false), not errors — the probe answered the question.

type DatabaseProbe

type DatabaseProbe struct {
	Reachable  bool   `json:"reachable"`
	Version    string `json:"version,omitempty"`
	DurationMs int64  `json:"durationMs"`
	Error      string `json:"error,omitempty"`
}

DatabaseProbe reports one throwaway connection against the system data source, carrying the server version on success.

type DispatchResult added in v0.55.0

type DispatchResult struct {
	Output any    `json:"output,omitempty"`
	Error  string `json:"error,omitempty"`
}

DispatchResult is what the business handler returned for one inbound dispatch: its output, or the message of the error it failed with.

type DryRunResult

type DryRunResult struct {
	Output      any                        `json:"output"`
	Trace       []integration.HTTPExchange `json:"trace"`
	FailureKind integration.FailureKind    `json:"failureKind,omitempty"`
	Error       string                     `json:"error,omitempty"`
}

DryRunResult is the outcome of a DryRun: the trace is populated even when the run failed, so operators see how far the script got.

type HTTPProbe

type HTTPProbe struct {
	Reachable  bool   `json:"reachable"`
	Status     int    `json:"status,omitempty"`
	StatusText string `json:"statusText,omitempty"`
	DurationMs int64  `json:"durationMs"`
	Error      string `json:"error,omitempty"`
}

HTTPProbe reports one probe request against the system base URL.

type InboundDryRunResult

type InboundDryRunResult struct {
	Reply           any                     `json:"reply"`
	DispatchedInput any                     `json:"dispatchedInput"`
	FailureKind     integration.FailureKind `json:"failureKind,omitempty"`
	Error           string                  `json:"error,omitempty"`
}

InboundDryRunResult is the outcome of an inbound DryRun: the reply the external system would receive plus what the script dispatched, so operators verify both translation directions at once.

type InvocationReplay added in v0.55.0

type InvocationReplay struct {
	orm.BaseModel `bun:"table:itg_invocation_replay,alias:ir"`

	ID        string         `bun:"id,pk"`
	Payload   string         `bun:"payload"`
	CreatedAt timex.DateTime `bun:"created_at"`
}

InvocationReplay is the itg_invocation_replay row holding the sealed replay payload of one invocation log entry, keyed by the entry's ID. It lives apart from the log so browsing the log never loads payloads.

type Invoker

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

Invoker executes integration calls end to end: target resolution, input validation, script execution against the system-scoped client, output validation, and outcome recording. It implements integration.Invoker and integration.StatsInspector.

func NewInvoker

func NewInvoker(
	db orm.DB,
	engine *js.Engine,
	registry *auth.OutboundRegistry,
	codec *definition.SecretCodec,
	resolver integration.RouteResolver,
	sources datasource.Registry,
	cfg *config.IntegrationConfig,
) *Invoker

NewInvoker assembles the invoker and its caches.

func (*Invoker) DryRun

func (inv *Invoker) DryRun(ctx context.Context, contract *integration.Contract, system *integration.System, script string, input any) *DryRunResult

DryRun executes script (possibly unsaved) against system under contract, bypassing the adapter table, the response cache, statistics, and the invocation log. It is the test-console entry point; the wire calls it makes are real.

func (*Invoker) Invoke

func (inv *Invoker) Invoke(ctx context.Context, contract string, input any, opts ...integration.InvokeOption) (*integration.Result, error)

Invoke implements integration.Invoker.

func (*Invoker) ReleaseSystem

func (inv *Invoker) ReleaseSystem(ctx context.Context, systemCode string) error

ReleaseSystem drops the datasource registry entry of a deleted system (or one whose data source configuration was removed or renamed).

func (*Invoker) Stats

func (inv *Invoker) Stats() []integration.InvocationStats

Stats implements integration.StatsInspector.

func (*Invoker) TestConnection

func (inv *Invoker) TestConnection(ctx context.Context, system *integration.System, method, path string) (*ConnectionCheck, error)

TestConnection probes system on every transport it configures — the entry point behind a management UI "test connection" button. Configuration faults (unknown auth scheme, undecryptable credential) return an error; any completed probe, whatever its result, reports as data.

type Receiver

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

Receiver is the inbound half of the execution engine: the protocol-blind pipeline every inbound gateway hands its requests to. It verifies the caller against the system's inbound auth, runs the inbound adapter script — which translates the wire request, dispatches the standard input to the registered business handler, and shapes the external-facing reply — and folds the delivery into the shared statistics and invocation log. It deliberately shares the Invoker's execution substrate (definition loading, compiled programs, schema cache, capture policy) instead of duplicating it.

func NewReceiver

func NewReceiver(invoker *Invoker, codec *definition.SecretCodec, schemes *auth.InboundRegistry, handlers []integration.InboundHandler) (*Receiver, error)

NewReceiver assembles the receiver, indexing the registered inbound handlers by contract code and rejecting blank or duplicate registrations at boot.

func (*Receiver) DryRun

func (r *Receiver) DryRun(ctx context.Context, contract *integration.Contract, system *integration.System, script string, req *integration.InboundRequest, handlerOutput any) *InboundDryRunResult

DryRun executes an inbound script (possibly unsaved) against a synthetic request, with the business handler replaced by a stub returning handlerOutput — no business code runs, verification is bypassed (the console tests translation, not credentials), and nothing is recorded to statistics or the invocation log; the contract schemas are enforced for real on both sides of the dispatch.

func (*Receiver) Receive

func (r *Receiver) Receive(ctx context.Context, req *integration.InboundRequest) (any, error)

Receive processes one inbound request end to end and returns the adapter script's reply for the gateway to render. Verification failures return integration.ErrInboundAuthFailed uniformly — the specific reason is recorded server-side only.

type ReplayPayload added in v0.55.0

type ReplayPayload struct {
	Input      any                         `json:"input,omitempty"`
	Request    *integration.InboundRequest `json:"request,omitempty"`
	Dispatches []DispatchResult            `json:"dispatches,omitempty"`
}

ReplayPayload is the lossless material a recorded invocation keeps so it can be re-run: the unmasked contract input of an outbound call, or the external request of an inbound delivery together with what the business handler returned, in dispatch order. Credentials never enter it.

type Replayer added in v0.55.0

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

Replayer implements integration.Replayer over the engine's two execution flows.

func (*Replayer) Replay added in v0.55.0

func (rp *Replayer) Replay(ctx context.Context, logID, script string) (*integration.ReplayResult, error)

Replay re-runs log entry logID; see integration.Replayer.

Jump to

Keyboard shortcuts

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