Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: standardized cli #80

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/metricq/metricq-python:v4.2 AS builder
FROM ghcr.io/metricq/metricq-python:v5.4 AS builder
LABEL maintainer="mario.bielert@tu-dresden.de"

USER root
Expand All @@ -13,7 +13,7 @@ COPY --chown=metricq:metricq . /home/metricq/sink-nsca
WORKDIR /home/metricq/sink-nsca
RUN pip install --user .

FROM ghcr.io/metricq/metricq-python:v4.2
FROM ghcr.io/metricq/metricq-python:v5.4

USER root
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' > /etc/apt/sources.list.d/backports.list \
Expand Down
2 changes: 1 addition & 1 deletion metricq_sink_nsca/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from asyncio import CancelledError, gather, sleep
from typing import Dict, Iterable, NamedTuple, Optional, Set

from metricq.types import Timedelta, Timestamp
from metricq import Timedelta, Timestamp

from .logging import get_logger
from .plugin import Plugin
Expand Down
35 changes: 17 additions & 18 deletions metricq_sink_nsca/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import click
import click_log
from metricq.cli import metricq_command

from .logging import get_logger
from .reporter import ReporterSink
Expand Down Expand Up @@ -48,23 +49,21 @@ def _set_log_levels(_ctx, _param, value: str):
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


@click.command(context_settings=CONTEXT_SETTINGS)
@click.option("--metricq-server", "-s", default="amqp://localhost/")
@click.option("--token", "-t", default="sink-nsca")
@metricq_command(default_token="sink-nsca", client_version=None)
@click.option("--dry-run", "-n", is_flag=True)
@verbosity_option(root_logger)
def main(metricq_server, token, dry_run):
try:
import uvloop

uvloop.install()
logging.info("Using uvloop-based event loop")
except ImportError:
logging.debug("Using default event loop")

reporter = ReporterSink(
dry_run=dry_run,
management_url=metricq_server,
token=token,
)
reporter.run(cancel_on_exception=True)
def main(server, token, dry_run):
try:
import uvloop

uvloop.install()
logging.info("Using uvloop-based event loop")
except ImportError:
logging.debug("Using default event loop")

reporter = ReporterSink(
dry_run=dry_run,
management_url=server,
token=token,
)
reporter.run(cancel_on_exception=True)
2 changes: 1 addition & 1 deletion metricq_sink_nsca/report_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from dataclasses import dataclass
from typing import AsyncIterator, Optional

from metricq.types import Timedelta
from metricq import Timedelta

from .state import State

Expand Down
2 changes: 1 addition & 1 deletion metricq_sink_nsca/state_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from dataclasses import replace as dataclass_replace
from typing import Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union

from metricq.types import Timedelta, Timestamp
from metricq import Timedelta, Timestamp

from .logging import get_logger
from .state import State
Expand Down
2 changes: 1 addition & 1 deletion metricq_sink_nsca/timeout_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from asyncio import CancelledError, Event
from typing import Optional, Protocol

from metricq.types import Timedelta, Timestamp
from metricq import Timedelta, Timestamp

from .logging import get_logger
from .subtask import subtask
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ include_package_data = True
setup_requires =
setuptools_scm
install_requires =
metricq ~= 4.0
metricq[cli] ~= 5.4
click ~= 8.0
click-log ~= 0.3

Expand Down
Loading