Interface: EntrypointAdapter<Context>
An adapter: a transport receiving a channel's requests (an HTTP server, a CLI parser, a socket server, the scheduler). It is given to the entrypoint options under its channel's key; the entrypoint starts it when it initializes and stops it, then closes it, when it is destroyed. The adapter packages export functions creating them (expressHTTPEntrypoint(), scheduleEntrypoint()…).
Type Parameters
Context
Context extends BaseContext = BaseContext
Properties
channel
readonlychannel:string
The adapter's channel, which is also its key in the entrypoint options.
definition?
readonlyoptionaldefinition?:ChannelDefinition
The channel's definition, defined by the entrypoint before it starts the adapter (for the packages defining their channel with their adapter).
middlewares?
readonlyoptionalmiddlewares?:MiddlewareDefinition[]
The middlewares run around the requests of this adapter, after the entrypoint's and before the controller's and the action's.
name?
readonlyoptionalname?:string
The adapter's name, to tell apart the adapters of a channel.
Methods
broadcast()?
optionalbroadcast(event,args):number
Push an event to every client of the adapter. Called by Entrypoint.broadcast.
Parameters
event
string
The event's name.
args
unknown[]
The arguments given to the clients' listeners.
Returns
number
The number of clients the event was pushed to.
close()?
optionalclose():void|Promise<void>
Release the resources (connections, servers) once the requests in progress ended or were aborted.
Returns
void | Promise<void>
notify()?
optionalnotify(clientId,event,args):boolean
Push an event to a client of the adapter (a window's renderer, a socket); its listeners receive the arguments. Called by Entrypoint.notify.
Parameters
clientId
string
The client's id, as set in its requests' contexts (ServiceContext.clientId).
event
string
The event's name.
args
unknown[]
The arguments given to the client's listeners.
Returns
boolean
Whether the adapter has the client.
start()
start(
runtime):void|Promise<void>
Start receiving requests. The entrypoint starts its adapters one after the other and awaits each; a rejection fails the entrypoint's initialization.
Parameters
runtime
ChannelRuntime<Context>
The channel's actions and the functions dispatching the requests.
Returns
void | Promise<void>
stop()?
optionalstop():void|Promise<void>
Stop receiving requests; the entrypoint then waits for the requests in progress (aborting them after its shutdownTimeout) before it calls EntrypointAdapter.close.
Returns
void | Promise<void>