1 =Remote Procedure Call=
2 Databoard RPC is a method call interface.
3 Server is an object that handles service requests.
4 The server publishes an [[#Interfaces]] that contains a list of callable methods.
7 The protocol is very simple. There are two conversing peers, one is ''the client'' and the other ''the server''.
8 Both parties introduce callable ''network interface''. Typically, the server's has plenty of procedures, and client's
10 The connection starts with handshake and is then followed by repeating conversation of writing ''Requests'' and reading ''Responses''.
12 In handshake, boths peers write their ''InterfaceDescription'' and message size limits.
13 (See [[#Definitions|Definitions]]).
14 Then both parties make a decision to whether accept or reject the other's interface.
17 ''A function type'' can be constructed as <tt>D -> R</tt>, where <tt>D</tt> is the domain and <tt>R</tt> the range of the function.
18 If the function can throw exceptions, it is denoted as <tt>D -> R throws E<sub>1</sub>, ..., E<sub>k</sub></tt>, where
19 <tt>E<sub>i</sub></tt> is a datatype for an exception. Multi-parameter types can be defined using the tuple notation:
22 (Integer,Integer) -> Integer
23 Integer -> Integer throws IndexOutOfRange
25 ''A method definition'' is a combination of name and method type.
26 The format is following, <tt>method M : T</tt>, where <tt>M</tt> is the name and <tt>T</tt> the type of the method.
27 <tt>T</tt> has to be a function type.
28 method getSamples : TimeSegment -> Sample[],
29 method read : ReadRequest -> Sample,
30 method getValueBounds : TimeSegment -> Sample[2]
32 ''Interface'' is a specification of fields and methods the interface has to have.
33 The interface is defined as a record that contains fields and methods definitions in the curly braces.
34 interface HistoryRecord = {
37 method getSamples : TimeSegment -> Sample[],
38 method read : ReadRequest -> Sample,
39 method getValueBounds : TimeSegment -> Sample[2]
42 Interfaces may extend other interfaces. This is denoted as <tt>interface I extends B<sub>1</sub>, ..., B<sub>k</sub> { ... }</tt>.
43 interface MutableHistoryRecord extends HistoryRecord = {
44 method write : Sample[] -> {},
45 method clear : {} -> {}
49 Client sends RequestHeader, followed by a serialization of the message's request argument.
50 The datatype and thus serialization format of the request argument was defined in MethodType which was informed by the server in the handshake.
52 The server processes the procedure request.
53 * On procedure success, ResponseHeader is sent, followed by a serialization of ResponseType. ResponseType serialization format was declared in MethodType.
54 * On procedure failure, ExecutionError_ is sent, followed by a serialization of ErrorType. ErrorType format was declared in MethodType.
55 * On unexpected error, Exception_ is sent
56 * On invalid method number, InvalidMethodError is sent
57 * On request or response message size exceeded, ResponseTooLargeError is sent
62 methodDefinitions : Map(MethodTypeDefinition, {})
65 type InterfaceDefinition = {
71 requestType : DataType,
72 responseType : DataType,
76 type MethodTypeDefinition = {
81 type Handshake = | Version0
84 recvMsgLimit : Integer,
85 sendMsgLimit : Integer,
86 methods : MethodTypeDefinition[]
89 type Message = | RequestHeader RequestHeader
90 | ResponseHeader ResponseHeader
91 | ExecutionError_ ExecutionError_
92 | Exception_ Exception_
93 | InvalidMethodError InvalidMethodError
94 | ResponseTooLarge ResponseTooLarge
96 type RequestHeader = {
101 type ResponseHeader = {
105 type ExecutionError_ = {
109 type InvalidMethodError = {
118 type ResponseTooLarge = {