-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to easier to rewrite code to work with binary data? #11
Comments
Do you have an example of what you would want the interface to look like? I could see something along the lines of the following being simple but useful wrappers: val make_send : ('a -> string list) -> _ Lwt_zmq.Socket.t -> ('a -> unit Lwt.t)
val make_recv : (string list -> 'a) -> _ Lwt_zmq.Socket.t -> (unit -> 'a Lwt.t)
val make_send_s : ('a -> string list Lwt.t) -> _ Lwt_zmq.Socket.t -> ('a -> unit Lwt.t)
val make_recv_s : (string list -> 'a Lwt.t) -> _ Lwt_zmq.Socket.t -> (unit -> 'a Lwt.t)
The |
Hello, currently I need only properly typed messages on zmq bus so I prefer following modification of your code with functor: module type IDType = sig
type t
val to_string : t -> string
val of_string : string -> t
end
module FLSocket(DType : IDType) = struct
type 'a t = {
socket : 'a ZMQ.Socket.t;
fd : Lwt_unix.file_descr;
}
...
let recv s =
wrap (fun s -> let r = ZMQ.Socket.recv ~block:false s in DType.of_string r) s
let send ?more s m =
wrap (fun s -> ZMQ.Socket.send ?more ~block:false s (DType.to_string m)) s
...
end
type vlan = int list [@@deriving protobuf { protoc }]
type io =
| Port of int [@key 1]
| Agg of int [@key 2]
| Vlan of vlan [@key 3]
[@@deriving protobuf { protoc }]
type router = io list [@@deriving protobuf { protoc }]
module LSocket =
FLSocket(struct
type t = router
let to_string = Protobuf.Encoder.encode_exn router_to_protobuf
let of_string = Protobuf.Decoder.decode_exn router_from_protobuf
end)
I don't know should I send such modification as pull request to your repository? |
Hello,
I want to work with structured messages packed to protocol buffers.
Is it right way to parametrize Router module by message type or you do not interested in such patches?
The text was updated successfully, but these errors were encountered: