Subscriptions

class uwsgiconf.options.subscriptions.Subscriptions(*args, **kwargs)

This allows some uWSGI instances to announce their presence to subscriptions managing server, which in its turn can address those nodes (e.g. delegate request processing to them) and automatically remove dead nodes from the pool.

Some routers provide subscription server functionality. See .routing.routers.

Note

Subscription system in many ways relies on Master Process.

Warning

The subscription system is meant for “trusted” networks. All of the nodes in your network can potentially make a total mess with it.

class algorithms

Balancing algorithms available to use with subscribe.

ip_hash

alias of uwsgiconf.options.subscriptions_algos.IpHash

least_reference_count

alias of uwsgiconf.options.subscriptions_algos.LeastReferenceCount

weighted_least_reference_count

alias of uwsgiconf.options.subscriptions_algos.WeightedLeastReferenceCount

weighted_round_robin

alias of uwsgiconf.options.subscriptions_algos.WeightedRoundRobin

set_server_params(client_notify_address=None, mountpoints_depth=None, require_vassal=None, tolerance=None, tolerance_inactive=None, key_dot_split=None)

Sets subscription server related params.

Parameters:
  • client_notify_address (str|unicode) – Set the notification socket for subscriptions. When you subscribe to a server, you can ask it to “acknowledge” the acceptance of your request. pointing address (Unix socket or UDP), on which your instance will bind and the subscription server will send acknowledgements to.
  • mountpoints_depth (int) –

    Enable support of mountpoints of certain depth for subscription system.

  • require_vassal (bool) – Require a vassal field (see subscribe) from each subscription.
  • tolerance (int) – Subscription reclaim tolerance (seconds).
  • tolerance_inactive (int) – Subscription inactivity tolerance (seconds).
  • key_dot_split (bool) – Try to fallback to the next part in (dot based) subscription key. Used, for example, in SNI.
set_server_verification_params(digest_algo=None, dir_cert=None, tolerance=None, no_check_uid=None, dir_credentials=None, pass_unix_credentials=None)

Sets peer verification params for subscription server.

These are for secured subscriptions.

Parameters:
  • digest_algo (str|unicode) –

    Digest algorithm. Example: SHA1

    Note

    Also requires dir_cert to be set.

  • dir_cert (str|unicode) –

    Certificate directory.

    Note

    Also requires digest_algo to be set.

  • tolerance (int) – Maximum tolerance (in seconds) of clock skew for secured subscription system. Default: 24h.
  • no_check_uid (str|unicode|int|list[str|unicode|int]) – Skip signature check for the specified uids when using unix sockets credentials.
  • dir_credentials (str|unicode|list[str|unicode]) – Directories to search for subscriptions key credentials.
  • pass_unix_credentials (bool) – Enable management of SCM_CREDENTIALS in subscriptions UNIX sockets.
set_client_params(start_unsubscribed=None, clear_on_exit=None, unsubscribe_on_reload=None, announce_interval=None)

Sets subscribers related params.

Parameters:
  • start_unsubscribed (bool) – Configure subscriptions but do not send them. .. note:: Useful with master FIFO.
  • clear_on_exit (bool) – Force clear instead of unsubscribe during shutdown.
  • unsubscribe_on_reload (bool) – Force unsubscribe request even during graceful reload.
  • announce_interval (int) – Send subscription announce at the specified interval. Default: 10 master cycles.
subscribe(server=None, key=None, address=None, address_vassal=None, balancing_weight=None, balancing_algo=None, modifier=None, signing=None, check_file=None, protocol=None, sni_cert=None, sni_key=None, sni_client_ca=None)

Registers a subscription intent.

Parameters:
  • server (str|unicode) –

    Subscription server address (UDP or UNIX socket).

    Examples:
    • 127.0.0.1:7171
  • key (str|unicode) –

    Key to subscribe. Generally the domain name (+ optional ‘/< mountpoint>’). Examples:

    • mydomain.it/foo
    • mydomain.it/foo/bar (requires mountpoints_depth=2)
    • mydomain.it
    • ubuntu64.local:9090
  • address (str|unicode) – Address to subscribe (the value for the key) or zero-based internal socket number (integer).
  • address – Vassal node address.
  • balancing_weight (int) – Load balancing value. Default: 1.
  • balancing_algo – Load balancing algorithm to use. See balancing_algorithms .. note:: Since 2.1
  • modifier (Modifier) – Routing modifier object. See .routing.modifiers
  • signing (list|tuple) –

    Signing basics, expects two elements list/tuple: (signing_algorithm, key).

    Examples:
    • SHA1:idlessh001
  • check_file (str|unicode) – If this file exists the subscription packet is sent, otherwise it is skipped.
  • protocol (str|unicode) –

    the protocol to use, by default it is uwsgi. See .networking.socket_types.

    Note

    Since 2.1

  • sni_cert (str|unicode) – Certificate file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni
  • sni_key (str|unicode) – sni_key Key file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni
  • sni_client_ca (str|unicode) – Ca file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni