@@ -22,6 +22,7 @@ use std::path::PathBuf;
22
22
use url:: Url ;
23
23
24
24
use crate :: {
25
+ kafka:: SslProtocol ,
25
26
oidc:: { self , OpenidConfig } ,
26
27
option:: { validation, Compression , Mode } ,
27
28
} ;
@@ -107,6 +108,14 @@ pub struct Cli {
107
108
pub trino_auth : Option < String > ,
108
109
pub trino_schema : Option < String > ,
109
110
pub trino_catalog : Option < String > ,
111
+
112
+ // Kafka specific env vars
113
+ pub kafka_topics : Option < String > ,
114
+ pub kafka_host : Option < String > ,
115
+ pub kafka_group : Option < String > ,
116
+ pub kafka_client_id : Option < String > ,
117
+ pub kafka_security_protocol : Option < SslProtocol > ,
118
+ pub kafka_partitions : Option < String > ,
110
119
}
111
120
112
121
impl Cli {
@@ -148,6 +157,14 @@ impl Cli {
148
157
pub const TRINO_AUTHORIZATION : & ' static str = "p-trino-authorization" ;
149
158
pub const TRINO_SCHEMA : & ' static str = "p-trino-schema" ;
150
159
160
+ // Kafka specific env vars
161
+ pub const KAFKA_TOPICS : & ' static str = "kafka-topics" ;
162
+ pub const KAFKA_HOST : & ' static str = "kafka-host" ;
163
+ pub const KAFKA_GROUP : & ' static str = "kafka-group" ;
164
+ pub const KAFKA_CLIENT_ID : & ' static str = "kafka-client-id" ;
165
+ pub const KAFKA_SECURITY_PROTOCOL : & ' static str = "kafka-security-protocol" ;
166
+ pub const KAFKA_PARTITIONS : & ' static str = "kafka-partitions" ;
167
+
151
168
pub fn local_stream_data_path ( & self , stream_name : & str ) -> PathBuf {
152
169
self . local_staging_path . join ( stream_name)
153
170
}
@@ -161,6 +178,48 @@ impl Cli {
161
178
162
179
pub fn create_cli_command_with_clap ( name : & ' static str ) -> Command {
163
180
Command :: new ( name) . next_line_help ( false )
181
+ . arg (
182
+ Arg :: new ( Self :: KAFKA_TOPICS )
183
+ . long ( Self :: KAFKA_TOPICS )
184
+ . env ( "P_KAFKA_TOPICS" )
185
+ . value_name ( "STRING" )
186
+ . help ( "Kafka topics to subscribe to" ) ,
187
+ )
188
+ . arg (
189
+ Arg :: new ( Self :: KAFKA_HOST )
190
+ . long ( Self :: KAFKA_HOST )
191
+ . env ( "P_KAFKA_HOST" )
192
+ . value_name ( "STRING" )
193
+ . help ( "Address and port for Kafka server" ) ,
194
+ )
195
+ . arg (
196
+ Arg :: new ( Self :: KAFKA_GROUP )
197
+ . long ( Self :: KAFKA_GROUP )
198
+ . env ( "P_KAFKA_GROUP" )
199
+ . value_name ( "STRING" )
200
+ . help ( "Kafka group" ) ,
201
+ )
202
+ . arg (
203
+ Arg :: new ( Self :: KAFKA_CLIENT_ID )
204
+ . long ( Self :: KAFKA_CLIENT_ID )
205
+ . env ( "P_KAFKA_CLIENT_ID" )
206
+ . value_name ( "STRING" )
207
+ . help ( "Kafka client id" ) ,
208
+ )
209
+ . arg (
210
+ Arg :: new ( Self :: KAFKA_SECURITY_PROTOCOL )
211
+ . long ( Self :: KAFKA_SECURITY_PROTOCOL )
212
+ . env ( "P_KAFKA_SECURITY_PROTOCOL" )
213
+ . value_name ( "STRING" )
214
+ . help ( "Kafka security protocol" ) ,
215
+ )
216
+ . arg (
217
+ Arg :: new ( Self :: KAFKA_PARTITIONS )
218
+ . long ( Self :: KAFKA_PARTITIONS )
219
+ . env ( "P_KAFKA_PARTITIONS" )
220
+ . value_name ( "STRING" )
221
+ . help ( "Kafka partitions" ) ,
222
+ )
164
223
. arg (
165
224
Arg :: new ( Self :: TRINO_ENDPOINT )
166
225
. long ( Self :: TRINO_ENDPOINT )
@@ -466,6 +525,13 @@ impl FromArgMatches for Cli {
466
525
self . trino_schema = m. get_one :: < String > ( Self :: TRINO_SCHEMA ) . cloned ( ) ;
467
526
self . trino_username = m. get_one :: < String > ( Self :: TRINO_USER_NAME ) . cloned ( ) ;
468
527
528
+ self . kafka_topics = m. get_one :: < String > ( Self :: KAFKA_TOPICS ) . cloned ( ) ;
529
+ self . kafka_host = m. get_one :: < String > ( Self :: KAFKA_HOST ) . cloned ( ) ;
530
+ self . kafka_group = m. get_one :: < String > ( Self :: KAFKA_GROUP ) . cloned ( ) ;
531
+ self . kafka_client_id = m. get_one :: < String > ( Self :: KAFKA_CLIENT_ID ) . cloned ( ) ;
532
+ self . kafka_security_protocol = m. get_one :: < SslProtocol > ( Self :: KAFKA_SECURITY_PROTOCOL ) . cloned ( ) ;
533
+ self . kafka_partitions = m. get_one :: < String > ( Self :: KAFKA_PARTITIONS ) . cloned ( ) ;
534
+
469
535
self . tls_cert_path = m. get_one :: < PathBuf > ( Self :: TLS_CERT ) . cloned ( ) ;
470
536
self . tls_key_path = m. get_one :: < PathBuf > ( Self :: TLS_KEY ) . cloned ( ) ;
471
537
self . trusted_ca_certs_path = m. get_one :: < PathBuf > ( Self :: TRUSTED_CA_CERTS_PATH ) . cloned ( ) ;
0 commit comments