NAME

rpctiny - command line client and test worker for RPC-Switch

SYNOPSIS

rpctiny [-H <host:port>] [-S] [-C <cert>] [-K <key>] [-V <cafile>]
        [-A <auth_method>] [-l <login>] [-c <config>] [-t <timeout>]
        [-m <method>] [-v|-q] [-j] [<json-param>]

rpctiny -w|-W <workername> [-a <maxasync>] [-F] [-m <method>]
        [connection options] ['{ <worker-code> }']

rpctiny -h

DESCRIPTION

rpctiny connects to an RPC-Switch server with the RPC::Switch::Client::Tiny module.

In client mode it calls a method and prints the result. The params are given as a single json or perl-format argument.

In worker mode (-w or -W) it announces a method and handles the incoming requests until it is stopped with ctrl-c. The handler is the given perl code block, or a builtin pong handler.

OPTIONS

-H host:port

rpc-switch address and port. The default is 127.0.0.1 with port 6551, or port 6850 when TLS is used.

-S

Use TLS for the rpc-switch connection. This defaults the auth method to clientcert.

-C cert

TLS client certificate file.

-K key

TLS client key file.

-V cafile

CA file to verify the server certificate.

-A auth_method

Auth method. The default is password, or clientcert with -S.

-l login[:token]

Login name and optional token. The default is looked up in ~/.netrc, else theEmployee.

-c config

Read the connection settings from the [rpc-switch] section of an ini-style config file (see "CONFIGURATION").

-m method

Method to call or announce. The client default is rpcswitch.ping, the worker default is bar.add:$USER. A method:platform suffix selects a platform, as a request param for calls and as a worker filter.

-t timeout

Timeout for rpc responses.

-w

Start a test worker. An optional '{ ... }' argument is used as the handler sub body, which gets the request params as first argument.

-W workername

Like -w, with the given worker name instead of pingpong.

-a maxasync

Run up to maxasync forked workers using async RES_WAIT notification.

-F

Use flowcontrol in async worker mode.

-v

Verbose, print the request trace and the resolved config.

-q

Quiet, just print the result (default).

-j

Pretty-print json output.

-h

Print the usage and the resolved config.

CONFIGURATION

The config file given by -c uses an ini-style [rpc-switch] section. The supported keys are address, port, who, token, auth_method, tls, tls_cert, tls_key, tls_ca and netrc. Command line options override the config file.

[rpc-switch]
address = 127.0.0.1
port = 6850
tls = 1
tls_cert = rpcclient.crt
tls_key = rpcclient.pem

If no login is given, who and token are read from ~/.netrc. The machine entries are tried in the order netrc config value, address:port, and address.

EXAMPLES

rpctiny -m rpcswitch.ping
rpctiny -m rpcswitch.get_methods -j
rpctiny -m rpcswitch.get_method_details -j '{"method": "foo.add"}'
rpctiny -m foo.add -v '{"counter": 10, "step": 2}'
rpctiny -m other.ping:test '{val => "tiny"}'

rpctiny -w -m bar.add '{ my ($params) = @_; return {msg => "got $params->{val}"} }'

SEE ALSO

RPC::Switch::Client::Tiny, https://github.com/a6502/rpc-switch

AUTHORS

Barnim Dzwillo @ Strato AG

COPYRIGHT AND LICENSE

Copyright (C) 2022 by Barnim Dzwillo

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.