All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.streams.folds.FoldSetup Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
 */

package com.kolibrifx.plovercrest.server.streams.folds;

import java.util.List;
import com.kolibrifx.plovercrest.server.internal.folds.FoldReaderSetup;
import com.kolibrifx.plovercrest.server.internal.folds.FoldWriter;
import com.kolibrifx.plovercrest.server.streams.Stream;

/**
 * This interface represents the glue for integrating specific fold types into the Plovercrest
 * stream system.
 *
 * @param 
 *            the output stream type.
 * @param 
 *            the common supertype of the input streams, or {@link Object} if there is no common
 *            type.
 */
public interface FoldSetup {
    /**
     * Called each time a new read request (or subscription) is initialized. Must return a new
     * {@link FoldReaderSetup} object that is passed to the (internal) reader implementation.
     * 

* The crucial part is the {@link com.kolibrifx.plovercrest.server.internal.folds.FoldCallback} * , which is invoked each time a new data element is retrieved from one of the input streams. * Implementors should invoke the fold code here, and add the timestamped result (if any) to the * output queue. */ FoldReaderSetup setupReader(long timestamp, FoldWriter foldOutput, List> inputStreams); /** * Calculate the last output timestamp from the input streams. The combinator strategy can be * taken into consideration. */ long getLastOutputTimestamp(List> inputStreams, CombinatorStrategy combinatorStrategy); }