-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor commands.py into multiple packages and modules
- Loading branch information
Swen
committed
Sep 16, 2021
1 parent
6e1c1ea
commit afbecbf
Showing
56 changed files
with
1,702 additions
and
1,404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from esque.cli.options import State | ||
from esque.controller.consumergroup_controller import ConsumerGroupController | ||
from esque.resources.broker import Broker | ||
|
||
|
||
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)] | ||
|
||
|
||
def list_consumergroups(ctx, args, incomplete): | ||
state = ctx.ensure_object(State) | ||
return [ | ||
group | ||
for group in ConsumerGroupController(state.cluster).list_consumer_groups() | ||
if group.startswith(incomplete) | ||
] | ||
|
||
|
||
def list_contexts(ctx, args, incomplete): | ||
state = ctx.ensure_object(State) | ||
return [context for context in state.config.available_contexts if context.startswith(incomplete)] | ||
|
||
|
||
def list_topics(ctx, args, incomplete): | ||
state = ctx.ensure_object(State) | ||
cluster = state.cluster | ||
return [ | ||
topic.name for topic in cluster.topic_controller.list_topics(search_string=incomplete, get_topic_objects=False) | ||
] |
Oops, something went wrong.