Skip to content

Commit

Permalink
Merge pull request #117 from anuragsoni/update-async-examples
Browse files Browse the repository at this point in the history
Port async examples to Command.Param
  • Loading branch information
seliopou authored Mar 29, 2019
2 parents 46b9da7 + c90801c commit 95e09c8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
17 changes: 9 additions & 8 deletions benchmarks/wrk_async_benchmark.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ let main port max_accepts_per_batch () =
Deferred.never ()

let () =
Command.async_spec
Command.async
~summary:"Start a hello world Async server"
Command.Spec.(empty +>
flag "-p" (optional_with_default 8080 int)
~doc:"int Source port to listen on"
+>
flag "-a" (optional_with_default 1 int)
~doc:"int Maximum accepts per batch"
) main
Command.Param.(
map (both
(flag "-p" (optional_with_default 8080 int)
~doc:"int Source port to listen on")
(flag "-a" (optional_with_default 1 int)
~doc:"int Maximum accepts per batch"))
~f:(fun (port, accepts) ->
(fun () -> main port accepts ())))
|> Command.run
17 changes: 9 additions & 8 deletions examples/async/async_echo_post.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ let main port max_accepts_per_batch () =
Deferred.never ()

let () =
Command.async_spec
Command.async
~summary:"Start a hello world Async server"
Command.Spec.(empty +>
flag "-p" (optional_with_default 8080 int)
~doc:"int Source port to listen on"
+>
flag "-a" (optional_with_default 1 int)
~doc:"int Maximum accepts per batch"
) main
Command.Param.(
map (both
(flag "-p" (optional_with_default 8080 int)
~doc:"int Source port to listen on")
(flag "-a" (optional_with_default 1 int)
~doc:"int Maximum accepts per batch"))
~f:(fun (port, accepts) ->
(fun () -> main port accepts ())))
|> Command.run
19 changes: 10 additions & 9 deletions examples/async/async_get.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core
open! Core
open Async

open Httpaf
Expand Down Expand Up @@ -37,13 +37,14 @@ let main port host () =
;;

let () =
Command.async_spec
Command.async
~summary:"Start a hello world Async client"
Command.Spec.(empty +>
flag "-p" (optional_with_default 80 int)
~doc:"int destination port"
+>
flag "-h" (required string)
~doc:"string destination host"
) main
Command.Param.(
map (both
(flag "-p" (optional_with_default 80 int)
~doc:"int destination port")
(flag "-h" (required string)
~doc:"string destination host"))
~f:(fun (port, host) ->
(fun () -> main port host ())))
|> Command.run
17 changes: 9 additions & 8 deletions examples/async/async_post.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ let main port host () =
;;

let () =
Command.async_spec
Command.async
~summary:"Start a hello world Async client"
Command.Spec.(empty +>
flag "-p" (optional_with_default 80 int)
~doc:"int destination port"
+>
flag "-a" (required string)
~doc:"string destination ip"
) main
Command.Param.(
map (both
(flag "-p" (optional_with_default 80 int)
~doc:"int destination port")
(flag "-h" (required string)
~doc:"string destination host"))
~f:(fun (port, host) ->
(fun () -> main port host ())))
|> Command.run

0 comments on commit 95e09c8

Please sign in to comment.