-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a3d214
commit b4a8929
Showing
10 changed files
with
103 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
open Core.Std | ||
open Async.Std | ||
|
||
let option_to_string = function | ||
| Some v -> v | ||
| None -> "<none>" | ||
|
||
let ping () = | ||
let open Deferred.Result.Monad_infix in | ||
let host = Sys.argv.(1) in | ||
let port = Int.of_string Sys.argv.(2) in | ||
let b = Sys.argv.(3) in | ||
Riakc.Conn.connect host port >>= fun c -> | ||
Riakc.Conn.list_keys c b >>= fun keys -> | ||
Riakc.Conn.close c >>= fun () -> | ||
return (Ok keys) | ||
|
||
let perform_ping () = | ||
ping () >>| function | ||
| Ok keys -> begin | ||
List.iter | ||
~f:(printf "%s\n") | ||
keys; | ||
shutdown 0 | ||
end | ||
| Error _ -> begin | ||
printf "Failed\n"; | ||
shutdown 1 | ||
end | ||
|
||
let () = | ||
ignore (perform_ping ()); | ||
never_returns (Scheduler.go ()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
val client_id : string Protobuf.Parser.t | ||
val server_info : (string option * string option) Protobuf.Parser.t | ||
val list_buckets : string list Protobuf.Parser.t | ||
val list_keys : (string list * bool) Protobuf.Parser.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
open Core.Std | ||
|
||
module B = Protobuf.Builder | ||
|
||
let wrap_request mc s = | ||
(* Add 1 for the mc *) | ||
let l = String.length s + 1 in | ||
let preamble_mc = String.create 5 in | ||
preamble_mc.[0] <- Char.of_int_exn ((l lsr 24) land 0xff); | ||
preamble_mc.[1] <- Char.of_int_exn ((l lsr 16) land 0xff); | ||
preamble_mc.[2] <- Char.of_int_exn ((l lsr 8) land 0xff); | ||
preamble_mc.[3] <- Char.of_int_exn (l land 0xff); | ||
preamble_mc.[4] <- mc; | ||
preamble_mc ^ s | ||
|
||
let ping () = | ||
"\x00\x00\x00\x01\x01" | ||
Ok (wrap_request '\x01' "") | ||
|
||
let client_id () = | ||
"\x00\x00\x00\x01\x03" | ||
Ok (wrap_request '\x03' "") | ||
|
||
let server_info () = | ||
"\x00\x00\x00\x01\x07" | ||
Ok (wrap_request '\x07' "") | ||
|
||
let list_buckets () = | ||
"\x00\x00\x00\x01\x0F" | ||
Ok (wrap_request '\x0F' "") | ||
|
||
let list_keys bucket () = | ||
let open Result.Monad_infix in | ||
let b = B.create () in | ||
B.bytes b 1 bucket >>= fun () -> | ||
Ok (wrap_request '\x11' (B.to_string b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
open Core.Std | ||
|
||
val ping : unit -> string | ||
val client_id : unit -> string | ||
val server_info : unit -> string | ||
val list_buckets : unit -> string | ||
val ping : unit -> (string, [> Protobuf.Builder.error ]) Result.t | ||
val client_id : unit -> (string, [> Protobuf.Builder.error ]) Result.t | ||
val server_info : unit -> (string, [> Protobuf.Builder.error ]) Result.t | ||
val list_buckets : unit -> (string, [> Protobuf.Builder.error ]) Result.t | ||
val list_keys : string -> unit -> (string, [> Protobuf.Builder.error ]) Result.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters