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

com.kolibrifx.plovercrest.server.streams.StreamEngine 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;

import java.nio.ByteBuffer;
import java.util.Collection;
import com.kolibrifx.common.Disposable;
import com.kolibrifx.plovercrest.server.TableInfo;

/**
 * Pluggable stream abstraction used by Plovercrest servers (and local plovercrest).
 * 

* A {@link Stream} corresponds to a Plovercrest table, which can be backed by a server table ( * {@link com.kolibrifx.plovercrest.server.Table}) or another implementation such as an in-memory * class. To include custom stream types, implement a {@link StreamProvider} and pass it to * {@link PlovercrestStreamEngineBuilder#extraProviders(Collection)}. * * @see PlovercrestStreamEngineBuilder */ public interface StreamEngine extends Disposable { /** * Try to open a stream with the given name. If no such table exists, null is * returned. * * @param elementType * The element class. {@link java.nio.ByteBuffer} is always supported, other types * require a serializer to be registered for the given element type, or a * {@link StreamProvider} that explicitly supports this type. */ Stream open(String name, Class elementType); /** * Convenience function, equivalent to open(name, ByteBuffer.class). */ Stream openRaw(String name); /** * Try to create a new stream with the given metadata. If the function returns without an error, * the stream was created successfully. If not, a * {@link com.kolibrifx.plovercrest.client.PlovercrestException} should be thrown. */ void create(TableInfo info); /** * Try to delete the table with the given name. If no such table exists, or deleting it is not * possible, false is returned. */ boolean delete(String name); /** * Rename an existing table, if possible. Returns true if successful. */ boolean rename(String oldName, String newName); /** * List all available streams. */ Collection list(); /** * Adds a listener for the set of available streams names (or template names). */ Disposable addStreamNamesListener(StreamNamesListener listener); /** * Trigger the listener when the specified stream is created. If the table already exists, the * listener is triggered immediately. The listener is triggered at most once. */ Disposable addCreateListener(String name, StreamCreateListener listener); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy