Documentation
¶
Index ¶
- Variables
- func CallTimeout(system *integration.System) time.Duration
- func NewTableRouteResolver(db orm.DB) integration.RouteResolver
- type ConnectionCheck
- type DatabaseProbe
- type DryRunResult
- type HTTPProbe
- type InboundDryRunResult
- type Invoker
- func (inv *Invoker) DryRun(ctx context.Context, contract *integration.Contract, ...) *DryRunResult
- func (inv *Invoker) Invoke(ctx context.Context, contract string, input any, ...) (*integration.Result, error)
- func (inv *Invoker) ReleaseSystem(ctx context.Context, systemCode string) error
- func (inv *Invoker) Stats() []integration.InvocationStats
- func (inv *Invoker) TestConnection(ctx context.Context, system *integration.System, method, path string) (*ConnectionCheck, error)
- type Receiver
Constants ¶
This section is empty.
Variables ¶
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") )
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.
Functions ¶
func CallTimeout ¶
func CallTimeout(system *integration.System) time.Duration
CallTimeout returns the per-request timeout of system's client, the bound script-supplied request timeouts may only shorten.
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 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 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 ¶
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.