示例#1
0
文件: commands.py 项目: Temikus/esque
def describe_broker(state: State, broker: str, output_format: str):
    """Return configuration options for broker BROKER. BROKER can be given with broker id (integer),
    the host name (if hostname is unique), or socket address ('hostname:port')"""
    if broker.isdigit():
        broker = Broker.from_id(state.cluster, broker).describe()
    elif ":" not in broker:
        broker = Broker.from_host(state.cluster, broker).describe()
    else:
        try:
            host, port = broker.split(":")
            broker = Broker.from_host_and_port(state.cluster, host, int(port)).describe()
        except ValueError:
            raise ValidationException("BROKER must either be the broker id, the hostname, or in the form 'host:port'")

    click.echo(format_output(broker, output_format))
示例#2
0
文件: commands.py 项目: Temikus/esque
def get_brokers(state: State, output_format: str):
    """List all brokers.

    Return the broker id's and socket addresses of all the brokers in the kafka cluster defined in the current context.
    """
    brokers = Broker.get_all(state.cluster)
    broker_ids_and_hosts = [f"{broker.broker_id}: {broker.host}:{broker.port}" for broker in brokers]
    click.echo(format_output(broker_ids_and_hosts, output_format))
示例#3
0
文件: commands.py 项目: Temikus/esque
def list_brokers(ctx, args, incomplete):
    state = ctx.ensure_object(State)
    all_broker_hosts_names = [f"{broker.host}:{broker.port}" for broker in Broker.get_all(state.cluster)]
    return [broker for broker in all_broker_hosts_names if broker.startswith(incomplete)]
示例#4
0
def broker_host_and_port(state: State) -> str:
    brokers = Broker.get_all(state.cluster)
    return "{}:{}".format(brokers[0].host, brokers[0].port)
示例#5
0
def broker_host(state: State) -> str:
    brokers = Broker.get_all(state.cluster)
    return brokers[0].host
示例#6
0
def broker_id(state: State) -> str:
    brokers = Broker.get_all(state.cluster)
    return str(brokers[0].broker_id)