Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions Sources/Kafka/Configuration/KafkaConsumerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

import Crdkafka
import struct Foundation.UUID

public struct KafkaConsumerConfiguration {
Expand All @@ -25,30 +24,20 @@ public struct KafkaConsumerConfiguration {

/// A struct representing different back pressure strategies for consuming messages in ``KafkaConsumer``.
public struct BackPressureStrategy: Sendable, Hashable {
enum _BackPressureStrategy: Sendable, Hashable {
case watermark(low: Int, high: Int)
}

let _internal: _BackPressureStrategy

private init(backPressureStrategy: _BackPressureStrategy) {
self._internal = backPressureStrategy
}

/// A back pressure strategy based on high and low watermarks.
///
/// The consumer maintains a buffer size between a low watermark and a high watermark
/// to control the flow of incoming messages.
///
/// - Parameter low: The lower threshold for the buffer size (low watermark).
/// - Parameter high: The upper threshold for the buffer size (high watermark).
public static func watermark(low: Int, high: Int) -> BackPressureStrategy {
return .init(backPressureStrategy: .watermark(low: low, high: high))
@available(*, deprecated, message: "Use MessageOptions to control backpressure")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to depreciate stuff here. We aren't 1.0.0 yet so let's just remove it!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed deprecated code.

public static func watermark(low _: Int, high _: Int) -> BackPressureStrategy {
return .init()
}
}

/// The backpressure strategy to be used for message consumption.
/// See ``KafkaConsumerConfiguration/BackPressureStrategy-swift.struct`` for more information.
@available(*, deprecated, message: "Use message.maximumBytes and message.maximumBytesToCopy to control backpressure")
public var backPressureStrategy: BackPressureStrategy = .watermark(
low: 10,
high: 50
Expand Down
Loading