-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run anycastd from
MainConfiguration
using the run command (#26)
* Add function to convert `ServiceConfiguration` to `Service` instance * Raname `config_to_instance` and improve docstring * Expose `config_to_service` from configuration module instead of `_sub_config_to_instance` * Expose `run_from_configuration` from core module * Call `run_from_configuration` in CLI module * Add tests for run CLI command * Fix typo "pararmeters"
- Loading branch information
Showing
7 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from anycastd._configuration.conversion import config_to_instance | ||
from anycastd._configuration.conversion import config_to_service | ||
from anycastd._configuration.exceptions import ConfigurationError | ||
from anycastd._configuration.main import MainConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from anycastd.core._run import run_services | ||
from anycastd.core._run import run_from_configuration | ||
from anycastd.core._service import Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import asyncio | ||
from collections.abc import Iterable | ||
|
||
from anycastd._configuration import MainConfiguration, config_to_service | ||
from anycastd.core._service import Service | ||
|
||
|
||
def run_services(services: Iterable[Service]) -> None: | ||
def run_from_configuration(configuration: MainConfiguration) -> None: | ||
"""Run anycastd using an instance of the main configuration.""" | ||
services = tuple(config_to_service(config) for config in configuration.services) | ||
asyncio.run(run_services(services)) | ||
|
||
|
||
async def run_services(services: Iterable[Service]) -> None: | ||
"""Run services. | ||
Args: | ||
services: The services to run. | ||
""" | ||
raise NotImplementedError | ||
asyncio.gather(*(service.run() for service in services)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters