Class Context
java.lang.Object
services.moleculer.context.ContextSource
services.moleculer.context.Context
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longTimestampfinal StringUnique context IDfinal intRequest level (in nested-calls) - the first level is 1final StringAction namefinal StringSource nodeIDfinal CallOptions.OptionsCalling optionsfinal io.datatree.TreeRequest parameters (includingmeta)final StringParent context ID (in nested-calls)final StringRequest ID (= first context ID)final PacketStreamStreamed contentFields inherited from class ContextSource
eventbus, serviceInvoker, uidGenerator -
Constructor Summary
ConstructorsConstructorDescriptionContext(ServiceInvoker serviceInvoker, Eventbus eventbus, UidGenerator uidGenerator, String id, String name, io.datatree.Tree params, int level, String parentID, String requestID, PacketStream stream, CallOptions.Options opts, String nodeID) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbroadcast(String name, io.datatree.Tree payload, Groups groups, PacketStream stream, CallOptions.Options opts, boolean local) protected io.datatree.Promisecall(String name, io.datatree.Tree params, CallOptions.Options opts, PacketStream stream) Calls an action (local or remote).protected voidemit(String name, io.datatree.Tree payload, Groups groups, PacketStream stream, CallOptions.Options opts) protected io.datatree.TreemergeMeta(io.datatree.Tree newParams) toString()Methods inherited from class ContextSource
broadcast, broadcast, broadcast, broadcast, broadcast, broadcastLocal, broadcastLocal, broadcastLocal, call, call, call, call, call, createStream, emit, emit, emit, emit, emit
-
Field Details
-
id
Unique context ID -
name
Action name -
params
public final io.datatree.Tree paramsRequest parameters (includingmeta) -
level
public final int levelRequest level (in nested-calls) - the first level is 1 -
parentID
Parent context ID (in nested-calls) -
requestID
Request ID (= first context ID) -
stream
Streamed content -
opts
Calling options -
nodeID
Source nodeID -
createdAt
protected final long createdAtTimestamp
-
-
Constructor Details
-
Context
public Context(ServiceInvoker serviceInvoker, Eventbus eventbus, UidGenerator uidGenerator, String id, String name, io.datatree.Tree params, int level, String parentID, String requestID, PacketStream stream, CallOptions.Options opts, String nodeID)
-
-
Method Details
-
emit
protected void emit(String name, io.datatree.Tree payload, Groups groups, PacketStream stream, CallOptions.Options opts) - Overrides:
emitin classContextSource
-
broadcast
protected void broadcast(String name, io.datatree.Tree payload, Groups groups, PacketStream stream, CallOptions.Options opts, boolean local) - Overrides:
broadcastin classContextSource
-
call
protected io.datatree.Promise call(String name, io.datatree.Tree params, CallOptions.Options opts, PacketStream stream) Calls an action (local or remote).- Overrides:
callin classContextSource- Parameters:
name- action name (eg. "math.add" in "service.action" syntax)params-Treestructure (input parameters of the method call)opts- calling options (target nodeID, call timeout, number of retries)stream- streamed data (optional)- Returns:
- response Promise
-
mergeMeta
protected io.datatree.Tree mergeMeta(io.datatree.Tree newParams) -
toString
-