Builder for a service host.
Project description
DNRY-SrvHost-Builder
A library for building a long running service in python.
This library is inspired by ASPNETCORE. This package provides a set of classes and interfaces that simplify the initialization of a service by integrating configuration management from dnry.config and container based dependency injection using pyioc3.
This library was intended as a platform on which to create long-running services and reduce boiler plate code. You can create your own service host use one from the DNRY.SrvHost library.
Quick Start
Install dnry-srvhost-builder
pip install dnry-srvhost-builder
Create your own own service host
from dnry.srvhost.builder import SrvHostBase
class AppHost(SrvHostBase):
def run(self):
print('Do something cool!')
Build your program
from dnry.config import IConfigFactory
from dnry.srvhost.builder import SrvHostBuilder, ISrvHostContext, ISrvHost
from pyioc3 import StaticContainerBuilder
def setup_config(ctx: ISrvHostContext, conf: IConfigFactory):
# Add configuration files here
pass
def setup_services(ctx: ISrvHostContext, services: StaticContainerBuilder):
services.bind(
annotation=ISrvHost,
implementation=AppHost)
if __name__ == "__main__":
SrvHostBuilder("App") \
.config_configuration(setup_config) \
.config_services(setup_services) \
.build() \
.run()
That's it! You are ready to build something cool. You can do much more
How What?
in setup_service and setup_config. For information on how to use the
IConfigFactory
, see the documentation at en0/dnry-config.
For more information on how to use StaticContainerBuilder
, see the
documentation at en0/pyioc3.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dnry_srvhost-builder-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 520bd9c0ee75c959d9daea9d02ffeeb6bf77a3209f537a7febb0d3e153973fb2 |
|
MD5 | 1c4657df029422c63f03e03063fedfaf |
|
BLAKE2b-256 | c1406e6d397d96a265b353a892403667f870ef770bbb85795d9ef7a58e832076 |
Hashes for dnry_srvhost_builder-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e1c705005920c896e4cc2672e7c5f9f24f0c568e23a3956c242a8024c306884 |
|
MD5 | aeb94af2a77866b004ca2abd36a59df2 |
|
BLAKE2b-256 | 727b467d1514bf479a66530648a8b19a5da26d97508eed81ba6304fad8d808e8 |