-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor nss/protocol.(ml/mli)/Encoder and add comments
* rename 'decoder_from' to more conventional 'of_string' * add safer version of peek pkt that also support git wire protocol v2 pkts: delim-pkt and response-end-pkt * move 'prompt_pkt' to 'decoder.mli' to reuse it in git wire proto v2 * add 'read_pkt' * add 'junk_chars' fn to 'Decoder' to increase 'decoder.pos' by 'n' * move 'bind' and '>>=' from nss/protocol.ml to pkt_line.decoder * [wip] support wire proto v2 capabilities * add 'Ls_refs', 'Fetch_command' modules to represent commands 'ls-refs' and 'fetch' respectively; * add 'Encoder' module to wire-proto-v2 with support for encoding command requests and copy-paste NSS's 'encode_proto_request' * add some comments to better define parts of a packet line: specific names for 4 bytes that encode packet length, the bytes that follow the length bytes, etc. * rename length calculating function 'pkt_len' to 'encoded_pkt_len' that returns the value hex-encoded in the first 4 bytes of the packet line and 'pkt_len_at_least_4' returns 'max 4 (encoded_pkt_len pkt)' * copy-paste 'Proto_request' module from NSS * update 'response' type in proto-v2 'Protocol' * add 'Extended_pkt_line_decoder' that provides more functionality than 'Pkt_line.Decoder' but not specific to the protocol * add decoding for all commands of wire proto v2 * reflect changes after 'mimic' lib introduction * make 'smart_flow' more understandable * reduce dup code, e.g., (>>=) * reorganize stuff closer to its use * rename stuff for more clarity * move smart protocol (wire proto v1)-based 'fetch' code to separate modules * functorize 'Smart_flow' * rename 'Smart_flow' to 'State_flow' * add mli file to 'State_flow' * improve 'nss/state.ml' API: - it improves cases when we want to "open" the module to get infix/syntax operators - it also make the API more uniform and rich, e.g., adds "map" fn * rename "fail" to "io_raise": 1) avoid clash with "fail" from "smart"/"wire_proto_v2" 2) to highlight that it causes "exception"al behavior * add support for "ls-refs" command (without args) * fix log.debug use and its message
- Loading branch information
Showing
26 changed files
with
1,941 additions
and
517 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,32 @@ | ||
open Astring | ||
|
||
type t = | ||
[ `Atom of string | ||
| `Key_value of string * string | ||
| `Command_features of string * string list ] | ||
|
||
(* TODO: integrate better support for known capabilities and commands | ||
e.g., ls-refs, etc. *) | ||
let of_string s = | ||
match String.cut ?rev:None ~sep:"=" s with | ||
| None -> `Atom s | ||
| Some (k, v) -> ( | ||
match String.cuts ?rev:None ?empty:None ~sep:" " v with | ||
| [] -> raise @@ Invalid_argument s | ||
| [ v ] -> `Key_value (k, v) | ||
| command :: features -> `Command_features (command, features)) | ||
|
||
let to_string = function | ||
| `Atom s -> s | ||
| `Key_value (k, v) -> Fmt.str "%s=%s" k v | ||
| `Command_features (s, s_lst) -> | ||
Fmt.str "%s=%s" s (String.concat ~sep:" " s_lst) | ||
|
||
let equal t1 t2 = | ||
match t1, t2 with | ||
| `Atom s1, `Atom s2 -> String.equal s1 s2 | ||
| `Key_value (k1, v1), `Key_value (k2, v2) -> | ||
String.equal k1 k2 && String.equal v1 v2 | ||
| `Command_features (c1, fs1), `Command_features (c2, fs2) -> | ||
String.equal c1 c2 && List.for_all2 String.equal fs1 fs2 | ||
| _ -> false |
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,9 @@ | ||
type t = | ||
private | ||
[ `Atom of string | ||
| `Key_value of string * string | ||
| `Command_features of string * string list ] | ||
|
||
val of_string : string -> t | ||
val to_string : t -> string | ||
val equal : t -> t -> bool |
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
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
Oops, something went wrong.