Marco methods

class marcopolo.bindings.marco.Marco(timeout=1000, group='224.0.0.112')
__init__(timeout=1000, group='224.0.0.112')
marco(max_nodes=None, exclude=[], params={}, timeout=None, retries=0)

C struct node * marco(int timeout)

C++ std::vector<node> marco(int timeout)

Java ArrayList<Node> marco(int timeout)

Sends a marco message to all nodes, which reply with a Polo message. Upon receiving all responses (those which arrived before the timeout), a collection of the response information is returned.

Parameters:
  • max_nodes (int) – Maximum number of nodes to be returned. If set to None, no limit is applied.
  • exclude (list) – List of nodes to be excluded from the returned ValueError.
  • timeout (int) – If set, overrides the default timeout value.
  • retries (int) – If set to a value greater than 0, retries the retries times if the first attempt is unsuccessful
Returns:

A list of all responding nodes.

request_for(service, node=None, max_nodes=None, exclude=[], params={}, timeout=None)

C: struct node * request_for(const char * service)

C++: std::vector<std::string> request_for(wchar_t* service)

Java: ArrayList<Nodo> request_for(String service)

Request all nodes offering a service.

Parameters:
  • service (string) – The name of the service to look for
  • node (string) – If defined, the function acts as a probe to check if the given node has the service.
  • timeout (int) – If set to an integer, the resolver will override its local timeout parameter and use this instead for the resolving process.

Please note that the function will block the execution of the thread until the timeout in the Marco configuration file is triggered. Though this should not be a problem for most application, it is worth knowing.

Returns:

A list of nodes offering the requested service.

Rvalue:

set()

Raise:
MarcoTimeOutException:
 If no connection can be made to the local resolver (probably due a failure start of the daemon).
request_one_for(exclude=[], timeout=None)

Returns one node picked at random from the responses (more precisely, the first replying node) or the one which first satisfies the given exclusion criteria. This function is equivalent to request_for with max_nodes=1

Parameters:
  • exclude (list) – List of nodes not to be included in the response.
  • timeout (int) – If set, overrides the default timeout value.
Returns:

The picked node

Rvalue:

Node

services(node, timeout=None)

Returns all the services available in the node identified by the given node. In the event that the node does not reply to the response, a exception will be raised.

C struct service * services(char * node, int timeout)

C++ std::vector<service> services(std::string node, int timeout)

Java ArrayList<Service> services(string node, int timeout)

Parameters:
  • node (string) – The node to ask
  • timeout (int) – If set, overrides the default timeout value.
Returns:

A list of the services offered by a node.

Rvalue:

set()

Exceptions

class marcopolo.bindings.marco.MarcoTimeOutException

Raised if a timeout occurs

class marcopolo.bindings.marco.MarcoInternalError

Raised if an internal exception occurs