@@ -1,11 +1,9 @@
11module Kafka.Kafka
22 ( SaslConfig
33 , Kafka
4− , RecordMetadata
54 , KafkaConfig
65 , makeClient
7− , Message
8− , Payload
6+ , LogLevel(..)
97 ) where
108
119import Prelude
@@ -14,6 +12,18 @@ import Data.Nullable (Nullable, toNullable)
1412
1513foreign import data Kafka :: Type
1614
15+
16+data LogLevel = LogNothing | LogDebug | LogInfo | LogWarn | LogError
17+
18+foreign import data InternalLogLevel :: Type
19+
20+foreign import internalLogNothing :: InternalLogLevel
21+
22+foreign import internalLogDebug :: InternalLogLevel
23+foreign import internalLogInfo:: InternalLogLevel
24+foreign import internalLogWarn :: InternalLogLevel
25+foreign import internalLogError :: InternalLogLevel
26+
1727type SaslConfig
1828 = { mechanism :: String
1929 , username :: String
@@ -25,6 +35,7 @@ type InternalKafkaConfig
2535 , brokers :: Array String
2636 , ssl :: Boolean
2737 , sasl :: Nullable SaslConfig
38+ , logLevel :: Nullable InternalLogLevel
2839 }
2940
3041type KafkaConfig
@@ -32,36 +43,25 @@ type KafkaConfig
3243 , brokers :: Array String
3344 , ssl :: Boolean
3445 , sasl :: Maybe SaslConfig
46+ , logLevel :: Maybe LogLevel
3547 }
3648
37−
38−
3949foreign import makeClientImpl :: InternalKafkaConfig -> Kafka
4050
4151makeClient :: KafkaConfig -> Kafka
4252makeClient = toInternal >>> makeClientImpl
4353 where
54+
55+ toInternalLogLevel LogNothing = internalLogNothing
56+ toInternalLogLevel LogDebug = internalLogDebug
57+ toInternalLogLevel LogInfo = internalLogDebug
58+ toInternalLogLevel LogWarn = internalLogWarn
59+ toInternalLogLevel LogError = internalLogError
60+
4461 toInternal config =
4562 { clientId: config.clientId
4663 , brokers: config.brokers
4764 , ssl: config.ssl
4865 , sasl: toNullable config.sasl
66+ , logLevel : config.logLevel <#> toInternalLogLevel # toNullable
4967 }
50−
51−
52−type Message
53− = { key :: Maybe String
54− , value :: String
55− , partition :: Maybe Int
56− }
57−
58−type Payload
59− = { topic :: String
60− , messages :: Array (Message)
61− }
62−
63−
64−foreign import data RecordMetadata :: Type
65−
66−
67−