Module proxy
Proxy service for signals.
This module allows to wait on and receive signals emitted in a remote
Lumen instance, trough a socket.
Signals are serialized using bencode or json, and restrictions apply
on what can be passed trough depending on the encoder selected. For
example, under bencode strings, numbers, lists (pure arrays) and tables
with strings as keys are supported.
This module depends on the selector task, which must be started
separataly.
Usage:
local proxy = require 'lumen.proxy' -for accepting connections roxy.init({ip='*', port=1985}) -connect to a remote node ocal waitd = proxy.new_remote_waitd('192.1681.1', 1985, {'a_event_name', 'other_event_name'}) ched.wait(waitd, function(_, eventname, ...) print ('received signal', eventname, ...) nd)
Functions
new_remote_waitd (ip, port, waitd_table) | Creates a waitd object over a remote Lumen instance. |
init (conf) | Starts the proxy. |
Tables
conf | Configuration Table. |
Functions
- new_remote_waitd (ip, port, waitd_table)
-
Creates a waitd object over a remote Lumen instance.
The remote Lumen instance must have the proxy module started,
and available trough a known ip address.
The waitd_table is as the one used in plain _sched.new_waitd()_ call, with
the difference that the array part does not contain the events but the
names which will be queried in the remote node's "events" catalog.
There is an additional parameter, _name_timeout, which controls the querying
in the catalogs.
The obtained waitd will react with a non null event, followed by the event name
(as put in the waitdtable), followed by the parameters of the original event.
On timeout, returns nil, 'timeout'.
Parameters:
- ip ip of the remote proxy module.
- port port of the remote proxy module.
- waitd_table a wait descriptor.
Returns:
-
a waitd object
- init (conf)
-
Starts the proxy.
This starts the task that will accept incomming wait requests.
Parameters:
- conf the configuration table (see conf)