Skip to content
This repository was archived by the owner on May 18, 2021. It is now read-only.
This repository was archived by the owner on May 18, 2021. It is now read-only.

Provide allOf variant with access to dependent results #95

@zootalures

Description

@zootalures

The current version of allOf does not allow processing of results once they are available (e.g. to implement a reduce operation). It would be useful to provide a variant that allows collect and transform the dependent stage results by the user function.

To achieve this goal, here is a possible extension to FnFlow:

  • New API method in com.fnproject.fn.api.flow.Flow that takes a function argument to transform the results in a lazy batch-oriented fashion:

FlowFuture<X> allResults(Flows.SerFunction<FlowResults, X> fn, FlowFuture<?>... flowFutures);

where the new interfaces FlowResult and FlowResults are defined as follows:

public interface FlowResults extends Serializable {

	/**
	 * Returns an iterator providing access to the results of one or more FlowFutures.
	 *
	 * @param maxBatchSize an upper bound on the number of results to retrieve from the completer in a
	 * single HTTP request. Results are lazily fetched from the completer during iteration and the 
	 * retrieved batch is cached in the runtime for performance.
	 *
	 * @return the iterator over the FlowFuture results
	 */
	Iterator<FlowResult> iterator(int maxBatchSize);

	/** The number of FlowFuture results contained inside this FlowResults instance.
	 * @return number of results available
	 */
	int size();
}

public interface FlowResult extends Serializable {

	/** Returns the completion value of the FlowFuture 
	 * @return the result of the given FlowFuture
	 * @throws FlowCompletionException when this future fails with an exception
	 */
	Object getValue();

	/** TBD - we could return the FlowId along with the result if we decide to 
	 * make them available via the public API
	 * @return the FlowId for the FlowFuture associated with this result
	 */
	FlowId getId();
}
  • The following protocol changes would be required:
    • new operation to get a batch of FlowFuture results (using multipart in response) by FlowIds
    • allResults operation will need to serialize all dependent FlowIds as args to allResults continuation, with the runtime wrapping them inside an instance of the FlowResults interface prior to invoking the user's reduce function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions