Package discord4j.gateway.state
Class DispatchStoreLayer
- java.lang.Object
-
- discord4j.gateway.state.DispatchStoreLayer
-
public class DispatchStoreLayer extends Object
ADispatchStoreLayerallows to intercept anyDispatchinstance and execute the appropriateStoreActionon a givenStore. An instance ofDispatchStoreLayeris specific to one shard, in case of sharded connection to the gateway, a separateDispatchStoreLayershould be created for each of them. It is completely independent to the gateway client itself, its use is completely optional.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DispatchStoreLayercreate(Store store, ShardInfo shardInfo)Creates 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 Detail
-
create
public static DispatchStoreLayer create(Store store, ShardInfo shardInfo)
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
public Mono<StatefulDispatch<?,?>> store(discord4j.discordjson.json.gateway.Dispatch dispatch)
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.
-
-