core hello world / hello_server.ml

open Core.Std
open Async.Std

(* The implementation of the "hello" RPC.  The first argument is the environment
   the query executes against, which in this case is trivial.

   The RPC waits a 10th of a second before responding just to show how you do a
   query whose implementation blocks.
*)
let hello_impl () hello =
  Log.Global.info "received hello query (%s)" hello;
  Clock.after (sec 0.1)
  >>= fun () -> return (hello ^ " World!")

(* The list of RPC implementations supported by this server *)
let implementations =
  [ Rpc.Rpc.implement Hello_protocol.hello_rpc hello_impl ]

(* The command-line interface.  We use [async_basic] so that the command starts
   the async scheduler, and exits when the server stops.  *)
let command =
  Command.async_basic
    ~summary:"Hello World server"
    Command.Spec.(
      empty +> Common.port_arg ()
    )
    (fun port () -> Common.start_server ~env:() ~port ~implementations ())

let () = Command.run command
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.