Class SplittingFlushStrategy
- java.lang.Object
-
- io.servicetalk.transport.netty.internal.SplittingFlushStrategy
-
- All Implemented Interfaces:
FlushStrategy
public final class SplittingFlushStrategy extends java.lang.Object implements FlushStrategy
AFlushStrategythat splits writes into logical write boundaries and manages flush state across those logical write boundaries. Actual flush logic is delegated to an externally provided (and updatable)FlushStrategy.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSplittingFlushStrategy.FlushBoundaryProviderA provider ofSplittingFlushStrategy.FlushBoundaryProvider.FlushBoundaryfor each written item.-
Nested classes/interfaces inherited from interface io.servicetalk.transport.netty.internal.FlushStrategy
FlushStrategy.FlushSender, FlushStrategy.WriteEventsListener
-
-
Constructor Summary
Constructors Constructor Description SplittingFlushStrategy(FlushStrategy delegate, SplittingFlushStrategy.FlushBoundaryProvider boundaryProvider)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FlushStrategy.WriteEventsListenerapply(FlushStrategy.FlushSender sender)Every time a new write that requires custom flushes is initiated, this method is invoked.booleanshouldFlushOnUnwritable()Returnstrueif pending writes, if any, MUST be flushed when the connection is not writable.CancellableupdateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)Updates theFlushStrategythat is used for flushing each delineated write boundary.voidupdateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider, int boundariesTillCancel)Updates theFlushStrategythat is used for flushing each delineated write boundary.
-
-
-
Constructor Detail
-
SplittingFlushStrategy
public SplittingFlushStrategy(FlushStrategy delegate, SplittingFlushStrategy.FlushBoundaryProvider boundaryProvider)
Create a new instance.- Parameters:
delegate-FlushStrategyto use for flushing each delineated write boundary.boundaryProvider-SplittingFlushStrategy.FlushBoundaryProviderto provideSplittingFlushStrategy.FlushBoundaryProvider.FlushBoundaryto delineate writes.
-
-
Method Detail
-
apply
public FlushStrategy.WriteEventsListener apply(FlushStrategy.FlushSender sender)
Description copied from interface:FlushStrategyEvery time a new write that requires custom flushes is initiated, this method is invoked. PassedFlushStrategy.FlushSenderis used tosignalto the connection that writes should now be flushed.- Specified by:
applyin interfaceFlushStrategy- Parameters:
sender-FlushStrategy.FlushSenderto signal flushes to the connection.- Returns:
FlushStrategy.WriteEventsListenerthat would listen to write events on the connection for which custom flushes are required.
-
shouldFlushOnUnwritable
public boolean shouldFlushOnUnwritable()
Description copied from interface:FlushStrategyReturnstrueif pending writes, if any, MUST be flushed when the connection is not writable.This method is expected to be idempotent.
- Specified by:
shouldFlushOnUnwritablein interfaceFlushStrategy- Returns:
trueif pending writes, if any, MUST be flushed when the connection is not writable.
-
updateFlushStrategy
public Cancellable updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)
Updates theFlushStrategythat is used for flushing each delineated write boundary.- Parameters:
strategyProvider-NettyConnectionContext.FlushStrategyProviderto provide theFlushStrategyto use.- Returns:
- A
Cancellablethat will cancel this update.
-
updateFlushStrategy
public void updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider, int boundariesTillCancel)
Updates theFlushStrategythat is used for flushing each delineated write boundary. This update will automatically be cancelled after it has been applied toboundariesTillCanceldelineated write boundaries.- Parameters:
strategyProvider-NettyConnectionContext.FlushStrategyProviderto provide theFlushStrategyto use.boundariesTillCancel- Number of delineated write boundaries to apply this flush on.
-
-