Client Specification#

This specification states what a kRPC client library does on top of the messaging protocol. It covers the behavior a program sees, such as how a client reports a refused connection, matches responses to calls and delivers stream values.

The requirements are generated from the conformance tests. Each requirement has a test that checks it, and the text and the test are one source. A change to a requirement is a change to its test, so the two cannot drift apart. The tests run against the TestServer, a server that runs without the game.

This specification is versioned with kRPC. The conformance tests in the krpctools package of a release check the specification of that release.

See also

Client Design covers how the kRPC clients are built, for ideas when designing your own.

Requirements#

Each requirement has an id of the form <area>-<name>, such as streams-wait. The area is one page of this specification:

Area

Covers

connection

Opening, reading and closing a connection

calls

Calling the members of a service, passing arguments, and matching responses to calls

values

The values passed as arguments and read back as results

codec

Encoding and decoding values

errors

The errors reported for errors returned by the server

objects

The objects held for instances of a server’s classes

streams

Adding streams, reading their values and removing them

events

Waiting on events and calling back on them

concurrency

Using one connection from several threads or async tasks

functions

Streaming, running and waiting on server side functions

The conformance test for a requirement is named after it. The test for streams-wait is test_wait in test_streams.py. The text of a requirement is the docstring of its test. The results of the clients in this repository are listed under Client Coverage.

The key words MUST and SHOULD are used as described in RFC 2119. A requirement marked SHOULD holds unless a client has a reason recorded in its documentation.

Profiles#

Each requirement is listed with the profiles a client needs to run its test, then its level:

connection-serialio-leftovers [serialio] [MUST]

A requirement marked MUST holds in every client that implements its profiles. A requirement listed without a profile applies only to the clients that do not implement it:

errors-message-prefix [core, without error-types] [MUST]

A client implements the core profile, and any of the others:

Profile

Covers

core

Connecting, calls, values, errors and objects

error-types

Error types: a remote error type the client’s own errors derive, and a type for each exception a service lists

dynamic

Checking and converting arguments at run time, and calls a static type system rules out

definitions

Building the services from the server’s definitions when connecting

declarations

Generated enumerations and structures, used with no connection and shared where the server’s definitions match

defaults

Omitting arguments that have defaults

named-arguments

Passing arguments by name at run time

skipped-arguments

Skipping an argument by position, so that it takes its default

streams

Adding streams, reading and waiting on their values, and removing them

callbacks

Calling back on stream updates, firings and stream ends

conditions

Holding the condition of a stream or event to read and wait on it

events

Events

functions

Streams, events and runs of server side functions

function-types

Checking the type a program names for the value of a server side function

connections

Several connections open at once, sharing objects

bound-classes

Calling a class’s static methods through the class bound to a connection, in a language where a class is a type

concurrency

Concurrent calls, waits, callbacks and closes, on threads or async tasks

ordering

Ordering objects, in a language that orders values

races

Forcing races between the update thread and the program, by pausing a thread of the client

tcpip, localsocket, serialio, websockets

The communication protocols