Ejemplo n.º 1
0
def setup_server(module_labels, module_params):
    utils.define_maker(
        make_server,
        {
            'create_engine': module_labels.database.create_engine,
            'publisher': module_labels.publisher.publisher,
            'return': module_labels.server.server,
        },
    )
    utils.define_maker(
        make_publisher,
        {
            'return': module_labels.publisher.publisher,
        },
    )
    g1.messaging.parts.servers.setup_server(
        module_labels.server,
        module_params.server,
    )
    g1.messaging.parts.publishers.setup_publisher(
        module_labels.publisher,
        module_params.publisher,
    )
    g1.databases.parts.setup_create_engine(
        module_labels.database,
        module_params.database,
    )
Ejemplo n.º 2
0
def setup_console(module_labels, module_params):
    utils.depend_parameter_for(module_labels.params, module_params)
    utils.define_maker(
        make_console,
        {
            'params': module_labels.params,
        },
    )
Ejemplo n.º 3
0
def setup_publisher(module_labels, module_params):
    utils.depend_parameter_for(module_labels.publisher_params, module_params)
    utils.define_maker(
        make_agent,
        {
            'publisher': module_labels.publisher,
            'params': module_labels.publisher_params,
        },
    )
Ejemplo n.º 4
0
def setup_executor(module_labels, module_params):
    utils.depend_parameter_for(module_labels.executor_params, module_params)
    utils.define_maker(
        make_executor,
        {
            'params': module_labels.executor_params,
            'return': module_labels.executor,
        },
    )
Ejemplo n.º 5
0
def setup_client(module_labels, module_params):
    utils.depend_parameter_for(module_labels.client_params, module_params)
    utils.define_maker(
        configure_client,
        {
            'client': module_labels.client,
            'params': module_labels.client_params,
        },
    )
Ejemplo n.º 6
0
def setup_stub(module_labels, module_params):
    utils.depend_parameter_for(module_labels.stub_params, module_params)
    utils.define_maker(
        make_stub,
        {
            'params': module_labels.stub_params,
            'return': module_labels.stub,
        },
    )
Ejemplo n.º 7
0
def setup_server(module_labels, module_params):
    utils.depend_parameter_for(module_labels.server_params, module_params)
    utils.define_maker(
        make_agent,
        {
            'server': module_labels.server,
            'params': module_labels.server_params,
        },
    )
Ejemplo n.º 8
0
def setup_create_engine(module_labels, module_params):
    utils.depend_parameter_for(module_labels.create_engine_params,
                               module_params)
    utils.define_maker(
        make_create_engine,
        {
            'params': module_labels.create_engine_params,
            'return': module_labels.create_engine,
        },
    )
Ejemplo n.º 9
0
def setup_session(module_labels, module_params):
    utils.depend_parameter_for(module_labels.session_params, module_params)
    utils.define_maker(
        make_session,
        {
            'params': module_labels.session_params,
            'executor': module_labels.executor,
            'return': module_labels.session,
        },
    )
Ejemplo n.º 10
0
def setup_server(module_labels, module_params):
    g1.networks.servers.parts.setup_server(module_labels.server, module_params)
    utils.define_maker(
        # Although this is called a server, from the perspective of
        # g1.networks.servers.SocketServer, this is a handler.
        servers.HttpServer,
        {
            'server_socket': module_labels.server.socket,
            'application': module_labels.application,
            'return': module_labels.server.handler,
        },
    )
Ejemplo n.º 11
0
def setup_server(module_labels, module_params):
    g1.http.servers.parts.setup_server(
        module_labels.server, module_params
    )
    utils.define_maker(
        wsgi_apps.Application,
        {
            'handler': module_labels.handler,
            'return': module_labels.server.application,
        },
    )
    utils.define_maker(
        make_agent,
        {
            'application': module_labels.server.application,
        },
    )
Ejemplo n.º 12
0
def setup_subscriber(module_labels, module_params):
    utils.define_maker(
        make_queue,
        {
            'return': module_labels.queue,
        },
    )
    utils.define_maker(
        subscribers.make_subscriber,
        {
            'queue': module_labels.queue,
            'return': module_labels.subscriber.subscriber,
        },
    )
    g1.messaging.parts.subscribers.setup_subscriber(
        module_labels.subscriber,
        module_params,
    )
Ejemplo n.º 13
0
def setup_server(module_labels, module_params):
    utils.depend_parameter_for(module_labels.params, module_params)
    # Server.
    utils.define_maker(
        make_socket_server,
        {
            'socket': module_labels.socket,
            'handler': module_labels.handler,
            'params': module_labels.params,
            'return': module_labels.server,
        },
    )
    utils.define_maker(
        make_agent,
        {
            'server': module_labels.server,
        },
    )
    # Server socket.
    utils.define_maker(
        make_server_socket,
        {
            'params': module_labels.params,
            'ssl_context': module_labels.ssl_context,
            'return': module_labels.socket,
        },
    )
    # SSL context.
    for name in (
        'certificate',
        'private_key',
        'client_authentication',
        'protocols',
    ):
        utils.depend_parameter_for(module_labels[name], module_params[name])
    utils.define_maker(
        sockets.make_ssl_context,
        {
            'certificate': module_labels.certificate,
            'private_key': module_labels.private_key,
            'client_authentication': module_labels.client_authentication,
            'protocols': module_labels.protocols,
            'return': module_labels.ssl_context,
        },
    )
Ejemplo n.º 14
0
def define_monitor():
    utils.depend_parameter_for(PARAMS_LABEL, PARAMS)
    utils.define_maker(make_monitor)
Ejemplo n.º 15
0
    'executor_params',
    'executor',
)

utils.depend_parameter_for(
    LABELS.executor_params,
    parameters.define(
        __name__,
        g1.threads.parts.make_executor_params(),
    ),
)

utils.define_maker(
    g1.threads.parts.make_executor,
    {
        'params': LABELS.executor_params,
        'return': LABELS.executor,
    },
)


def square(x):
    duration = random.uniform(0, 4)
    time.sleep(duration)
    answer = x * x
    print('computing: %d^2 is %d' % (x, answer))
    return answer, duration


def main(executor: LABELS.executor):
    start = time.perf_counter()
Ejemplo n.º 16
0
def setup_client(module_labels, module_params):
    utils.define_maker(clients.make_client, {'return': module_labels.client})
    g1.messaging.parts.clients.setup_client(module_labels, module_params)