Package com.cognite.client.stream
Class Publisher<T>
java.lang.Object
com.cognite.client.stream.AbstractPublisher
com.cognite.client.stream.Publisher<T>
- Type Parameters:
T-
-
Field Summary
Fields inherited from class com.cognite.client.stream.AbstractPublisher
abortStream, DEFAULT_POLLING_INTERVAL, DEFAULT_POLLING_OFFSET, LOG, MAX_END_TIME, MAX_POLLING_INTERVAL, MAX_POLLING_OFFSET, MIN_POLLING_INTERVAL, MIN_POLLING_OFFSET, MIN_START_TIME, state -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Publisher<T>of(ListSource<T> listSource) withConsumer(Consumer<List<T>> consumer) Add the consumer of the data stream.withEndTime(Instant endTime) Sets the end time (i.e.withPollingInterval(Duration interval) Sets the polling interval to check for updates to the source raw table.withPollingOffset(Duration interval) Sets the polling offset.withRequest(Request request) Sets a baselineRequestto use when producing the steam of objects.withStartTime(Instant startTime) Sets the start time (i.e.Methods inherited from class com.cognite.client.stream.AbstractPublisher
abort, getEndTime, getPollingInterval, getPollingOffset, getStartTime, start
-
Constructor Details
-
Publisher
public Publisher()
-
-
Method Details
-
of
-
withConsumer
Add the consumer of the data stream. The consumer will be called for each batch ofT. This is potentially a blocking operation, so you should take care to process the batch efficiently (or spin off processing to a separate thread).- Parameters:
consumer- The function to call for each batch ofT.- Returns:
- The
Publisherwith the consumer configured.
-
withStartTime
Sets the start time (i.e. the earliest possible created/changed time of the CDF Raw Row) of the data stream. The default start time is at Unix epoch. I.e. the publisher will read all existing rows (if any) in the raw table.- Parameters:
startTime- The start time instant- Returns:
- The
Publisherwith the consumer configured.
-
withEndTime
Sets the end time (i.e. the latest possible created/changed time of the CDF Raw Row) of the data stream. The default end time isInstant.MAX. I.e. the publisher will stream data indefinitely, or until aborted.- Parameters:
endTime- The end time instant- Returns:
- The
Publisherwith the consumer configured.
-
withPollingInterval
Sets the polling interval to check for updates to the source raw table. The default polling interval is every 5 seconds. You can configure a more or less frequent interval, down to every 0.5 seconds.- Parameters:
interval- The interval to check the source raw table for updates.- Returns:
- The
Publisherwith the consumer configured.
-
withPollingOffset
Sets the polling offset. The offset is a time window "buffer" subtracted from the current time when polling for data from CDF Raw. It is intended as a safeguard for clock differences between the client (running this publisher) and the CDF service. For example, if the polling offset is 2 seconds, then this publisher will look for data updates up to (and including) T-2 seconds. That is, data will be streamed with a 2 second fixed latency/delay.- Parameters:
interval- The interval to check the source raw table for updates.- Returns:
- The
Publisherwith the consumer configured.
-
withRequest
Sets a baselineRequestto use when producing the steam of objects. TheRequestcontains the set of filters that you want the (stream) objects to satisfy.- Parameters:
request- The baseline request specifying filters for the object stream.- Returns:
- The
Publisherwith the consumer configured.
-