RPCClient.batch

Execute a batch of function calls.

class RPCClient(API, Transport = TCPTransport)
Response[long]
batch
(
BatchRequest[] requests...
)
if (
is(API == interface) &&
isTransport!Transport
)

Parameters

requests BatchRequest[]

A list of BatchRequests, each constructed via the batchReq function.

Return Value

Type: Response[long]

An array of Response objects, in the same order as the respective request.

Notes: Notifications do not get responses; if three requests are made, and one is a notification, only two responses will be returned.

Examples

import std.typecons : Yes;

interface API {
    void func1(int a);
    long func2(string s);
    long func3();
}
auto client = RPCClient!API("localhost", 54321);

auto responses = client.batch(
        batchReq("func1", JSONValue(50)),
        batchReq("func1", JSONValue(-1), Yes.notify),
        batchReq("func2", JSONValue("hello")),
        batchReq("func3", JSONValue(), Yes.notify),
        batchReq("func1", JSONValue(123))
);

Meta