Package ai.tock.bot.connector
Class ConnectorQueue
-
- All Implemented Interfaces:
public final class ConnectorQueueA Queue to ensure the calls from the same user id are sent sequentially.
-
-
Constructor Summary
Constructors Constructor Description ConnectorQueue(Executor executor, InstantSource clock)
-
Method Summary
Modifier and Type Method Description final Unitadd(Action action, Long delayInMs, Function1<Action, Unit> send)Adds an action to send to a queue by recipient. final <T extends Any> Unitadd(Action action, Long delayInMs, Function1<Action, T> prepare, Function1<T, Unit> send)Adds an action to send to a queue by recipient, with a specific prepare step beforehand. -
-
Constructor Detail
-
ConnectorQueue
ConnectorQueue(Executor executor, InstantSource clock)
-
-
Method Detail
-
add
final Unit add(Action action, Long delayInMs, Function1<Action, Unit> send)
Adds an action to send to a queue by recipient.
This method is thread safe.
- Parameters:
action- the action to senddelayInMs- the optional delaysend- the send function
-
add
final <T extends Any> Unit add(Action action, Long delayInMs, Function1<Action, T> prepare, Function1<T, Unit> send)
Adds an action to send to a queue by recipient, with a specific prepare step beforehand.
prepare is run asynchronously as soon as this method is called. send is run once the following preconditions are met:
prepare returned a result. If prepare returns
null, send is not called.delayInMs has passed
the previous message has been sent
This method is thread safe.
- Parameters:
action- the action to senddelayInMs- the optional delaysend- the send function
-
-
-
-