Skip to content

Interface: ChannelRuntime<Context> ​

What the entrypoint gives an adapter when it starts it (EntrypointAdapter.start): the channel's actions and the functions dispatching the requests to them.

Type Parameters ​

Context ​

Context extends BaseContext = BaseContext

Properties ​

actions ​

readonly actions: readonly ChannelActionInfo[]

The channel's actions, one per address.


channel ​

readonly channel: ChannelDefinition

The adapter's channel.


controllers ​

readonly controllers: readonly IBaseObjectConstructor<Controller>[]

The entrypoint's controller classes, for the channels serving what the controllers declare besides their actions (their prefixes, their metadata).


module ​

readonly module: Module

The module owning the entrypoint (the application).


ready ​

readonly ready: Promise<void>

Resolves once every adapter of the entrypoint started and the application launched (its objects and its bootstrap are ready), for the adapters acting on their own rather than on requests (running a command, triggering the schedules). Without an application (a bare container), it resolves once the entrypoint is initialized.

Methods ​

dispatch() ​

dispatch(context, options?): Promise<unknown>

Dispatch a request to the action it matches: the request runs in a container of its own, through the middlewares, the input validation, the access control and the action. It is tracked as in progress until it ends, so the entrypoint waits for it when it stops.

Parameters ​

context ​

Context

The request's context, of the channel's context class.

options? ​

DispatchOptions

The request's abort signal and address parameters.

Returns ​

Promise<unknown>

The action's result; undefined when the request is aborted by its signal.

Throws ​

The channel's not-found error when no action matches (ControllerActionNotFoundException for the built-in channels), the input validation error, the access control's denial (AccessDeniedException), the error of a middleware or of the action, or EntrypointStoppedException when the entrypoint stopped before the request completed.


dispatchTo() ​

dispatchTo(action, context, options?): Promise<unknown>

Dispatch a request to a given action without matching it, for the channels binding a trigger to each action (schedules, subscriptions); the request runs as with ChannelRuntime.dispatch.

Parameters ​

action ​

ChannelActionInfo

One of the objects of ChannelRuntime.actions (compared by identity, not a copy).

context ​

Context

The request's context, of the channel's context class.

options? ​

DispatchOptions

The request's abort signal and address parameters.

Returns ​

Promise<unknown>

The action's result; undefined when the request is aborted by its signal.

Throws ​

The channel's not-found error when the action is not one of the runtime's, and the errors of ChannelRuntime.dispatch.


getObject() ​

getObject<T>(target): Promise<T>

Get an object from the entrypoint's container, such as a component the adapter uses (an autoloaded class is registered on first use).

Type Parameters ​

T ​

T extends BaseObject

Parameters ​

target ​

string | symbol | IBaseObjectConstructor<T>

The object's registration name or symbol, or its class.

Returns ​

Promise<T>

The object, once created and initialized.

Throws ​

When the object is not registered or fails to be created.

Released under the MIT License.