Created
March 9, 2021 03:55
-
-
Save droyo/81dd28811bf6f279a3429a5792fcf9c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(* service definition | |
message SeekRequest { | |
string subscription = 1; | |
oneof target { | |
google.protobuf.Timestamp time = 2; | |
string snapshot = 3; | |
} | |
} | |
message SeekResponse { | |
} | |
service Subscriber { | |
rpc Seek(SeekRequest) returns (SeekResponse); | |
} | |
*) | |
(* option 1: explicit Request/Response messages *) | |
module SeekRequest : sig | |
(** The time to seek to. *) | |
type target = Time of Ptime.t | Snapshot of string | |
(** Request for the `Seek` method. *) | |
type t = { | |
subscription : string; | |
target : target; | |
} | |
end | |
module SeekResponse : sig | |
type t = unit | |
end | |
module Subscriber : sig | |
val seek : SeekRequest.t -> SeekResponse.t | |
end | |
(* option 2: partial import as labelled arguments *) | |
module SeekRequest : sig | |
type target = Time of Ptime.t | Snapshot of string | |
end | |
module Subscriber : sig | |
val seek : subscription:string -> target:SeekRequest.target -> unit | |
end | |
(* option 3: full import w/ polymorphic variants *) | |
module Subscriber : sig | |
val seek : subscription:string -> target:[< `Time of Ptime.t | `Snapshot of string] -> unit | |
end | |
(* option 4: full import w/ optional arguments *) | |
module Subscriber : sig | |
val seek : ?time:Ptime.t -> ?snapshot:string -> subscription:string -> unit | |
end | |
(* option 5: full import w/ function duplication for every oneof permutation *) | |
module Subscriber : sig | |
val seek_time : subscription:string -> time:Ptime.t -> unit | |
val seek_snapshot : subscription:string -> snapshot:string -> unit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment