Skip to content
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
11 changes: 10 additions & 1 deletion antd-ruby/lib/antd/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ def initialize(base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT)
# @return [HealthStatus]
def health
j = do_json(:get, "/health")
HealthStatus.new(ok: j["status"] == "ok", network: j["network"])
HealthStatus.new(
ok: j["status"] == "ok",
network: j["network"],
version: j.fetch("version", ""),
evm_network: j.fetch("evm_network", ""),
uptime_seconds: j.fetch("uptime_seconds", 0),
build_commit: j.fetch("build_commit", ""),
payment_token_address: j.fetch("payment_token_address", ""),
payment_vault_address: j.fetch("payment_vault_address", "")
)
end

# --- Data ---
Expand Down
11 changes: 10 additions & 1 deletion antd-ruby/lib/antd/grpc_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ def initialize(target: DEFAULT_GRPC_TARGET)
# @return [HealthStatus]
def health
resp = grpc_call { @health_stub.check(Antd::V1::HealthCheckRequest.new) }
HealthStatus.new(ok: resp.status == "ok", network: resp.network)
HealthStatus.new(
ok: resp.status == "ok",
network: resp.network,
version: resp.version,
evm_network: resp.evm_network,
uptime_seconds: resp.uptime_seconds,
build_commit: resp.build_commit,
payment_token_address: resp.payment_token_address,
payment_vault_address: resp.payment_vault_address
)
end

# --- Data ---
Expand Down
19 changes: 18 additions & 1 deletion antd-ruby/lib/antd/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

module Antd
# Result of a health check.
HealthStatus = Struct.new(:ok, :network, keyword_init: true)
#
# The diagnostic fields (:version, :evm_network, :uptime_seconds,
# :build_commit, :payment_token_address, :payment_vault_address) were added
# in antd 0.4.0. They default to "" / 0 so existing two-arg
# `HealthStatus.new(ok:, network:)` calls keep working and pre-0.4.0 daemon
# responses parse cleanly.
HealthStatus = Struct.new(
:ok, :network,
:version, :evm_network, :uptime_seconds,
:build_commit, :payment_token_address, :payment_vault_address,
keyword_init: true
) do
def initialize(ok:, network:, version: "", evm_network: "",
uptime_seconds: 0, build_commit: "",
payment_token_address: "", payment_vault_address: "")
super
end
end

# Result of a put/create operation.
PutResult = Struct.new(:cost, :address, keyword_init: true)
Expand Down
22 changes: 22 additions & 0 deletions antd-ruby/lib/antd/v1/chunks_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions antd-ruby/lib/antd/v1/chunks_services_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions antd-ruby/lib/antd/v1/common_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions antd-ruby/lib/antd/v1/data_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions antd-ruby/lib/antd/v1/data_services_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions antd-ruby/lib/antd/v1/files_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions antd-ruby/lib/antd/v1/files_services_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions antd-ruby/lib/antd/v1/health_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions antd-ruby/lib/antd/v1/health_services_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion antd-ruby/test/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,40 @@ def setup
# --- Health ---

def test_health
body = {
status: "ok", network: "local",
version: "0.4.0", evm_network: "local", uptime_seconds: 42,
build_commit: "abcdef123456",
payment_token_address: "0xtoken", payment_vault_address: "0xvault"
}.to_json
stub_request(:get, "#{BASE}/health")
.to_return(status: 200, body: '{"status":"ok","network":"local"}',
.to_return(status: 200, body: body,
headers: { "Content-Type" => "application/json" })

h = @client.health
assert h.ok
assert_equal "local", h.network
assert_equal "0.4.0", h.version
assert_equal "local", h.evm_network
assert_equal 42, h.uptime_seconds
assert_equal "abcdef123456", h.build_commit
assert_equal "0xtoken", h.payment_token_address
assert_equal "0xvault", h.payment_vault_address
end

# Pre-0.4.0 daemons reply with just status + network — verify the
# diagnostic fields default to empty / 0 rather than NPE-ing.
def test_health_pre_0_4_0_daemon
stub_request(:get, "#{BASE}/health")
.to_return(status: 200, body: '{"status":"ok","network":"default"}',
headers: { "Content-Type" => "application/json" })

h = @client.health
assert h.ok
assert_equal "default", h.network
assert_equal "", h.version
assert_equal "", h.evm_network
assert_equal 0, h.uptime_seconds
end

# --- Data Public ---
Expand Down