コード例 #1
0
ファイル: consoles.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #2
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,
        },
    )
コード例 #3
0
ファイル: parts.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #4
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,
        },
    )
コード例 #5
0
ファイル: clusters.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #6
0
ファイル: servers.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #7
0
ファイル: parts.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #8
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,
        },
    )
コード例 #9
0
ファイル: parts.py プロジェクト: clchiou/garage
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,
        },
    )
コード例 #10
0
ファイル: demo_params.py プロジェクト: clchiou/garage
from g1.apps import parameters
from g1.apps import utils
from g1.bases import labels

LABELS = labels.make_labels(
    __name__,
    'f',
    'x',
)

PARAMS = parameters.define(
    __name__,
    parameters.Namespace(x=parameters.Parameter(0)),
)

utils.depend_parameter_for(LABELS.x, PARAMS.x)


def square(x):
    return x * x


@startup
def bind(x: LABELS.x) -> LABELS.f:
    x = x.get()
    return lambda: square(x)


def main(f: LABELS.f):
    print('f() = %d' % f())
    return 0
コード例 #11
0
ファイル: parts.py プロジェクト: clchiou/garage
    # shutdown_agents.
    'shutdown_queue',
)

PARAMS = parameters.define(
    agents.__name__,
    parameters.Namespace(grace_period=parameters.Parameter(4,
                                                           type=(int, float),
                                                           unit='seconds'), ),
)

startup.set(LABELS.agent_queue, tasks.CompletionQueue())
startup.set(LABELS.graceful_exit, locks.Event())
startup.set(LABELS.shutdown_queue, queues.Queue())

utils.depend_parameter_for(LABELS.grace_period, PARAMS.grace_period)

utils.define_binder(
    agents.supervise_agents,
    LABELS.supervise_agents,
    {
        'agent_queue': LABELS.agent_queue,
        'graceful_exit': LABELS.graceful_exit,
        'grace_period': LABELS.grace_period,
    },
)


@startup
def spawn_shutdown_agents(
    agent_queue: LABELS.agent_queue,
コード例 #12
0
ファイル: monitors.py プロジェクト: clchiou/garage
def define_monitor():
    utils.depend_parameter_for(PARAMS_LABEL, PARAMS)
    utils.define_maker(make_monitor)
コード例 #13
0
from g1.apps import utils
from g1.bases import labels
from g1.threads import futures

import g1.threads.parts

LABELS = labels.make_labels(
    __name__,
    '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)