-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julian Ventura
committed
Oct 2, 2024
1 parent
7138c28
commit 365616b
Showing
5 changed files
with
39 additions
and
7 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,2 +1,3 @@ | ||
ALIGNED_CONFIG_FILE="../contracts/script/output/devnet/alignedlayer_deployment_output.json" | ||
OPERATOR_FETCHER_WAIT_TIME_MS=5000 | ||
ENVIRONMENT=devnet |
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
32 changes: 32 additions & 0 deletions
32
telemetry_api/lib/telemetry_api/periodic/operator_fetcher.ex
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,32 @@ | ||
defmodule TelemetryApi.Periodic.OperatorFetcher do | ||
use Task | ||
alias TelemetryApi.Operators | ||
|
||
wait_time_str = System.get_env("OPERATOR_FETCHER_WAIT_TIME_MS") || | ||
raise """ | ||
environment variable OPERATOR_FETCHER_WAIT_TIME_MS is missing. | ||
""" | ||
|
||
@wait_time_ms ( | ||
case Integer.parse(wait_time_str) do | ||
:error -> raise("OPERATOR_FETCHER_WAIT_TIME_MS is not a number") | ||
{num, _} -> num | ||
end | ||
) | ||
|
||
def start_link(_) do | ||
Task.start_link(&poll_serivce/0) | ||
end | ||
|
||
defp poll_serivce() do | ||
receive do | ||
after | ||
@wait_time_ms -> | ||
case Operators.fetch_all_operators() do | ||
{:ok, _} -> :ok | ||
{:error, message} -> IO.inspect "Couldn't fetch operators: #{IO.inspect message}" | ||
end | ||
poll_serivce() | ||
end | ||
end | ||
end |
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