Trait/Object

spinoco.fs2.kafka

KafkaClient

Related Docs: object KafkaClient | package kafka

Permalink

sealed trait KafkaClient[F[_]] extends AnyRef

Client that binds to kafka broker. Usually application need only one client.

Client lives until the emitted process is interrupted, or fails.

Source
KafkaClient.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. KafkaClient
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def leaderFor(delay: FiniteDuration)(topic: @@[String, TopicName], topics: @@[String, TopicName]*): Stream[F, Map[(@@[String, TopicName], @@[Int, PartitionId]), BrokerAddress]]

    Permalink

    Like leaders but queries only for supplied topics

  2. abstract def leaders(delay: FiniteDuration): Stream[F, Map[(@@[String, TopicName], @@[Int, PartitionId]), BrokerAddress]]

    Permalink

    Creates discrete signal of leaders that is queried from periodical query of metadata from brokers.

    Creates discrete signal of leaders that is queried from periodical query of metadata from brokers.

    While this stream is consumed, this will keep connection with very first broker that have answered request for metadata succesfully.

    If there is no broker available to server metadata request (all brokers was failing recently w/o providing valid response), this will fail as NoBrokerAvailable.

    If the broker from which metadata are queried will fail, this will try next broker in supplied seed.

    delay

    Delay to refresh new metadata from last known good broker

  3. abstract def offsetRangeFor(topicId: @@[String, TopicName], partition: @@[Int, PartitionId]): F[(@@[Long, Offset], @@[Long, Offset])]

    Permalink

    Queries offsets for given topic and partition.

    Queries offsets for given topic and partition. Returns offset of first message kept (head) and offset of next message that will arrive to topic. When numbers are equal, then the topic does not include any messages at all.

    topicId

    Id of the topic

    partition

    Id of the partition

  4. abstract def publishN(topicId: @@[String, TopicName], partition: @@[Int, PartitionId], requireQuorum: Boolean, serverAckTimeout: FiniteDuration, compress: Option[protocol.kafka.Compression.Value])(messages: Chunk[(ByteVector, ByteVector)]): F[Long]

    Permalink

    Publishes Chunk of messages to the ensemble.

    Publishes Chunk of messages to the ensemble. The messages are published as a whole batch, so when this terminates, all messages are guaranteed to be processed by kafka server.

    Returns offset of very first message published.

    topicId

    Id of the topic to publish to.

    partition

    Partition to publish to.

    requireQuorum

    If true, this requires quorum of ISR to commit message before leader will reply. If false, only leader is required to confirm this publish request.

    serverAckTimeout

    Defines how long to wait for server to confirm that messages were published. Note that this will fail the resulting task if timeout is exceeded, but that won't guarantee that messages were not published.

    compress

    When defined, messages will be compressed by supplied algorithm.

    messages

    Chunk of messages to publish. First is id of the topic, second is partition, then key and message itself. Additionally A may be passed to pair the offset of the message in resulting chunk.

  5. abstract def publishUnsafeN(topic: @@[String, TopicName], partition: @@[Int, PartitionId], compress: Option[protocol.kafka.Compression.Value])(messages: Chunk[(ByteVector, ByteVector)]): F[Unit]

    Permalink

    Like publishN except this won't await for messages to be confirmed to be published successfully.

    Like publishN except this won't await for messages to be confirmed to be published successfully.

    Note that this does not guarantee that message was even sent to server. It will get queued and will be delivered to server within earliest opportunity (once server will be ready to accept it).

  6. abstract def subscribe(topicId: @@[String, TopicName], partition: @@[Int, PartitionId], offset: @@[Long, Offset], prefetch: Boolean = true, minChunkByteSize: Int = 1, maxChunkByteSize: Int = 1024 * 1024, maxWaitTime: FiniteDuration = 1.minute, leaderFailureTimeout: FiniteDuration = 3.seconds, leaderFailureMaxAttempts: Int = 20): Stream[F, TopicMessage]

    Permalink

    Subscribes to specified topic to receive messages published to that topic.

    Subscribes to specified topic to receive messages published to that topic.

    Essentially this acts sort of unix tail command.

    Note that user can fine-tune reads from topic by specifying minChunkByteSize, maxChunkByteSize and maxWaitTime parameters to optimize chunking and flow control of reads from Kafka. Default values provide polling each 1 minute whenever at least one message is available.

    User can by fine-tuning the maxWaitTime and leaderFailureMaxAttempts recovery in case of leadership changes in kafka cluster.

    For example, when leader fails, the stream will stop for about leaderFailureTimeout and then tries to continue where the last fetch ended. However wehn there are leaderFailureMaxAttempts successive failures, then the stream will fail.

    Setting leaderFailureTimeout to 0 and leaderFailureMaxAttempts to 0 will cause resulting stream to fail immediatelly when any failure occurs.

    topicId

    Name of the topic to subscribe to

    partition

    Partition to subscribe to

    offset

    Offset of the topic to start to read from. First received message may have offset larger than supplied offset only if the oldest message has offset higher than supplied offset. Otherwise this will always return first message with this offset. -1 specified start from tail (new message arriving to topic)

    prefetch

    When true, the implementation will prefetch next chunk of messages from kafka while processing last chunk of messages.

    minChunkByteSize

    Min size of bytes to read from kafka in single attempt. That number of bytes must be available, in order for read to succeed.

    maxChunkByteSize

    Max number of bytes to include in reply. Should be always > than max siz of single message including key.

    maxWaitTime

    Maximum time to wait before reply, even when minChunkByteSize is not satisfied.

    leaderFailureTimeout

    When fetch from Kafka leader fails, this will try to recover connection every this period up to leaderFailureMaxAttempts attempt count is exhausted

    leaderFailureMaxAttempts

    Maximum attempts to recover from leader failure, then this will fail.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to any2stringadd[KafkaClient[F]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (KafkaClient[F], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to ArrowAssoc[KafkaClient[F]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (KafkaClient[F]) ⇒ Boolean, msg: ⇒ Any): KafkaClient[F]

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to Ensuring[KafkaClient[F]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (KafkaClient[F]) ⇒ Boolean): KafkaClient[F]

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to Ensuring[KafkaClient[F]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): KafkaClient[F]

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to Ensuring[KafkaClient[F]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): KafkaClient[F]

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to Ensuring[KafkaClient[F]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to StringFormat[KafkaClient[F]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. def publish1(topicId: @@[String, TopicName], partition: @@[Int, PartitionId], key: ByteVector, message: ByteVector, requireQuorum: Boolean, serverAckTimeout: FiniteDuration): F[Long]

    Permalink

    Publishes single message to the supplied topic.

    Publishes single message to the supplied topic. Returns None, if the message was not published due topic/partition not existent or Some(offset) of published message.

    When F finishes its evaluation, message is guaranteed to be seen by the ensemble.

    topicId

    Topic to publish to

    partition

    Partition to publish to

    key

    Key of the message

    message

    Message itself

    requireQuorum

    If true, this requires quorum of ISR to commit message before leader will reply. If false, only leader is required to confirm this publish request.

    serverAckTimeout

    Timeout server waits for replicas to ack the request. If the publish request won't be acked by server in this time, then the request fails to be published.

  23. def publishUnsafe1(topicId: @@[String, TopicName], partition: @@[Int, PartitionId], key: ByteVector, message: ByteVector): F[Unit]

    Permalink

    Like publish except this won't wait for the confirmation that message was published (fire'n forget).

    Like publish except this won't wait for the confirmation that message was published (fire'n forget).

    Note that this does not guarantee that message was even sent to server. It will get queued and will be delivered to server within earliest opportunity (once server will be ready to accept it).

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. def [B](y: B): (KafkaClient[F], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from KafkaClient[F] to ArrowAssoc[KafkaClient[F]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from KafkaClient[F] to any2stringadd[KafkaClient[F]]

Inherited by implicit conversion StringFormat from KafkaClient[F] to StringFormat[KafkaClient[F]]

Inherited by implicit conversion Ensuring from KafkaClient[F] to Ensuring[KafkaClient[F]]

Inherited by implicit conversion ArrowAssoc from KafkaClient[F] to ArrowAssoc[KafkaClient[F]]

Ungrouped