Other modules

quickrpc.announcer_api module

module ‘quickrpc.announcer_api’ undocumented

class quickrpc.announcer_api.AnnouncerAPI(codec='jrpc', transport=None, security='null', invert=False, async_processing=False)[source]

Bases: quickrpc.remote_api.RemoteAPI

AnnouncerAPI provides a means of discovering services in some kind of distributed system.

“Clients” broadcast a seek call. All “servers” who feel spoken to respond with an advertise call to the seeker.

advertise(receivers=None, description='')[source]

Advertise that I am present.

Usually the advertisement should be sent only to the seeker, in return of seek().

description is a to-be-defined expression or structure giving details about service type, version, etc.

seek(sender, filter='')[source]

Request advertising of present services.

filter is a to-be-defined expression or data structure specifying the services that are wanted.

quickrpc.announcer_api.make_announcer(transport, description='', filter_func=None, codec=<quickrpc.terse_codec.TerseCodec object>)[source]

Returns a ready-to-use announcer server running over the given transport.

Sets the transport’s API.

description is the service description to hand out.

filter_func is a predicate accepting the filter parameter of AnnouncerAPI.seek and returning True if the filter matches this service. If left out, it is assumed to be always True.

All you need to do afterwards is to call transport.start(). Keep a reference to the transport.

quickrpc.announcer_api.make_udp_announcer(port, description='', filter_func=None, codec=<quickrpc.terse_codec.TerseCodec object>)[source]

makes an annoncer using UdpTransport(port) and returns it.

Start/stop with announcer.transport.start() / .stop().

quickrpc.echo_api module

EchoAPI: simple chat server.

Demonstrates use of RemoteAPI as well as StdioTransport and TcpServerTransport.

The server responds to a “say” call with “echo” of the text to all clients. The message “quit”:

  • if coming from stdio, shuts the server down
  • if coming over a tcp connection, makes the server close the connection.

Run with python3 -m quickrpc.echo_api. Enter json messages on the commandline to test stdio transport. Use telnet localhost 8888 to test tcp functionality. Use tail -F echo_api.log in another terminal to watch logged events.

class quickrpc.echo_api.EchoAPI(codec='jrpc', transport=None, security='null', invert=False, async_processing=False)[source]

Bases: quickrpc.remote_api.RemoteAPI

Demo of how to use RemoteAPI.

Echo API answers incoming say calls with an echo call.

echo(receivers=None, text='')[source]

method ‘quickrpc.echo_api.EchoAPI.echo’ undocumented

quit(sender='')[source]

method ‘quickrpc.echo_api.EchoAPI.quit’ undocumented

say(sender='', text='')[source]

method ‘quickrpc.echo_api.EchoAPI.say’ undocumented

quickrpc.echo_api.L()

function ‘quickrpc.echo_api.L’ undocumented

quickrpc.echo_api.test()[source]

function ‘quickrpc.echo_api.test’ undocumented

quickrpc.util module

module ‘quickrpc.util’ undocumented

quickrpc.util.subclasses(cls)[source]

function ‘quickrpc.util.subclasses’ undocumented

quickrpc.util.paren_partition(text)[source]

pop first parenthesized expression from a string.

The text must start with one of ({[<. The function finds the matching closing paren, then returns a tuple of (paren_content, paren, rest):

  • paren_content is the text in parens, without the actual parens
  • paren is the opening paren
  • rest is what comes after the closing paren.
>>> paren_partition('(a (contrived) example)(foo)bar')
('a (contrived) example', '(', '(foo)bar')