Skip to content

Commit

Permalink
feat: standardized cli + upgrade to metricq version 5
Browse files Browse the repository at this point in the history
  • Loading branch information
devmaxde committed Jan 9, 2025
1 parent fdc8035 commit 93daf13
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
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="[email protected]"

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

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

USER metricq
COPY --from=BUILDER --chown=metricq:metricq /home/metricq/.local /home/metricq/.local
Expand Down
3 changes: 1 addition & 2 deletions metricq_grafana/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import operator
import time

from metricq import get_logger
from metricq import get_logger, Timestamp
from metricq.history_client import HistoryRequestType, HistoryResponseType
from metricq.types import Timestamp

from .functions import parse_functions
from .target import Target
Expand Down
2 changes: 1 addition & 1 deletion metricq_grafana/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod

from metricq import Timedelta
from metricq.history_client import HistoryResponse, HistoryResponseType
from metricq.types import Timedelta


def parse_functions(target_dict):
Expand Down
27 changes: 15 additions & 12 deletions metricq_grafana/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import click_log
from aiohttp import web
from metricq import get_logger
from metricq.cli import metricq_command

from .client import Client
from .routes import setup_routes
Expand Down Expand Up @@ -105,9 +106,7 @@ def panic(loop, context):
loop.stop()


@click.command()
@click.argument("management-url", default="amqp://localhost/")
@click.option("--token", default="metricq-grafana")
@metricq_command(default_token="metricq-grafana")
@click.option("--management-exchange", default="metricq.management")
@click.option("--debug/--no-debug", default=False)
@click.option("--log-to-journal/--no-log-to-journal", default=False)
Expand All @@ -117,14 +116,14 @@ def panic(loop, context):
@click_log.simple_verbosity_option(logger)
@click.version_option(version=version)
def runserver_cmd(
management_url,
token,
management_exchange,
debug,
log_to_journal,
host,
port,
cors_origin,
server,
token,
management_exchange,
debug,
log_to_journal,
host,
port,
cors_origin,
):
loop = asyncio.get_event_loop()
if debug:
Expand All @@ -139,5 +138,9 @@ def runserver_cmd(
except ImportError:
logger.error("Can't enable journal logger, systemd package not found!")

app = create_app(loop, token, management_url, management_exchange, cors_origin)
app = create_app(loop, token, server, management_exchange, cors_origin)
web.run_app(app, host=host, port=int(port), loop=loop)


if __name__ == "__main__":
runserver_cmd()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"click-completion",
"click_log",
"colorama",
"metricq ~= 4.1.0",
"metricq[cli] ~= 5.4.0",
"aiocache",
],
extras_require={"journallogger": ["systemd"]},
Expand Down

0 comments on commit 93daf13

Please sign in to comment.