Exemple #1
0
            client = store.client()
            try:
                yield client.ping()
            except pulsar.ConnectionRefusedError:
                host = localhost(store._host)
                if not host:
                    raise
                cfg = yield send('arbiter', 'run', start_pulsar_ds,
                                 host, workers)
                store._host = cfg.addresses[0]
                dns = store._buildurl()
                store = create_store(dns, **kw)
        coroutine_return(store)

    def localhost(host):
        if isinstance(host, tuple):
            if host[0] in ('127.0.0.1', ''):
                return ':'.join((str(b) for b in host))
        else:
            return host

    def _start_store(monitor):
        app = monitor.app
        if not isinstance(app, PulsarDS):
            dns = app.cfg.data_store
            if dns:
                store = yield start_store(dns)
                app.cfg.set('data_store', store.dns)

    when_monitor_start.append(_start_store)
Exemple #2
0
    if store.name == 'pulsar':
        client = store.client()
        try:
            await client.ping()
        except ConnectionRefusedError:
            host = localhost(store._host)
            if not host:
                raise
            cfg = await send('arbiter', 'run', start_pulsar_ds, host, workers)
            store._host = cfg.addresses[0]
            dns = store.buildurl()
            store = create_store(dns, **kw)
    app.cfg.set('data_store', store.dns)


def localhost(host):
    if isinstance(host, tuple):
        if host[0] in ('127.0.0.1', ''):
            return ':'.join((str(b) for b in host))
    else:
        return host


def _start_store(monitor):
    app = monitor.app
    if not isinstance(app, PulsarDS) and app.cfg.data_store:
        return start_store(app, app.cfg.data_store)


when_monitor_start.append(_start_store)