-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add inject framework, refactor rpc and services
- Loading branch information
1 parent
aeec040
commit 7b4c3bf
Showing
29 changed files
with
795 additions
and
702 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
debug: true | ||
secret: 023517f06f444118986877e636b4a226 | ||
test_environ: true | ||
|
||
app: | ||
port: 8000 | ||
|
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,6 +1,6 @@ | ||
debug: true | ||
secret: 023517f06f444118986877e636b4a226 | ||
test_environ: false | ||
test_environ: true | ||
|
||
app: | ||
port: 8000 | ||
|
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from typing import Literal | ||
|
||
from dependency_injector import containers, providers | ||
from hiku.engine import Engine | ||
from hiku.executors.asyncio import AsyncIOExecutor | ||
|
||
from featureflags.config import config | ||
from featureflags.services.db import init_db_engine | ||
from featureflags.services.ldap import LDAP, DummyLDAP | ||
|
||
|
||
def select_main_or_testing_dependency() -> Literal["main", "testing"]: | ||
return "testing" if config.test_environ else "main" | ||
|
||
|
||
class Container(containers.DeclarativeContainer): | ||
""" | ||
Container with app dependencies. | ||
""" | ||
|
||
wiring_config = containers.WiringConfiguration( | ||
packages=[ | ||
"featureflags.services", | ||
"featureflags.web", | ||
"featureflags.rpc", | ||
] | ||
) | ||
|
||
graph_engine = providers.Factory( | ||
Engine, | ||
providers.Callable(AsyncIOExecutor), | ||
) | ||
|
||
db_engine = providers.Resource(init_db_engine) | ||
|
||
ldap_service = providers.Selector( | ||
selector=select_main_or_testing_dependency, | ||
main=providers.Factory( | ||
LDAP, | ||
host=config.ldap.host, | ||
base_dn=config.ldap.base_dn, | ||
), | ||
testing=providers.Factory( | ||
DummyLDAP, | ||
bound=True, | ||
), | ||
) |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.