serviceregistry
Service Registry for python apps
For instance during the lifecycle of the application you want 2 things:
- store system variables
- store service with certain initialization code and initialize them on boot of the application
let's look an example to understand this further..
installation
pip install serviceregistry
how to use
from serviceregistry.services import Container, Registry
import meerkat.configurations.app.settings
def create_container(app):
container = Container()
container.set(settings.Props.FALCON, app)
return container
def boot(container):
service_registry = Registry()
for service in settings.services:
service_registry.register(service)
service_registry.boot(container)
container = create_container(create_app())
boot(container)
here we define the props enum as constants to a system vars
# settings.py
from serviceregistry.services import Props as BaseProps
services = [
LoggingService(),
EnvironmentService(),
]
class Props(BaseProps):
DI_PROVIDER = 0
FALCON = 1
APP_URL = "APP_URL"
MONGO_HOST = "MONGO_HOST"
MONGO_PORT = "MONGO_PORT"
MONGO_DB = "MONGO_DB"
and here is the environment service, which registers certain system variables from environment variables
import os
from serviceregistry.services import BootableService, Container
class EnvironmentService(BootableService):
def boot(self, container: Container):
from meerkat.configurations.app.settings import Props
container.set(Props.APP_URL, os.environ.get(Props.APP_URL.value))
container.set(Props.MONGO_HOST, os.environ.get(Props.MONGO_HOST.value))
container.set(Props.MONGO_PORT, os.environ.get(Props.MONGO_PORT.value))
container.set(Props.MONGO_DB, os.environ.get(Props.MONGO_DB.value))
Logging service
import logging as registry_logging
import sys
import serviceregistry.services
class LoggingService(serviceregistry.services.BootableService):
def boot(self):
registry_logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=registry_logging.DEBUG,
)
registry_logging.getLogger().addHandler(
registry_logging.StreamHandler(sys.stdout)
)
Metadata
Release files for py-service-registry 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_service_registry-0.1.1.tar.gz | 3.9 kB | Without provenance | Details for py_service_registry-0.1.1.tar.gz |
Release files / py_service_registry-0.1.1.tar.gz
| Download URL | py_service_registry-0.1.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0946955445b461f9cd42e3bc7d24cfa231d6d2dd65af837844a8523f123ebe7f
|
|
BLAKE2b-256 checksum How to use checksums |
d81f983381f5538384095ba80f46af119dd3b0b94a11dd85d8d5b1b79acac589
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Security for py-service-registry 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.