1. Yaron Minsky
  2. core hello world


Yaron Minsky  committed da7f04f

small tweaks

  • Participants
  • Parent commits 31415b8
  • Branches default

Comments (0)

Files changed (6)

File README.md

View file
  • Ignore whitespace
-Hello World for Core
+Core and Async Hello World
 A simple hello-world project for Core.  The intent is to show you how
 to get started building OCaml projects using OPAM, Core and
-OCamlbuild.  To use this, first get OPAM, and install the "core"
-package.  Also, it's probably doing this:
-    $ opam switch ocaml-4.00.1+short-types
+Before getting started with this code, you should follow the
+instructions in the PREREQUISITES.
-to get better error messages from the compiler when using Core.  (As
-of 4.01, this compiler variant should be obsolete.)
-You can build all the pieces of this project by running:
+Once that's done, you can build all the pieces of this project by
     $ ./build_all.sh
 Hello World
+This is a very simple exercise that shows you how to make a basic
+command-line application using Core's `Command` module.
 This executable is `hello_world.native` (or `hello_world.byte`), and
 here's an example of it in action.

File broker_protocol.ml

View file
  • Ignore whitespace
 let shutdown_rpc = Rpc.Rpc.create

File broker_server.ml

View file
  • Ignore whitespace
 (* First, we build the implementations *)
 let publish_impl (dir,_) msg =
+  Log.Global.sexp ~level:`Debug msg
+    (Message.sexp_of_t);
   return (Directory.publish dir msg)
 let subscribe_impl (dir,_) topic ~aborted =

File build.sh

View file
  • Ignore whitespace
 eval `opam config -env`
-for TARGET in $*
-  ocamlbuild -use-ocamlfind $TARGET -cflags "-w @A-4-33-23" -cflags -short-paths
+ocamlbuild -j 4 -use-ocamlfind -cflags "-w @A-4-33-23" -cflags -short-paths $*

File common.ml

View file
  • Ignore whitespace
 let start_server ~env ?(stop=Deferred.never ()) ~implementations ~port () =
-  Log.Global.info "starting server on %d" port;
+  Log.Global.info "Starting server on %d" port;
   let implementations =
     Rpc.Implementations.create_exn ~implementations
       ~on_unknown_rpc:(`Call (fun ~rpc_tag ~version ->
         Log.Global.info "Unexpected RPC, tag %s, version %d" rpc_tag version))
-  Log.Global.info "About to start TCP server";
     ~on_handler_error:(`Call (fun _ exn -> Log.Global.sexp exn Exn.sexp_of_t))
     (Tcp.on_port port)
   >>= fun server ->
-  Log.Global.info "TCP server started, waiting for close";
+  Log.Global.info "Server started, waiting for close";
     [ (stop >>= fun () -> Tcp.Server.close server)
     ; Tcp.Server.close_finished server ]

File hello_server.ml

View file
  • Ignore whitespace
    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!")