package streamable

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file versioned_plain_rpc_intf.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
open! Core
open! Async_kernel
open! Import

module type Caller_converts = sig
  type query
  type response

  val dispatch_multi
    :  Versioned_rpc.Connection_with_menu.t
    -> query
    -> response Deferred.Or_error.t

  val name : string
end

module type Callee_converts = sig
  type query
  type response

  val implement_multi
    :  ?on_exception:Rpc.On_exception.t (** default: [On_exception.continue] **)
    -> ('conn_state -> version:int -> query -> response Deferred.Or_error.t)
    -> 'conn_state Rpc.Implementation.t list

  val name : string
end

module type Both_convert = sig
  type caller_query
  type caller_response
  type callee_query
  type callee_response

  val dispatch_multi
    :  Versioned_rpc.Connection_with_menu.t
    -> caller_query
    -> caller_response Deferred.Or_error.t

  val implement_multi
    :  ?on_exception:Rpc.On_exception.t (** default: [On_exception.continue] **)
    -> ('conn_state -> version:int -> callee_query -> callee_response Deferred.Or_error.t)
    -> 'conn_state Rpc.Implementation.t list

  val name : string
end

module type Versioned_plain_rpc = sig
  module type Caller_converts = Caller_converts
  module type Callee_converts = Callee_converts
  module type Both_convert    = Both_convert

  module Caller_converts : sig
    module type S = Caller_converts

    module Make (Model : sig
        val name : string

        type query
        type response
      end) : sig
      module Register (Version : sig
          val version : int

          type query [@@deriving bin_io]
          type response

          module Response : Main.S_rpc with type t = response

          val query_of_model : Model.query -> query
          val model_of_response : response -> Model.response
          val client_pushes_back : bool
        end) : sig
        val rpc : (Version.query, Version.response) Plain_rpc.t

        (** [implement'] is like [Plain_rpc.implement rpc] except that it allows the
            server to control the conversion from the [response] to parts. *)
        val implement'
          :  ?on_exception:Rpc.On_exception.t (** default: [On_exception.continue] **)
          -> ('conn_state
              -> Version.query
              -> Version.Response.Intermediate.Part.t Pipe.Reader.t Deferred.Or_error.t)
          -> 'conn_state Rpc.Implementation.t
      end

      include S with type query := Model.query with type response := Model.response
    end
  end

  module Callee_converts : sig
    module type S = Callee_converts

    module Make (Model : sig
        val name : string

        type query
        type response
      end) : sig
      module Register (Version : sig
          val version : int

          type query [@@deriving bin_io]
          type response

          module Response : Main.S_rpc with type t = response

          val model_of_query     : query -> Model.query
          val response_of_model  : Model.response -> response
          val client_pushes_back : bool
        end) : sig
        val rpc : (Version.query, Version.response) Plain_rpc.t

        (** [implement'] is like [Plain_rpc.implement rpc] except that it allows the
            server to control the conversion from the [response] to parts. *)
        val implement'
          :  ?on_exception:Rpc.On_exception.t (** default: [On_exception.continue] **)
          -> ('conn_state
              -> Version.query
              -> Version.Response.Intermediate.Part.t Pipe.Reader.t Deferred.Or_error.t)
          -> 'conn_state Rpc.Implementation.t
      end

      include S with type query := Model.query with type response := Model.response
    end
  end

  module Both_convert : sig
    module type S = Both_convert

    module Make (Model : sig
        val name : string

        module Caller : sig
          type query
          type response
        end

        module Callee : sig
          type query
          type response
        end
      end) : sig
      open Model

      module Register (Version : sig
          val version : int

          type query [@@deriving bin_io]
          type response

          module Response : Main.S_rpc with type t = response

          val query_of_caller_model    : Caller.query -> query
          val callee_model_of_query    : query -> Callee.query
          val response_of_callee_model : Callee.response -> response
          val caller_model_of_response : response -> Caller.response
          val client_pushes_back       : bool
        end) : sig
        val rpc : (Version.query, Version.response) Plain_rpc.t

        (** [implement'] is like [Plain_rpc.implement rpc] except that it allows the
            server to control the conversion from the [response] to parts. *)
        val implement'
          :  ?on_exception:Rpc.On_exception.t (** default: [On_exception.continue] **)
          -> ('conn_state
              -> Version.query
              -> Version.Response.Intermediate.Part.t Pipe.Reader.t Deferred.Or_error.t)
          -> 'conn_state Rpc.Implementation.t
      end

      include
        S
        with type caller_query    := Caller.query
        with type caller_response := Caller.response
        with type callee_query    := Callee.query
        with type callee_response := Callee.response
    end
  end
end
OCaml

Innovation. Community. Security.