Skip to content

Commit

Permalink
Issue #112 move connections_cache_ttl to AggregatorBackendConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Feb 20, 2024
1 parent d6b81aa commit 09171b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/openeo_aggregator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class AggregatorConfig(dict):
# See `memoizer_from_config` for details.
memoizer = dict_item(default={"type": "dict"})

# TTL for connection caching.
connections_cache_ttl = dict_item(default=5 * 60.0)

# Just a config field for test purposes (while were stripping down this config class)
test_dummy = dict_item(default="alice")

Expand Down Expand Up @@ -136,6 +133,9 @@ class AggregatorBackendConfig(OpenEoBackendConfig):

auth_entitlement_check: Union[bool, dict] = False

# TTL for connection caching.
connections_cache_ttl: float = 5 * 60.0

# List of collection ids to cover with the aggregator (when None: support union of all upstream collections)
collection_whitelist: Optional[List[Union[str, re.Pattern]]] = None

Expand Down
2 changes: 1 addition & 1 deletion src/openeo_aggregator/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def from_config(config: AggregatorConfig) -> 'MultiBackendConnection':
backends=config.aggregator_backends,
configured_oidc_providers=get_backend_config().oidc_providers or config.configured_oidc_providers,
memoizer=memoizer_from_config(config, namespace="mbcon"),
connections_cache_ttl=config.connections_cache_ttl,
connections_cache_ttl=get_backend_config().connections_cache_ttl,
)

def _get_connections(self, skip_failures=False) -> Iterator[BackendConnection]:
Expand Down
1 change: 1 addition & 0 deletions tests/backend_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
OidcProvider(id="y-agg", issuer="https://y.test", title="Y (agg)"),
OidcProvider(id="z-agg", issuer="https://z.test", title="Z (agg)"),
],
connections_cache_ttl=1.0,
)
10 changes: 1 addition & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,7 @@ def memoizer_config() -> dict:


@pytest.fixture
def connections_cache_ttl() -> float:
"""MultiBackendConnection.connections_cache_ttl fixture to allow parameterization"""
return 1.0



@pytest.fixture
def base_config(configured_oidc_providers, zk_client, memoizer_config, connections_cache_ttl) -> AggregatorConfig:
def base_config(configured_oidc_providers, zk_client, memoizer_config) -> AggregatorConfig:
"""Base config for tests (without any configured backends)."""
conf = AggregatorConfig()
conf.config_source = "test fixture base_config"
Expand All @@ -120,7 +113,6 @@ def base_config(configured_oidc_providers, zk_client, memoizer_config, connectio
conf.configured_oidc_providers = configured_oidc_providers

conf.memoizer = memoizer_config
conf.connections_cache_ttl = connections_cache_ttl

conf.zookeeper_prefix = "/o-a/"
conf.partitioned_job_tracking = {
Expand Down

0 comments on commit 09171b8

Please sign in to comment.