case class Subscriptions(baseUri: URI, oAuth2TokenProvider: Option[OAuth2TokenProvider] = None)(implicit kanadiHttpConfig: HttpConfig, http: HttpExt, materializer: Materializer) extends Product with Serializable
- Alphabetic
- By Inheritance
- Subscriptions
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Subscriptions(baseUri: URI, oAuth2TokenProvider: Option[OAuth2TokenProvider] = None)(implicit kanadiHttpConfig: HttpConfig, http: HttpExt, materializer: Materializer)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addStreamToKillSwitch(subscriptionId: SubscriptionId, streamId: StreamId, uniqueKillSwitch: UniqueKillSwitch): Unit
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- val baseUri: URI
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
closeHttpConnection(subscriptionId: SubscriptionId, streamId: StreamId): Boolean
Closes the underlying http connection for a subscriptionId/streamId.
Closes the underlying http connection for a subscriptionId/streamId.
- returns
trueIf there was a reference to a connection (i.e. there was a stream running) orfalseif there was no reference. Note that cancelling the http connection will execute the eventsStreamed#connectionClosedCallback
- def combinedJsonParserGraph[T](implicit decoder: Decoder[List[Event[T]]]): Graph[FlowShape[ByteString, Either[Throwable, SubscriptionEvent[T]]], NotUsed]
-
def
commitCursors(subscriptionId: SubscriptionId, subscriptionCursor: SubscriptionCursor, streamId: StreamId)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Option[CommitCursorResponse]]
Endpoint for committing offsets of the subscription.
Endpoint for committing offsets of the subscription. If there is uncommited data, and no commits happen for 60 seconds, then Nakadi will consider the client to be gone, and will close the connection. As long as no events are sent, the client does not need to commit.
If the connection is closed, the client has 60 seconds to commit the events it received, from the moment they were sent. After that, the connection will be considered closed, and it will not be possible to do commit with that X-Nakadi-StreamId anymore.
When a batch is committed that also automatically commits all previous batches that were sent in a stream for this partition.
- subscriptionId
Id of subscription
- streamId
Id of stream which client uses to read events. It is not possible to make a commit for a terminated or none-existing stream. Also the client can't commit something which was not sent to his stream.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
def
create(subscription: Subscription)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Subscription]
This endpoint creates a subscription for org.zalando.kanadi.models.EventTypeName's.
This endpoint creates a subscription for org.zalando.kanadi.models.EventTypeName's. The subscription is needed to be able to consume events from EventTypes in a high level way when Nakadi stores the offsets and manages the rebalancing of consuming clients. The subscription is identified by its key parameters (owning_application, event_types, consumer_group). If this endpoint is invoked several times with the same key subscription properties in body (order of even_types is not important) - the subscription will be created only once and for all other calls it will just return the subscription that was already created.
- subscription
Subscription is a high level consumption unit. Subscriptions allow applications to easily scale the number of clients by managing consumed event offsets and distributing load between instances. The key properties that identify subscription are owningApplication, eventTypes and consumerGroup. It's not possible to have two different subscriptions with these properties being the same.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
def
createIfDoesntExist(subscription: Subscription)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Subscription]
Attempts to create a subscription if it doesn't already exist, else it will return the currently existing subscription
Attempts to create a subscription if it doesn't already exist, else it will return the currently existing subscription
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
def
cursors(subscriptionId: SubscriptionId)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Option[SubscriptionCursor]]
Exposes the currently committed offsets of a subscription.
Exposes the currently committed offsets of a subscription.
- subscriptionId
Id of subscription.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
def
delete(subscriptionId: SubscriptionId)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Unit]
Deletes a subscription.
Deletes a subscription.
- subscriptionId
Id of subscription.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
eventsStreamed[T](subscriptionId: SubscriptionId, eventCallback: EventCallback[T], connectionClosedCallback: ConnectionClosedCallback = ..., streamConfig: StreamConfig = Subscriptions.StreamConfig(), modifySourceFunction: Option[(Source[SubscriptionEvent[T], UniqueKillSwitch]) ⇒ Source[SubscriptionEvent[T], UniqueKillSwitch]] = None)(implicit decoder: Decoder[List[Event[T]]], flowId: FlowId = randomFlowId(), executionContext: ExecutionContext, eventStreamSupervisionDecider: EventStreamSupervisionDecider): Future[StreamId]
Starts a new stream for reading events from this subscription.
Starts a new stream for reading events from this subscription. The data will be automatically rebalanced between streams of one subscription. The minimal consumption unit is a partition, so it is possible to start as many streams as the total number of partitions in event-types of this subscription. The rebalance currently only operates with the number of partitions so the amount of data in event-types/partitions is not considered during autorebalance. The position of the consumption is managed by Nakadi. The client is required to commit the cursors he gets in a stream.
This call lets you register a callback which gets execute every time an event is streamed. There are different types of callbacks depending on how you want to handle failure. The timeout for the akka http request is the same as streamTimeout with a small buffer. Note that typically clients should be using eventsStreamedManaged as this will handle disconnects/reconnects
- subscriptionId
Id of subscription.
- eventCallback
The callback which gets executed every time an event is processed via the stream
- connectionClosedCallback
The callback which gets executed when the connection is closed, you typically want to reopen the subscription
- streamConfig
Configuration for the stream
- modifySourceFunction
Allows you to specify a function which modifies the underlying stream
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
- eventStreamSupervisionDecider
The supervision decider which decides what to do when an error is thrown in the stream. Default behaviour is if its a JSON Circe decoding exception on event data, it will commit the cursor, log the error and resume the stream, otherwise it will log the error and restart the stream.
- returns
The StreamId for this Stream
-
def
eventsStreamedManaged[T](subscriptionId: SubscriptionId, eventCallback: EventCallback[T], connectionClosedCallback: ConnectionClosedCallback = ..., streamConfig: StreamConfig = Subscriptions.StreamConfig(), modifySourceFunction: Option[(Source[SubscriptionEvent[T], UniqueKillSwitch]) ⇒ Source[SubscriptionEvent[T], UniqueKillSwitch]] = None)(implicit decoder: Decoder[List[Event[T]]], flowId: FlowId = randomFlowId(), executionContext: ExecutionContext, eventStreamSupervisionDecider: EventStreamSupervisionDecider): Future[StreamId]
Creates an event stream using eventsStreamed however also manages disconnects and reconnects from the server.
Creates an event stream using eventsStreamed however also manages disconnects and reconnects from the server. Typically clients want to use this as they don't need to handle these situations manually.
This uses akka.pattern.after to recreate the streams in the case of server disconnects/no empty slots and cursor resets. The timeouts respectively can be configured with HttpConfig.serverDisconnectRetryDelay and HttpConfig.noEmptySlotsCursorResetRetryDelay. The
connectionClosedCallbackparameter is still respected.NOTE: If the connection is closed by the client explicitly using the closeHttpConnection method then eventsStreamedManaged will not re-establish a connection.
- subscriptionId
Id of subscription.
- eventCallback
The callback which gets executed every time an event is processed via the stream
- connectionClosedCallback
The callback which gets executed when the connection is closed, you typically want to reopen the subscription. NOTE: Don't use the parameter to reconnect the stream, this is automatically handled
- streamConfig
Configuration for the stream
- modifySourceFunction
Allows you to specify a function which modifies the underlying stream
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
- eventStreamSupervisionDecider
The supervision decider which decides what to do when an error is thrown in the stream. Default behaviour is if its a JSON Circe decoding exception on event data, it will commit the cursor, log the error and resume the stream, otherwise it will log the error and restart the stream.
- returns
Initial Stream Id
-
def
eventsStreamedSource[T](subscriptionId: SubscriptionId, connectionClosedCallback: ConnectionClosedCallback = ..., streamConfig: StreamConfig = Subscriptions.StreamConfig())(implicit decoder: Decoder[List[Event[T]]], flowId: FlowId, executionContext: ExecutionContext, eventStreamSupervisionDecider: EventStreamSupervisionDecider): Future[NakadiSource[T]]
Starts a new stream for reading events from this subscription.
Starts a new stream for reading events from this subscription. The data will be automatically rebalanced between streams of one subscription. The minimal consumption unit is a partition, so it is possible to start as many streams as the total number of partitions in event-types of this subscription. The rebalance currently only operates with the number of partitions so the amount of data in event-types/partitions is not considered during autorebalance. The position of the consumption is managed by Nakadi. The client is required to commit the cursors he gets in a stream.
This exposes the stream as a Source, which also means you need to handle adding the stream to the kill switch configuration using the addStreamToKillSwitch method if you plan on using the closeHttpConnection to kill a stream.
- def eventsStreamedSourceManaged[T](subscriptionId: SubscriptionId, connectionClosedCallback: ConnectionClosedCallback = ..., streamConfig: StreamConfig = Subscriptions.StreamConfig())(implicit decoder: Decoder[List[Event[T]]], flowId: FlowId, executionContext: ExecutionContext, eventStreamSupervisionDecider: EventStreamSupervisionDecider): Future[NakadiSource[T]]
-
def
eventsStrictUnsafe[T](subscriptionId: SubscriptionId, maxUncommittedEvents: Option[Int] = None, batchLimit: Option[Int] = None, streamLimit: Option[Int] = None, batchFlushTimeout: Option[FiniteDuration] = None, streamTimeout: Option[FiniteDuration] = None, streamKeepAliveLimit: Option[Int] = None)(implicit decoder: Decoder[List[Event[T]]], flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[List[SubscriptionEvent[T]]]
NOTE: This is the strict version of eventsStreamed, unless you know what you are doing, you should only be using this method for debugging purposes.
NOTE: This is the strict version of eventsStreamed, unless you know what you are doing, you should only be using this method for debugging purposes. If you don't set streamTimeout, this function will never complete, and you will likely run out of memory on your machine.
- subscriptionId
Id of subscription.
- maxUncommittedEvents
The amount of uncommitted events Nakadi will stream before pausing the stream. When in paused state and commit comes - the stream will resume. Minimal value is 1.
- batchLimit
Maximum number of SubscriptionEvent's in each chunk (and therefore per partition) of the stream. If 0 or unspecified will buffer Events indefinitely and flush on reaching of batchFlushTimeout
- streamLimit
Maximum number of SubscriptionEvent's in this stream (over all partitions being streamed in this connection). If 0 or undefined, will stream batches indefinitely. Stream initialization will fail if streamLimit is lower than batchLimit.
- batchFlushTimeout
Maximum time in seconds to wait for the flushing of each chunk (per partition). If the amount of buffered Events reaches batchLimit before this batchFlushTimeout is reached, the messages are immediately flushed to the client and batch flush timer is reset. If 0 or undefined, will assume 30 seconds.
- streamTimeout
Maximum time in seconds a stream will live before connection is closed by the server. If 0 or unspecified will stream indefinitely. If this timeout is reached, any pending messages (in the sense of stream_limit) will be flushed to the client. Stream initialization will fail if streamTimeout is lower than batchFlushTimeout.
- streamKeepAliveLimit
Maximum number of empty keep alive batches to get in a row before closing the connection. If 0 or undefined will send keep alive messages indefinitely.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
get(subscriptionId: SubscriptionId)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Option[Subscription]]
Returns a subscription identified by id.
Returns a subscription identified by id.
- subscriptionId
Id of subscription.
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
list(owningApplication: Option[String] = None, eventType: Option[List[EventTypeName]] = None, limit: Option[Int] = None, offset: Option[Int] = None)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[SubscriptionQuery]
Lists all subscriptions that exist in a system.
Lists all subscriptions that exist in a system. List is ordered by creation date/time descending (newest subscriptions come first).
- owningApplication
Parameter to filter subscriptions list by owning application. If not specified - the result list will contain subscriptions of all owning applications.
- eventType
Parameter to filter subscriptions list by event types. If not specified - the result list will contain subscriptions for all event types. It's possible to provide multiple values like
List(EventTypeName("et1"),EventTypeName("et2")), in this case it will show subscriptions having both "et1" and "et2"- limit
maximum number of subscriptions retuned in one page
- offset
page offset
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
val
logger: LoggerTakingImplicit[FlowId]
- Attributes
- protected
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val oAuth2TokenProvider: Option[OAuth2TokenProvider]
- def resetCursors(subscriptionId: SubscriptionId, subscriptionCursor: Option[SubscriptionCursor] = None)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Boolean]
-
def
stats(subscriptionId: SubscriptionId)(implicit flowId: FlowId = randomFlowId(), executionContext: ExecutionContext): Future[Option[SubscriptionStats]]
exposes statistics of specified subscription
exposes statistics of specified subscription
- subscriptionId
Id of subscription
- flowId
The flow id of the request, which is written into the logs and passed to called services. Helpful for operational troubleshooting and log analysis.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )