18
18
// TODO: DocC: inherit documentation?
19
19
// TODO: DocC: take from lirbdkafka official documentation
20
20
// TODO: Topic config -> see KafkaConfig in SwiftKafka
21
- // TODO: make IPAddressFamily etc. part of some ConfigProperty like type to avoid cluttering docc
22
21
// TODO: create empty init for substructs to disable free initializer?
23
22
// TODO: test that values get set accordingly
24
23
// TODO: remove old config tests
@@ -91,7 +90,7 @@ extension ClientConfig {
91
90
set { self . properties [ " topic.blacklist " ] = newValue. joined ( separator: " , " ) }
92
91
}
93
92
94
- public var debug : [ DebugOption ] {
93
+ public var debug : [ ConfigEnums . DebugOption ] {
95
94
get { self . getDebugOptions ( ) }
96
95
set {
97
96
if !newValue. isEmpty {
@@ -140,7 +139,7 @@ extension ClientConfig {
140
139
set { self . properties [ " broker.address.ttl " ] = String ( newValue) }
141
140
}
142
141
143
- public var brokerAddressFamily : IPAddressFamily {
142
+ public var brokerAddressFamily : ConfigEnums . IPAddressFamily {
144
143
get { self . getIPAddressFamily ( ) ?? . any }
145
144
set { self . properties [ " broker.address.family " ] = newValue. description }
146
145
}
@@ -155,7 +154,7 @@ extension ClientConfig {
155
154
set { self . properties [ " reconnect.backoff.max.ms " ] = String ( newValue) }
156
155
}
157
156
158
- public var securityProtocol : SecurityProtocol {
157
+ public var securityProtocol : ConfigEnums . SecurityProtocol {
159
158
get { self . getSecurityProtocol ( ) ?? . plaintext }
160
159
set { self . properties [ " security.protocol " ] = newValue. description }
161
160
}
@@ -195,7 +194,7 @@ extension ClientConfig {
195
194
set { self . properties [ " ssl.keystore.password " ] = newValue }
196
195
}
197
196
198
- public var saslMechanism : SASLMechanism ? {
197
+ public var saslMechanism : ConfigEnums . SASLMechanism ? {
199
198
get { self . getSASLMechanism ( ) }
200
199
set {
201
200
if let newValue {
@@ -250,104 +249,41 @@ extension ClientConfig {
250
249
return Bool ( value)
251
250
}
252
251
253
- func getDebugOptions( ) -> [ DebugOption ] {
252
+ func getDebugOptions( ) -> [ ConfigEnums . DebugOption ] {
254
253
guard let options = properties [ " debug " ] else {
255
254
return [ ]
256
255
}
257
256
return options. components ( separatedBy: " , " )
258
- . map { DebugOption ( description: $0) }
257
+ . map { ConfigEnums . DebugOption ( description: $0) }
259
258
}
260
259
261
- func getIPAddressFamily( ) -> IPAddressFamily ? {
260
+ func getIPAddressFamily( ) -> ConfigEnums . IPAddressFamily ? {
262
261
guard let value = properties [ " broker.address.family " ] else {
263
262
return nil
264
263
}
265
- return IPAddressFamily ( description: value)
264
+ return ConfigEnums . IPAddressFamily ( description: value)
266
265
}
267
266
268
- func getSecurityProtocol( ) -> SecurityProtocol ? {
267
+ func getSecurityProtocol( ) -> ConfigEnums . SecurityProtocol ? {
269
268
guard let value = properties [ " security.protocol " ] else {
270
269
return nil
271
270
}
272
- return SecurityProtocol ( description: value)
271
+ return ConfigEnums . SecurityProtocol ( description: value)
273
272
}
274
273
275
- func getSASLMechanism( ) -> SASLMechanism ? {
274
+ func getSASLMechanism( ) -> ConfigEnums . SASLMechanism ? {
276
275
guard let value = properties [ " sasl.mechanism " ] else {
277
276
return nil
278
277
}
279
- return SASLMechanism ( description: value)
278
+ return ConfigEnums . SASLMechanism ( description: value)
280
279
}
281
280
282
281
// TODO: move to Consumer
283
- func getAutoOffsetReset( ) -> AutoOffsetReset ? {
282
+ func getAutoOffsetReset( ) -> ConfigEnums . AutoOffsetReset ? {
284
283
guard let value = properties [ " auto.offset.reset " ] else {
285
284
return nil
286
285
}
287
- return AutoOffsetReset ( description: value)
286
+ return ConfigEnums . AutoOffsetReset ( description: value)
288
287
}
289
288
}
290
289
291
- // MARK: - Auxiliary Types
292
-
293
- public struct DebugOption : Hashable , Equatable , CustomStringConvertible {
294
- public let description : String
295
-
296
- public static let generic = DebugOption ( description: " generic " )
297
- public static let broker = DebugOption ( description: " broker " )
298
- public static let topic = DebugOption ( description: " topic " )
299
- public static let metadata = DebugOption ( description: " metadata " )
300
- public static let feature = DebugOption ( description: " feature " )
301
- public static let queue = DebugOption ( description: " queue " )
302
- public static let msg = DebugOption ( description: " msg " )
303
- public static let `protocol` = DebugOption ( description: " protocol " )
304
- public static let cgrp = DebugOption ( description: " cgrp " )
305
- public static let security = DebugOption ( description: " security " )
306
- public static let fetch = DebugOption ( description: " fetch " )
307
- public static let interceptor = DebugOption ( description: " interceptor " )
308
- public static let plugin = DebugOption ( description: " plugin " )
309
- public static let consumer = DebugOption ( description: " consumer " )
310
- public static let admin = DebugOption ( description: " admin " )
311
- public static let eos = DebugOption ( description: " eos " )
312
- public static let all = DebugOption ( description: " all " )
313
- }
314
-
315
- public struct IPAddressFamily : Hashable , Equatable , CustomStringConvertible {
316
- public let description : String
317
-
318
- public static let any = IPAddressFamily ( description: " any " )
319
- public static let v4 = IPAddressFamily ( description: " v4 " )
320
- public static let v6 = IPAddressFamily ( description: " v6 " )
321
- }
322
-
323
- public struct SecurityProtocol : Hashable , Equatable , CustomStringConvertible {
324
- public let description : String
325
-
326
- public static let plaintext = SecurityProtocol ( description: " plaintext " )
327
- public static let ssl = SecurityProtocol ( description: " ssl " )
328
- public static let saslPlaintext = SecurityProtocol ( description: " sasl_plaintext " )
329
- public static let saslSSL = SecurityProtocol ( description: " sasl_ssl " )
330
- }
331
-
332
- public struct SASLMechanism : Hashable , Equatable , CustomStringConvertible {
333
- public let description : String
334
-
335
- public static let gssapi = SASLMechanism ( description: " GSSAPI " )
336
- public static let plain = SASLMechanism ( description: " PLAIN " )
337
- public static let scramSHA256 = SASLMechanism ( description: " SCRAM-SHA-256 " )
338
- public static let scramSHA512 = SASLMechanism ( description: " SCRAM-SHA-512 " )
339
- public static let oauthbearer = SASLMechanism ( description: " OAUTHBEARER " )
340
- }
341
-
342
- // TODO: move to consumer? -> only used there
343
- public struct AutoOffsetReset : Hashable , Equatable , CustomStringConvertible {
344
- public let description : String
345
-
346
- public static let smallest = AutoOffsetReset ( description: " smallest " )
347
- public static let earliest = AutoOffsetReset ( description: " earliest " )
348
- public static let beginning = AutoOffsetReset ( description: " beginning " )
349
- public static let largest = AutoOffsetReset ( description: " largest " )
350
- public static let latest = AutoOffsetReset ( description: " latest " )
351
- public static let end = AutoOffsetReset ( description: " end " )
352
- public static let error = AutoOffsetReset ( description: " error " )
353
- }
0 commit comments