Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update getHealth response #171

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,13 @@ General node health check.
server = Soroban.RPC.Server.testnet()
Soroban.RPC.get_health(server)

{:ok, %Soroban.RPC.GetHealthResponse{status: "healthy"}}
{:ok,
%Soroban.RPC.GetHealthResponse{
status: "healthy",
latest_ledger: 706073,
oldest_ledger: 688794,
ledger_retention_window: 17280
}}

```

Expand Down
11 changes: 9 additions & 2 deletions lib/rpc/responses/get_health_response.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ defmodule Soroban.RPC.GetHealthResponse do
@behaviour Soroban.RPC.Response.Spec

@type status :: String.t()
@type latest_ledger :: non_neg_integer()
@type oldest_ledger :: non_neg_integer()
@type ledger_retention_window :: non_neg_integer()

@type t :: %__MODULE__{
status: status()
status: status(),
latest_ledger: latest_ledger(),
oldest_ledger: oldest_ledger(),
ledger_retention_window: ledger_retention_window()
}

defstruct [:status]
defstruct [:status, :latest_ledger, :oldest_ledger, :ledger_retention_window]

@impl true
def new(attrs), do: struct(%__MODULE__{}, attrs)
Expand Down
5 changes: 4 additions & 1 deletion test/rpc/responses/get_health_response_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ defmodule Soroban.RPC.GetHealthResponseTest do
setup do
%{
result: %{
status: "healthy"
status: "healthy",
latest_ledger: 706_073,
oldest_ledger: 688_794,
ledger_retention_window: 17_280
}
}
end
Expand Down
5 changes: 4 additions & 1 deletion test/rpc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ defmodule Soroban.RPC.CannedRPCGetHealthClientImpl do

{:ok,
%{
status: "healthy"
status: "healthy",
latest_ledger: 706_073,
oldest_ledger: 688_794,
ledger_retention_window: 17_280
}}
end
end
Expand Down