···6262 Tomlt.(
6363 Table.(
6464 obj
6565- (fun host port tls insecure client_id clean_session keep_alive
6666- username password protocol_version ->
6565+ (fun
6666+ host
6767+ port
6868+ tls
6969+ insecure
7070+ client_id
7171+ clean_session
7272+ keep_alive
7373+ username
7474+ password
7575+ protocol_version
7676+ ->
6777 {
6878 host;
6979 port;
···106116 mqtt = Option.value ~default:empty_mqtt_config mqtt;
107117 pool = Option.value ~default:empty_pool_config pool;
108118 })
109109- |> opt_mem "mqtt" mqtt_codec
110110- ~enc:(fun c ->
111111- if c.mqtt = empty_mqtt_config then None else Some c.mqtt)
112112- |> opt_mem "pool" pool_codec
113113- ~enc:(fun c ->
114114- if c.pool = empty_pool_config then None else Some c.pool)
119119+ |> opt_mem "mqtt" mqtt_codec ~enc:(fun c ->
120120+ if c.mqtt = empty_mqtt_config then None else Some c.mqtt)
121121+ |> opt_mem "pool" pool_codec ~enc:(fun c ->
122122+ if c.pool = empty_pool_config then None else Some c.pool)
115123 |> finish))
116124117125 let load_from_path path =
···193201 "Skip TLS certificate verification (allows expired/self-signed \
194202 certificates)."
195203 in
196196- Term.(const (fun flag -> flag || config_default) $ Arg.(value & flag & info [ "insecure" ] ~doc))
204204+ Term.(
205205+ const (fun flag -> flag || config_default)
206206+ $ Arg.(value & flag & info [ "insecure" ] ~doc))
197207198208let client_id_term ~file_config =
199209 let default = file_config.Config_file.mqtt.client_id in
···201211 "MQTT client identifier. If not specified, a random ID is generated."
202212 in
203213 let env = Cmd.Env.info "MQTT_CLIENT_ID" ~doc in
204204- Arg.(value & opt (some string) default & info [ "client-id" ] ~docv:"ID" ~doc ~env)
214214+ Arg.(
215215+ value
216216+ & opt (some string) default
217217+ & info [ "client-id" ] ~docv:"ID" ~doc ~env)
205218206219let clean_session_term ~file_config =
207207- let config_default = or_else file_config.Config_file.mqtt.clean_session false in
220220+ let config_default =
221221+ or_else file_config.Config_file.mqtt.clean_session false
222222+ in
208223 let doc =
209224 "Start with a clean session (discard any previous session state)."
210225 in
211211- Term.(const (fun flag -> flag || config_default) $ Arg.(value & flag & info [ "clean-session" ] ~doc))
226226+ Term.(
227227+ const (fun flag -> flag || config_default)
228228+ $ Arg.(value & flag & info [ "clean-session" ] ~doc))
212229213230let keep_alive_term ~file_config =
214231 let default = or_else file_config.Config_file.mqtt.keep_alive 60 in
···223240 in
224241 let doc = "MQTT protocol version to use." in
225242 let versions = [ ("3.1.1", `V3_1_1); ("5", `V5_0); ("5.0", `V5_0) ] in
226226- Arg.(value & opt (enum versions) default & info [ "mqtt-version" ] ~docv:"VERSION" ~doc)
243243+ Arg.(
244244+ value
245245+ & opt (enum versions) default
246246+ & info [ "mqtt-version" ] ~docv:"VERSION" ~doc)
227247228248let username_term ~file_config =
229249 let default = file_config.Config_file.mqtt.username in
230250 let doc = "MQTT username for authentication." in
231251 let env = Cmd.Env.info "MQTT_USER" ~doc in
232232- Arg.(value & opt (some string) default & info [ "u"; "username" ] ~docv:"USER" ~doc ~env)
252252+ Arg.(
253253+ value
254254+ & opt (some string) default
255255+ & info [ "u"; "username" ] ~docv:"USER" ~doc ~env)
233256234257let password_term ~file_config =
235258 let default = file_config.Config_file.mqtt.password in
236259 let doc = "MQTT password for authentication." in
237260 let env = Cmd.Env.info "MQTT_PASSWORD" ~doc in
238238- Arg.(value & opt (some string) default & info [ "password" ] ~docv:"PASS" ~doc ~env)
261261+ Arg.(
262262+ value
263263+ & opt (some string) default
264264+ & info [ "password" ] ~docv:"PASS" ~doc ~env)
239265240266(** {1 Combined Terms} *)
241267···245271 { host; port; tls; insecure }
246272 in
247273 Term.(
248248- const make
249249- $ host_term ~file_config
250250- $ port_term ~file_config
251251- $ tls_term ~file_config
252252- $ insecure_term ~file_config)
274274+ const make $ host_term ~file_config $ port_term ~file_config
275275+ $ tls_term ~file_config $ insecure_term ~file_config)
253276254277let config_term ~file_config =
255278 let make client_id clean_session keep_alive version username password =
···275298 $ clean_session_term ~file_config
276299 $ keep_alive_term ~file_config
277300 $ protocol_version_term ~file_config
278278- $ username_term ~file_config
279279- $ password_term ~file_config)
301301+ $ username_term ~file_config $ password_term ~file_config)
280302281303let pool_config_term ~file_config =
282304 let default_max =
···301323 in
302324 Term.(
303325 const (fun max_connections_per_endpoint max_idle_time ->
304304- Conpool.Config.make ~max_connections_per_endpoint ~max_idle_time ())
326326+ Conpool.Config.v ~max_connections_per_endpoint ~max_idle_time ())
305327 $ max_size $ idle_timeout)
306328307329(** {1 Main Term} *)
···346368 | Error (`Msg msg) -> failwith ("Failed to create TLS config: " ^ msg)
347369 else None
348370 in
349349- Conpool.create_basic ~sw ~net ~clock ?tls:tls_config ~config:pool_config ()
371371+ Conpool.basic ~sw ~net ~clock ?tls:tls_config ~config:pool_config ()
350372351351-let endpoint conn = Conpool.Endpoint.make ~host:conn.host ~port:conn.port
373373+let endpoint conn = Conpool.Endpoint.v ~host:conn.host ~port:conn.port
352374353375(** {1 XDG Access} *)
354376···394416 `P "The following environment variables affect the program:";
395417 `I
396418 ( "MQTT_HOST",
397397- "MQTT broker hostname or IP address. Overrides config file, \
398398- overridden by --host." );
419419+ "MQTT broker hostname or IP address. Overrides config file, overridden \
420420+ by --host." );
399421 `I
400400- ("MQTT_PORT", "MQTT broker port. Overrides config file, overridden by --port.");
422422+ ( "MQTT_PORT",
423423+ "MQTT broker port. Overrides config file, overridden by --port." );
401424 `I ("MQTT_TLS", "Enable TLS if set to any value. Overridden by --tls.");
402425 `I
403426 ( "MQTT_CLIENT_ID",
···510533 "Creates a default configuration file at ~/.config/%s/config.toml \
511534 with commented examples of all available options."
512535 app_name);
513513- `P
514514- "If a configuration file already exists, use --force to overwrite it.";
536536+ `P "If a configuration file already exists, use --force to overwrite it.";
515537 ]
516538 in
517539 let info = Cmd.info "init-config" ~doc ~man in
+21-14
lib/cmd/mqtte_cmd.mli
···4545(** {1 Connection Options} *)
46464747type connection = { host : string; port : int; tls : bool; insecure : bool }
4848-(** Connection parameters parsed from command line, environment, or config file. *)
4848+(** Connection parameters parsed from command line, environment, or config file.
4949+*)
49505051(** {1 Combined Configuration} *)
5152···6364 XDG context for accessing application directories. *)
64656566val term :
6666- app_name:string -> fs:Eio.Fs.dir_ty Eio.Path.t -> unit -> parsed Cmdliner.Term.t
6767+ app_name:string ->
6868+ fs:Eio.Fs.dir_ty Eio.Path.t ->
6969+ unit ->
7070+ parsed Cmdliner.Term.t
6771(** [term ~app_name ~fs ()] creates a Cmdliner term that parses MQTT
6872 configuration from command line arguments, environment variables, and TOML
6973 config files.
···176180 (** Empty configuration. *)
177181178182 val codec : t Tomlt.t
179179- (** Tomlt codec for the full config file (both [[mqtt]] and [[pool]] sections).
180180- Use this when loading a standalone config.toml, or use {!mqtt_codec} and
181181- {!pool_codec} separately to compose with application-specific sections. *)
183183+ (** Tomlt codec for the full config file (both [[mqtt]] and [[pool]]
184184+ sections). Use this when loading a standalone config.toml, or use
185185+ {!mqtt_codec} and {!pool_codec} separately to compose with
186186+ application-specific sections. *)
182187183188 val load : Xdge.t -> t option
184189 (** [load xdg] attempts to load [config.toml] from the XDG config directory.
···271276272277 Example usage:
273278 {[
274274- let main_cmd = Cmd.group info [
275275- your_main_term;
276276- Mqtte_cmd.init_config_cmd ~app_name ~fs;
277277- Mqtte_cmd.show_config_cmd ~app_name ~fs;
278278- ]
279279+ let main_cmd =
280280+ Cmd.group info
281281+ [
282282+ your_main_term;
283283+ Mqtte_cmd.init_config_cmd ~app_name ~fs;
284284+ Mqtte_cmd.show_config_cmd ~app_name ~fs;
285285+ ]
279286 ]} *)
280287281288val init_config_cmd :
···283290(** [init_config_cmd ~app_name ~fs] creates an [init-config] subcommand that
284291 writes a default configuration file to the XDG config directory.
285292286286- Supports [--force] flag to overwrite existing configuration.
287287- Returns exit code 0 on success, 1 if file exists and --force not given. *)
293293+ Supports [--force] flag to overwrite existing configuration. Returns exit
294294+ code 0 on success, 1 if file exists and --force not given. *)
288295289296val show_config_cmd :
290297 app_name:string -> fs:Eio.Fs.dir_ty Eio.Path.t -> int Cmdliner.Cmd.t
291298(** [show_config_cmd ~app_name ~fs] creates a [show-config] subcommand that
292292- displays the configuration file path and its contents if it exists.
293293- Returns exit code 0. *)
299299+ displays the configuration file path and its contents if it exists. Returns
300300+ exit code 0. *)
+6-6
lib/eio/client.ml
···111111112112let handle_incoming_packet t packet =
113113 match packet with
114114- | Transport.V3 pkt -> begin
115115- match pkt with
114114+ | Transport.V3 pkt ->
115115+ begin match pkt with
116116 | Mqtte.V3.Packet.Publish p ->
117117 let msg =
118118 {
···161161 t.connected <- false;
162162 t.should_stop <- true
163163 | _ -> Log.warn (fun m -> m "Unexpected packet type")
164164- end
165165- | Transport.V5 pkt -> begin
166166- match pkt with
164164+ end
165165+ | Transport.V5 pkt ->
166166+ begin match pkt with
167167 | Mqtte.V5.Packet.Publish p ->
168168 let msg =
169169 {
···247247 t.connected <- false;
248248 t.should_stop <- true
249249 | _ -> Log.warn (fun m -> m "Unexpected packet type")
250250- end
250250+ end
251251252252let reader_fiber t reader =
253253 Log.debug (fun m -> m "Starting reader fiber");