Skip to content

Instantly share code, notes, and snippets.

@ktoso
Created October 13, 2017 02:28
Show Gist options
  • Save ktoso/787ceaa040eaf474ac093ef0e5fa80f6 to your computer and use it in GitHub Desktop.
Save ktoso/787ceaa040eaf474ac093ef0e5fa80f6 to your computer and use it in GitHub Desktop.
/**
* Returns a Flow.Processor that subscribes to a sequence of Operations and
* produces a sequence of corresponding Submissions. The Operations must be
* members of this OperationGroup. Calling Subscription.onNext with any
* Operation that is not a member of this OperationGroup, that is was not
* created by calling one of the Operation factory methods on this
* OperationGroup, will cause the Subscription to be canceled and call
* Subscriber.onError with IllegalArgumentException. The method
* Subscription.onNext will call submit on each Operation it is passed and
* publish the resulting Submission. Since an Operation can only be submitted
* once, submitting an Operation and calling onNext with that submitted
* Operation will cause the Subscription to be canceled and Subscriber.onError
* to be called with IllegalStateException. The Processor does not retain
* Submissions to produce to a subsequently attached Subscriber.
*
* If there is no Subscriber to the Processor, the Processor will request
* Operations as appropriate. If there is a Subscriber to the Processor, the
* Processor will request Operations no faster than the Subscriber requests
* Submissions.
*
* Each call to this method returns a new Flow.processor. The Submissions
* published to each Processor are exactly those generated by calling submit
* on the Operations passed as arguments to onNext on the same Processor.
*
* If there are multiple active operationProcessors on a single Connection
* the Connection will as much as possible keep the demand on all Publishers
* the same. In particular, if the Connection can accept more Operations then
* the demand on all Publishers should be greater than 0.
*
* Note: If any Operation is submitted directly, that is by calling submit
* rather than passing it to onNext, the Submission returned by the submit
* call will not be published.
*
* @return a Flow.Processor that accepts Operations and generates Submissions
*/
public Flow.Processor<Operation<T>, Submission<T>> operationProcessor();
And here is a very rough draft of a RowProcessorOperation
public interface RowProcessorOperation<T> extends ParameterizedOperation<T> {
/** DRAFT
* Accepts a Processor that subscribes to a sequence of Rows and publishes
* a sequence of result values. The last result value published is the result
* of the Operation.
*
* The result of this Operation is the last value passed to the onNext method
* of the Subscriber passed to rowProcessor.subscribe.If onComplete
* is called before any value is passed to onNext this Operation is completed
* with null. If onError is called this Operation completes exceptionally
* with the passed exception. If neither onComplete or onError is called
* this Operation does not complete.
*
* Calling Row.cancel is the same as calling Subscription.cancel on the
* Subscription associated with the Row publisher.
*
* @param rowProcessor
* @return this RowProcessorOperation
*/
public RowProcessorOperation<T> rowProcessor(Flow.Processor<Result.Row, T> rowProcessor);
// plus lots of covariant overrides: onError, set, etc
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment