Interface TransactionalSubscriber<V>
-
- Type Parameters:
V
- The value handled by this subscriber
- All Superinterfaces:
Subscriber<V>
- All Known Subinterfaces:
Processor.Transactional<I,O>
,Processor.TransactionalIso<V>
public interface TransactionalSubscriber<V> extends Subscriber<V>
A subscriber that is transaction-aware. As opposed to standard Subscribers which receive simple value events, transactional subscribers receive a series of events: first, abeginTransaction
, followed by acommit
orrollback
.A transactional subscriber will only be fully effective when controlled by a
transaction-aware publisher
. A transaction-aware publisher will roll back all subscribers if the transaction fails on any one subscriber, where a standard publisher will not.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
beginTransaction(V newValue)
Receive a new value, and validate it.void
commit()
Expose a transaction's resultvoid
rollback()
Called when a transaction has failed, to revert any prepared changesdefault void
submit(V item)
Called to submit a new item-
Methods inherited from interface ninja.leaping.configurate.reactive.Subscriber
onClose, onError
-
-
-
-
Method Detail
-
submit
default void submit(V item)
Description copied from interface:Subscriber
Called to submit a new item- Specified by:
submit
in interfaceSubscriber<V>
- Parameters:
item
- The item available
-
beginTransaction
void beginTransaction(V newValue) throws TransactionFailedException
Receive a new value, and validate it. The received value must not be made available outside of to other transaction-aware viewers untilcommit()
has been called.- Parameters:
newValue
- The new value- Throws:
TransactionFailedException
- if the new value does not validate
-
commit
void commit()
Expose a transaction's resultThis method will be called on all transactional subscribers in a system have received and validated any new data. Calling this method when a transaction is not in progress should result in a noop.
-
rollback
void rollback()
Called when a transaction has failed, to revert any prepared changesThis event indicates that it is safe for clients to discard any prepared information from an in-progress transaction. If there is no transaction in progress, this must be a no-op.
-
-