Skip to content

Commit

Permalink
feat: Poller refresh interval (#232)
Browse files Browse the repository at this point in the history
* feat(poller_refresh_interval): Added a CLI parameter for the poller refresh interval

* bump: 2.4.7 → 2.4.8

---------

Co-authored-by: 0xevolve <Artevolve@yahoo.com>
  • Loading branch information
akhercha and EvolveArt authored Dec 13, 2024
1 parent 76024a3 commit adb6bd0
Show file tree
Hide file tree
Showing 13 changed files with 3,044 additions and 2,798 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v2.4.8 (2024-12-13)

### Feat

- **poller_refresh_interval**: Added a CLI parameter for the poller refresh interval

## v2.4.7 (2024-12-03)

### Feat
Expand Down
1,175 changes: 610 additions & 565 deletions checkpointer/poetry.lock

Large diffs are not rendered by default.

1,175 changes: 610 additions & 565 deletions lp-pricer/poetry.lock

Large diffs are not rendered by default.

1,175 changes: 610 additions & 565 deletions merkle-maker/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pragma-sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.7
2.4.8
707 changes: 368 additions & 339 deletions pragma-sdk/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pragma-sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pragma-sdk"
version = "2.4.7"
version = "2.4.8"
authors = ["0xevolve <matthias@pragma.build>"]
description = "Core package for rollup-native Pragma Oracle"
readme = "README.md"
Expand Down
154 changes: 77 additions & 77 deletions pragma-utils/poetry.lock

Large diffs are not rendered by default.

709 changes: 369 additions & 340 deletions price-pusher/poetry.lock

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion price-pusher/price_pusher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def main(
private_key: PrivateKey,
publisher_name: str,
publisher_address: str,
poller_refresh_interval: int,
rpc_url: Optional[str] = None,
api_base_url: Optional[str] = None,
api_key: Optional[str] = None,
Expand Down Expand Up @@ -75,6 +76,7 @@ async def main(
pusher = PricePusher(client=pragma_client)
orchestrator = Orchestrator(
poller=poller,
poller_refresh_interval=poller_refresh_interval,
listeners=_create_listeners(price_configs, target, pragma_client),
pusher=pusher,
)
Expand Down Expand Up @@ -243,7 +245,14 @@ def _create_client(
"--enable-strk-fees",
type=click.BOOL,
required=False,
help="enable_strk_fees option for the onchain client",
help="Pay fees using STRK for on chain queries.",
)
@click.option(
"--poller-refresh-interval",
type=click.IntRange(min=5),
required=False,
default=5,
help="Interval in seconds between poller refreshes. Default to 5 seconds.",
)
def cli_entrypoint(
config_file: str,
Expand All @@ -259,6 +268,7 @@ def cli_entrypoint(
max_fee: Optional[int],
pagination: Optional[int],
enable_strk_fees: Optional[bool],
poller_refresh_interval: int,
) -> None:
if target == "offchain":
if not api_key or not api_base_url:
Expand Down Expand Up @@ -312,6 +322,7 @@ def cli_entrypoint(
max_fee=max_fee,
pagination=pagination,
enable_strk_fees=enable_strk_fees,
poller_refresh_interval=poller_refresh_interval,
)
)

Expand Down
13 changes: 10 additions & 3 deletions price-pusher/price_pusher/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class Orchestrator:
"""

poller: PricePoller
# Time between poller refresh. Defaults to 5 seconds.
# Make sure it's high enough - else we might get rate limited by public APIs.
poller_refresh_interval: int

listeners: List[PriceListener]
pusher: PricePusher
# Contains the latest spot/future prices for each sources
Expand All @@ -32,12 +36,15 @@ def __init__(
poller: PricePoller,
listeners: List[PriceListener],
pusher: PricePusher,
poller_refresh_interval: int = 5,
) -> None:
# Init class properties.
self.poller = poller
self.listeners = listeners
self.pusher = pusher

# Time between poller refresh
self.poller_refresh_interval = poller_refresh_interval

# Contains the latest prices for each sources
self.latest_prices: LatestOrchestratorPairPrices = {}

Expand Down Expand Up @@ -73,8 +80,8 @@ async def _poller_service(self) -> None:
"""
while True:
await self.poller.poll_prices()
# Wait 5 seconds before requerying public APIs (rate limits).
await asyncio.sleep(5)
# Wait some time before requerying public APIs (rate limits).
await asyncio.sleep(self.poller_refresh_interval)

async def _listener_services(self) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"

[tool.commitizen]
name = "cz_conventional_commits"
version = "2.4.7"
version = "2.4.8"
tag_format = "v$version"
version_files = [
"VERSION",
Expand Down
709 changes: 369 additions & 340 deletions vrf-listener/poetry.lock

Large diffs are not rendered by default.

0 comments on commit adb6bd0

Please sign in to comment.