diff --git a/pyproject.toml b/pyproject.toml index f4d0ba4..d82541d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,14 +7,10 @@ name = "config-service" classifiers = [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ] description = "an service to put and get your config values from" -dependencies = [] # Add project dependencies here, e.g. ["click", "numpy"] +dependencies = ["fastapi", "hiredis", "dls-dodal"] dynamic = ["version"] license.file = "LICENSE" readme = "README.md" diff --git a/src/config_service/__main__.py b/src/config_service/__main__.py index 45b44fe..7dc85b6 100644 --- a/src/config_service/__main__.py +++ b/src/config_service/__main__.py @@ -1,16 +1,25 @@ -from argparse import ArgumentParser +import redis +from dodal.common.beamlines.beamline_parameters import ( + BEAMLINE_PARAMETER_PATHS, + GDABeamlineParameters, +) +from fastapi import FastAPI -from . import __version__ +app = FastAPI() +r = redis.Redis(host="localhost", port=6379, decode_responses=True) +beamline_params = GDABeamlineParameters.from_file(BEAMLINE_PARAMETER_PATHS["i03"]) -__all__ = ["main"] +@app.get("/beamlineparameters/{item_id}") +def beamlineparameter(item_id: str): + return {item_id: beamline_params.params.get(item_id)} -def main(args=None): - parser = ArgumentParser() - parser.add_argument("-v", "--version", action="version", version=__version__) - args = parser.parse_args(args) +@app.post("/featureflag/{item_id}") +def set_featureflag(item_id: str, value): + return {item_id: r.set(item_id, value)} -# test with: python -m config_service -if __name__ == "__main__": - main() + +@app.get("/featureflag/{item_id}") +def get_featureflag(item_id: str): + return {item_id: r.get(item_id)} diff --git a/valkey/Dockerfile b/valkey/Dockerfile new file mode 100644 index 0000000..8980c28 --- /dev/null +++ b/valkey/Dockerfile @@ -0,0 +1,2 @@ +FROM valkey/valkey:7.2.5-alpine3.19 +