Package discord4j.gateway.state
Class DispatchStoreLayer
java.lang.Object
discord4j.gateway.state.DispatchStoreLayer
A
DispatchStoreLayer allows to intercept any Dispatch instance and execute the appropriate
StoreAction on a given Store. An instance of DispatchStoreLayer is specific to one shard,
in case of sharded connection to the gateway, a separate DispatchStoreLayer should be created for each of
them. It is completely independent to the gateway client itself, its use is completely optional.-
Method Summary
Modifier and TypeMethodDescriptionstatic DispatchStoreLayerCreates a newDispatchStoreLayeroperating on the given store and shard.Mono<StatefulDispatch<?,?>> store(discord4j.discordjson.json.gateway.Dispatch dispatch) Executes a store action depending on the type of the given dispatch.
-
Method Details
-
create
Creates a newDispatchStoreLayeroperating on the given store and shard.- Parameters:
store- the store to execute actions onshardInfo- the shard info where dispatches are received from- Returns:
- a new
DispatchStoreLayer
-
store
Executes a store action depending on the type of the given dispatch. The dispatch given in argument is assumed to come from the same shard as given when creating thisDispatchStoreLayer. The shard info will be overriden if an instance ofShardAwareDispatchis provided. The result of the store action, which represents the old state of the data affected when applicable, is returned along with the dispatch itself in aStatefulDispatchwhich can be processed downstream.- Parameters:
dispatch- the dispatch to produce the store action for- Returns:
- a
Monowhere, upon successful completion, emits theStatefulDispatchholding the result of the store action execution, if any. If an error occurs during store execution, the error is dropped and logged, and aStatefulDispatchwith empty old state is returned.
-