|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the swift-kafka-gsoc open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2022 Apple Inc. and the swift-kafka-gsoc project authors |
| 6 | +// Licensed under Apache License v2.0 |
| 7 | +// |
| 8 | +// See LICENSE.txt for license information |
| 9 | +// See CONTRIBUTORS.txt for the list of swift-kafka-gsoc project authors |
| 10 | +// |
| 11 | +// SPDX-License-Identifier: Apache-2.0 |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +// TODO: getter for internal dict representation |
| 16 | +// TODO: Array to comma separated string |
| 17 | +// TODO: default values |
| 18 | +// TODO: dict add manually by key (unsafe api)? |
| 19 | +// TODO: support PEMs? |
| 20 | +// TODO: support OAuth? |
| 21 | +// TODO: List continues at group.id |
| 22 | +// TODO: DocC: inherit documentation? |
| 23 | +// TODO: DocC: take from lirbdkafka official documentation |
| 24 | +// TODO: Topic config -> see KafkaConfig in SwiftKafka |
| 25 | +// TODO: make IPAddressFamily etc. part of some ConfigProperty like type to avoid cluttering docc |
| 26 | +protocol ClientConfig: Hashable, Equatable { |
| 27 | + var clientID: String { get set } |
| 28 | + |
| 29 | + var bootstrapServers: [String] { get set } |
| 30 | + |
| 31 | + var messageMaxBytes: UInt { get set } |
| 32 | + var messageCopyMaxBytes: UInt { get set } |
| 33 | + |
| 34 | + var recieveMessageMaxBytes: UInt { get set } |
| 35 | + var maxInFlightRequestsPerConnection: UInt { get set } |
| 36 | + var metadataMaxAgeMs: UInt { get set } |
| 37 | + |
| 38 | + var topicMetadataRefreshIntervalMs: Int { get set } |
| 39 | + var topicMetadataRefreshFastIntervalMs: UInt { get set } |
| 40 | + var topicMetadataRefreshSparse: Bool { get set } |
| 41 | + var topicMetadataPropagationMaxMs: UInt { get set } // TODO: needed? |
| 42 | + var topicDenylist: [String] { get set } // TODO: is blacklist actually + property needed? |
| 43 | + |
| 44 | + var debug: [DebugOption] { get set } |
| 45 | + |
| 46 | + var socketTimeoutMs: UInt { get set } |
| 47 | + var socketSendBufferBytes: UInt { get set } |
| 48 | + var socketReceiveBufferBytes: UInt { get set } |
| 49 | + var socketKeepaliveEnable: Bool { get set } |
| 50 | + var socketNagleDisable: Bool { get set } |
| 51 | + var socketMaxFails: UInt { get set } |
| 52 | + var socketConnectionSetupTimeoutMs: UInt { get set } // TODO: needed? if not also delete in implementing structs |
| 53 | + |
| 54 | + var brokerAddressTTL: UInt { get set } // TODO: needed? |
| 55 | + var brokerAddressFamily: IPAddressFamily { get set } |
| 56 | + |
| 57 | + var reconnectBackoffMs: UInt { get set } |
| 58 | + var reconnectBackoffMaxMs: UInt { get set } |
| 59 | + |
| 60 | + var allowAutoCreateTopics: Bool { get set } // TODO: needed? |
| 61 | + |
| 62 | + var securityProtocol: SecurityProtocol { get set } |
| 63 | + |
| 64 | + var sslKeyLocation: String { get set } |
| 65 | + var sslKeyPassword: String { get set } |
| 66 | + var sslCertificateLocation: String { get set } |
| 67 | + var sslCALocation: String { get set } |
| 68 | + var sslCRLLocation: String { get set } |
| 69 | + var sslKeystoreLocation: String { get set } |
| 70 | + var sslKeystorePassword: String { get set } |
| 71 | + |
| 72 | + var saslMechanism: SASLMechanism { get set } |
| 73 | + var saslUsername: String { get set } |
| 74 | + var saslPassword: String { get set } |
| 75 | +} |
| 76 | + |
| 77 | +// MARK: - Auxiliary Types |
| 78 | + |
| 79 | +public struct DebugOption: Hashable, Equatable, CustomStringConvertible { |
| 80 | + public let description: String |
| 81 | + |
| 82 | + public static let generic = DebugOption(description: "generic") |
| 83 | + public static let broker = DebugOption(description: "broker") |
| 84 | + public static let topic = DebugOption(description: "topic") |
| 85 | + public static let metadata = DebugOption(description: "metadata") |
| 86 | + public static let feature = DebugOption(description: "feature") |
| 87 | + public static let queue = DebugOption(description: "queue") |
| 88 | + public static let msg = DebugOption(description: "msg") |
| 89 | + public static let `protocol` = DebugOption(description: "protocol") |
| 90 | + public static let cgrp = DebugOption(description: "cgrp") |
| 91 | + public static let security = DebugOption(description: "security") |
| 92 | + public static let fetch = DebugOption(description: "fetch") |
| 93 | + public static let interceptor = DebugOption(description: "interceptor") |
| 94 | + public static let plugin = DebugOption(description: "plugin") |
| 95 | + public static let consumer = DebugOption(description: "consumer") |
| 96 | + public static let admin = DebugOption(description: "admin") |
| 97 | + public static let eos = DebugOption(description: "eos") |
| 98 | + public static let all = DebugOption(description: "all") |
| 99 | +} |
| 100 | + |
| 101 | +public struct IPAddressFamily: Hashable, Equatable, CustomStringConvertible { |
| 102 | + public let description: String |
| 103 | + |
| 104 | + public static let any = IPAddressFamily(description: "any") |
| 105 | + public static let v4 = IPAddressFamily(description: "v4") |
| 106 | + public static let v6 = IPAddressFamily(description: "v6") |
| 107 | +} |
| 108 | + |
| 109 | +public struct SecurityProtocol: Hashable, Equatable, CustomStringConvertible { |
| 110 | + public let description: String |
| 111 | + |
| 112 | + public static let plaintext = SecurityProtocol(description: "plaintext") |
| 113 | + public static let ssl = SecurityProtocol(description: "ssl") |
| 114 | + public static let saslPlaintext = SecurityProtocol(description: "sasl_plaintext") |
| 115 | + public static let saslSSL = SecurityProtocol(description: "sasl_ssl") |
| 116 | +} |
| 117 | + |
| 118 | +public struct SASLMechanism: Hashable, Equatable, CustomStringConvertible { |
| 119 | + public let description: String |
| 120 | + |
| 121 | + public static let gssapi = SASLMechanism(description: "GSSAPI") |
| 122 | + public static let plain = SASLMechanism(description: "PLAIN") |
| 123 | + public static let scramSHA256 = SASLMechanism(description: "SCRAM-SHA-256") |
| 124 | + public static let scramSHA512 = SASLMechanism(description: "SCRAM-SHA-512") |
| 125 | + public static let oauthbearer = SASLMechanism(description: "OAUTHBEARER") |
| 126 | +} |
0 commit comments