public interface ClientFactory
extends java.lang.AutoCloseable
Events that are written to a stream can be read by a reader. All events can be processed with
exactly once semantics provided the reader has the ability to restore to the correct position
upon failure. See EventRead.getPosition()
A note on ordering: Events inside of a stream have a strict order, but may need to be divided
between multiple readers for scaling. In order to process events in parallel on different hosts
and still have some ordering guarantees; events written to a stream have a routingKey see
EventStreamWriter.writeEvent(String, Object)
. Events within a routing key are strictly
ordered (i.e. They must go the the same reader or its replacement). However because
ReaderGroup
s process events in parallel there is no ordering between different readers.
A note on scaling: Because a stream can grow in its event rate, streams are divided into Segments. For the most part this is an implementation detail. However its worth understanding that the way a stream is divided between multiple readers in a group that wish to split the messages between them is by giving different segments to different readers.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the client factory.
|
BatchClient |
createBatchClient()
Create a new batch client.
|
<T> EventStreamWriter<T> |
createEventWriter(java.lang.String streamName,
Serializer<T> s,
EventWriterConfig config)
Creates a new writer that can write to the specified stream.
|
<T> EventStreamReader<T> |
createReader(java.lang.String readerId,
java.lang.String readerGroup,
Serializer<T> s,
ReaderConfig config)
Creates (or recreates) a new reader that is part of a
ReaderGroup . |
<T> RevisionedStreamClient<T> |
createRevisionedStreamClient(java.lang.String streamName,
Serializer<T> serializer,
SynchronizerConfig config)
Creates a new RevisionedStreamClient that will work with the specified stream.
|
<StateT extends Revisioned,UpdateT extends Update<StateT>,InitT extends InitialUpdate<StateT>> |
createStateSynchronizer(java.lang.String streamName,
Serializer<UpdateT> updateSerializer,
Serializer<InitT> initSerializer,
SynchronizerConfig config)
Creates a new StateSynchronizer that will work on the specified stream.
|
static ClientFactory |
withScope(java.lang.String scope,
ClientConfig config)
Creates a new instance of Client Factory.
|
static ClientFactory |
withScope(java.lang.String scope,
java.net.URI controllerUri)
Creates a new instance of Client Factory.
|
static ClientFactory withScope(java.lang.String scope, java.net.URI controllerUri)
scope
- The scope string.controllerUri
- The URI for controller.static ClientFactory withScope(java.lang.String scope, ClientConfig config)
scope
- The scope string.config
- Configuration for the client.<T> EventStreamWriter<T> createEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
T
- The type of events.streamName
- The name of the stream to write to.config
- The writer configuration.s
- The Serializer.<T> EventStreamReader<T> createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config)
ReaderGroup
. The reader
will join the group and the members of the group will automatically rebalance among
themselves.
In the event that the reader dies, the method ReaderGroup.readerOffline(String, Position)
should be called, passing the last position of the reader. (Usually done by storing the
position along with the output when it is processed.) Which will trigger redistribute the
events among the remaining readers.
Note that calling reader offline while the reader is still online may result in multiple reader within the group receiving the same events.
T
- The type of events.readerId
- A unique name (within the group) for this readers.readerGroup
- The name of the group to join.s
- The serializer for events.config
- The readers configuration.<T> RevisionedStreamClient<T> createRevisionedStreamClient(java.lang.String streamName, Serializer<T> serializer, SynchronizerConfig config)
T
- The type of eventsstreamName
- The name of the stream for the synchronizerserializer
- The serializer for updates.config
- The client configuration<StateT extends Revisioned,UpdateT extends Update<StateT>,InitT extends InitialUpdate<StateT>> StateSynchronizer<StateT> createStateSynchronizer(java.lang.String streamName, Serializer<UpdateT> updateSerializer, Serializer<InitT> initSerializer, SynchronizerConfig config)
StateT
- The type of the state being synchronized.UpdateT
- The type of the updates being written.InitT
- The type of the initial update used.streamName
- The name of the stream for the synchronizerupdateSerializer
- The serializer for updates.initSerializer
- The serializer for the initial update.config
- The synchronizer configuration@Beta BatchClient createBatchClient()
void close()
close
in interface java.lang.AutoCloseable
AutoCloseable.close()