Exemple #1
0
def start_actor(actor_type, **kwargs):
    configure_logging(level=CONFIG.log_level)
    if CONFIG.sentry_enable:
        sentry_init(CONFIG.sentry_dsn)
    backdoor.setup()
    is_scheduler = actor_type == 'scheduler'
    actors = list(collect_actors(f'rssant_{actor_type}'))
    if not is_scheduler:
        actors.extend([
            do_update_registery,
            do_keepalive,
            do_dns_service_update,
        ])
        kwargs.update(
            on_startup=[on_startup],
            on_shutdown=[on_shutdown],
        )
    start_actor_cli(
        actor_type=actor_type,
        actors=actors,
        registery_node_spec=CONFIG.registery_node_spec,
        schema_compiler=schema_compiler,
        storage_dir_path=CONFIG.actor_storage_path,
        storage_compact_wal_delta=CONFIG.actor_storage_compact_wal_delta,
        queue_max_complete_size=CONFIG.actor_queue_max_complete_size,
        max_retry_time=CONFIG.actor_max_retry_time,
        max_retry_count=CONFIG.actor_max_retry_count,
        token=CONFIG.actor_token,
        **kwargs
    )
Exemple #2
0
    for node in ctx.registery.remote_nodes:
        LOG.info('ping node {}'.format(node.name))
        await ctx.tell('worker.ping', {'message': 'ping'}, dst_node=node.name)
    for node in ctx.registery.remote_nodes:
        LOG.info('ask node {} begin'.format(node.name))
        r = await ctx.ask('worker.local_ask', {'message': 'ping'},
                          dst_node=node.name)
        LOG.info('ask node {} done: {}'.format(node.name, r))


@actor('registery.query')
async def do_query(ctx: ActorContext) -> T.dict(nodes=T.list(NodeSpecSchema)):
    return dict(nodes=ctx.registery.to_spec())


ACTORS = collect_actors(__name__)


def main():
    backdoor.setup()
    app = ActorNode(
        actors=ACTORS,
        port=8081,
        name='registery',
        storage_dir_path='data/actorlib_example_registery',
    )
    app.run()


if __name__ == "__main__":
    from rssant_common.logger import configure_logging