def test_make_nested_labels(self): self.assertEqual( flatten( labels.make_nested_labels( 'foo.bar', # Strings are iterables, too (this may be confusing # sometimes). ('a', ('b', 'x'), ('c', (('y', 'z'), ))), ), ), ( ('a', 'foo.bar:a'), ('b.x', 'foo.bar:b.x'), ('c.y.z', 'foo.bar:c.y.z'), ), ) self.assertEqual( flatten( labels.make_nested_labels( 'foo.bar', (('a', ('x', 'y', 'z')), ), ), ), ( ('a.x', 'foo.bar:a.x'), ('a.y', 'foo.bar:a.y'), ('a.z', 'foo.bar:a.z'), ), )
def define_server(module_path=None, **kwargs): module_path = module_path or __package__ module_labels = labels.make_nested_labels(module_path, SERVER_LABEL_NAMES) setup_server( module_labels, parameters.define(module_path, make_server_params(**kwargs)), ) return module_labels
def define_subscriber(module_path=None, **kwargs): module_path = module_path or subscribers.__name__ module_labels = labels.make_nested_labels( module_path, SUBSCRIBER_LABEL_NAMES, ) setup_subscriber( module_labels, parameters.define(module_path, make_subscriber_params(**kwargs)), ) return module_labels
import g1.asyncs.agents.parts import g1.http.clients.parts.clusters import g1.threads.parts from g1.apps import asyncs from g1.apps import parameters from g1.apps import utils from g1.asyncs import kernels from g1.asyncs.bases import tasks from g1.bases import labels from g1.http import clients LABELS = labels.make_nested_labels( __name__, ( ('session', g1.http.clients.parts.clusters.SESSION_LABEL_NAMES), ('stub', g1.http.clients.parts.clusters.STUB_LABEL_NAMES), ), ) g1.http.clients.parts.clusters.setup_session( LABELS.session, parameters.define( __name__ + '.session', g1.http.clients.parts.clusters.make_session_params(), ), ) g1.http.clients.parts.clusters.setup_stub( LABELS.stub, parameters.define(