From 41e0e0306df1293d2103eb4a98e2c2fbfdd540e8 Mon Sep 17 00:00:00 2001 From: Nic-dorman Date: Tue, 5 May 2026 10:34:28 +0100 Subject: [PATCH] feat(antd-ruby): expose new HealthStatus diagnostic fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors antd-go v0.5.0 / antd-py: HealthStatus now carries :version, :evm_network, :uptime_seconds, :build_commit, :payment_token_address, and :payment_vault_address. The keyword-init Struct.new gains an explicit initialize that defaults the diagnostic kwargs to "" / 0 so existing two-arg HealthStatus.new(ok:, network:) calls keep working and pre-0.4.0 daemon responses parse cleanly. REST `Client#health` and gRPC `GrpcClient#health` populate the new fields via Hash#fetch(... "") (REST) and direct getters on the regenerated HealthCheckResponse proto (gRPC). Proto stubs are regenerated locally via grpc_tools_ruby_protoc — they remain untracked, consistent with the pre-existing setup. Mock fixture in test_client.rb extended to populate all 6 fields. Existing test_health asserts each. New test_health_pre_0_4_0_daemon exercises the empty-defaults path. Note: bundle install on the orchestrator's Windows host requires MSYS2 which isn't installed; tests were not run locally. Part of #37. Co-Authored-By: Claude Opus 4.7 (1M context) --- antd-ruby/lib/antd/client.rb | 11 +++++++- antd-ruby/lib/antd/grpc_client.rb | 11 +++++++- antd-ruby/lib/antd/models.rb | 19 +++++++++++++- antd-ruby/lib/antd/v1/chunks_pb.rb | 22 ++++++++++++++++ antd-ruby/lib/antd/v1/chunks_services_pb.rb | 25 ++++++++++++++++++ antd-ruby/lib/antd/v1/common_pb.rb | 21 +++++++++++++++ antd-ruby/lib/antd/v1/data_pb.rb | 29 +++++++++++++++++++++ antd-ruby/lib/antd/v1/data_services_pb.rb | 29 +++++++++++++++++++++ antd-ruby/lib/antd/v1/files_pb.rb | 23 ++++++++++++++++ antd-ruby/lib/antd/v1/files_services_pb.rb | 28 ++++++++++++++++++++ antd-ruby/lib/antd/v1/health_pb.rb | 18 +++++++++++++ antd-ruby/lib/antd/v1/health_services_pb.rb | 24 +++++++++++++++++ antd-ruby/test/test_client.rb | 29 ++++++++++++++++++++- 13 files changed, 285 insertions(+), 4 deletions(-) create mode 100644 antd-ruby/lib/antd/v1/chunks_pb.rb create mode 100644 antd-ruby/lib/antd/v1/chunks_services_pb.rb create mode 100644 antd-ruby/lib/antd/v1/common_pb.rb create mode 100644 antd-ruby/lib/antd/v1/data_pb.rb create mode 100644 antd-ruby/lib/antd/v1/data_services_pb.rb create mode 100644 antd-ruby/lib/antd/v1/files_pb.rb create mode 100644 antd-ruby/lib/antd/v1/files_services_pb.rb create mode 100644 antd-ruby/lib/antd/v1/health_pb.rb create mode 100644 antd-ruby/lib/antd/v1/health_services_pb.rb diff --git a/antd-ruby/lib/antd/client.rb b/antd-ruby/lib/antd/client.rb index 853e55d..02b936f 100644 --- a/antd-ruby/lib/antd/client.rb +++ b/antd-ruby/lib/antd/client.rb @@ -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 --- diff --git a/antd-ruby/lib/antd/grpc_client.rb b/antd-ruby/lib/antd/grpc_client.rb index 2f521d4..af72e19 100644 --- a/antd-ruby/lib/antd/grpc_client.rb +++ b/antd-ruby/lib/antd/grpc_client.rb @@ -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 --- diff --git a/antd-ruby/lib/antd/models.rb b/antd-ruby/lib/antd/models.rb index 3dc1fa5..e5d069b 100644 --- a/antd-ruby/lib/antd/models.rb +++ b/antd-ruby/lib/antd/models.rb @@ -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) diff --git a/antd-ruby/lib/antd/v1/chunks_pb.rb b/antd-ruby/lib/antd/v1/chunks_pb.rb new file mode 100644 index 0000000..e0ca555 --- /dev/null +++ b/antd-ruby/lib/antd/v1/chunks_pb.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: antd/v1/chunks.proto + +require 'google/protobuf' + +require 'antd/v1/common_pb' + + +descriptor_data = "\n\x14\x61ntd/v1/chunks.proto\x12\x07\x61ntd.v1\x1a\x14\x61ntd/v1/common.proto\"\"\n\x0fGetChunkRequest\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\" \n\x10GetChunkResponse\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"\x1f\n\x0fPutChunkRequest\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"@\n\x10PutChunkResponse\x12\x1b\n\x04\x63ost\x18\x01 \x01(\x0b\x32\r.antd.v1.Cost\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t2\x86\x01\n\x0c\x43hunkService\x12:\n\x03Get\x12\x18.antd.v1.GetChunkRequest\x1a\x19.antd.v1.GetChunkResponse\x12:\n\x03Put\x12\x18.antd.v1.PutChunkRequest\x1a\x19.antd.v1.PutChunkResponseBDZ8github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1\xaa\x02\x07\x41ntd.V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Antd + module V1 + GetChunkRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetChunkRequest").msgclass + GetChunkResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetChunkResponse").msgclass + PutChunkRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutChunkRequest").msgclass + PutChunkResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutChunkResponse").msgclass + end +end diff --git a/antd-ruby/lib/antd/v1/chunks_services_pb.rb b/antd-ruby/lib/antd/v1/chunks_services_pb.rb new file mode 100644 index 0000000..2da23bf --- /dev/null +++ b/antd-ruby/lib/antd/v1/chunks_services_pb.rb @@ -0,0 +1,25 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: antd/v1/chunks.proto for package 'antd.v1' + +require 'grpc' +require 'antd/v1/chunks_pb' + +module Antd + module V1 + module ChunkService + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'antd.v1.ChunkService' + + rpc :Get, ::Antd::V1::GetChunkRequest, ::Antd::V1::GetChunkResponse + rpc :Put, ::Antd::V1::PutChunkRequest, ::Antd::V1::PutChunkResponse + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/antd-ruby/lib/antd/v1/common_pb.rb b/antd-ruby/lib/antd/v1/common_pb.rb new file mode 100644 index 0000000..797c8e8 --- /dev/null +++ b/antd-ruby/lib/antd/v1/common_pb.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: antd/v1/common.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x14\x61ntd/v1/common.proto\x12\x07\x61ntd.v1\"y\n\x04\x43ost\x12\x13\n\x0b\x61tto_tokens\x18\x01 \x01(\t\x12\x11\n\tfile_size\x18\x02 \x01(\x04\x12\x13\n\x0b\x63hunk_count\x18\x03 \x01(\r\x12\x1e\n\x16\x65stimated_gas_cost_wei\x18\x04 \x01(\t\x12\x14\n\x0cpayment_mode\x18\x05 \x01(\t\"\x16\n\x07\x41\x64\x64ress\x12\x0b\n\x03hex\x18\x01 \x01(\t\"\x1d\n\x0ePublicKeyProto\x12\x0b\n\x03hex\x18\x01 \x01(\t\"\x1d\n\x0eSecretKeyProto\x12\x0b\n\x03hex\x18\x01 \x01(\t\"6\n\x0fGraphDescendant\x12\x12\n\npublic_key\x18\x01 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x02 \x01(\tBDZ8github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1\xaa\x02\x07\x41ntd.V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Antd + module V1 + Cost = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.Cost").msgclass + Address = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.Address").msgclass + PublicKeyProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PublicKeyProto").msgclass + SecretKeyProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.SecretKeyProto").msgclass + GraphDescendant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GraphDescendant").msgclass + end +end diff --git a/antd-ruby/lib/antd/v1/data_pb.rb b/antd-ruby/lib/antd/v1/data_pb.rb new file mode 100644 index 0000000..471c9ce --- /dev/null +++ b/antd-ruby/lib/antd/v1/data_pb.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: antd/v1/data.proto + +require 'google/protobuf' + +require 'antd/v1/common_pb' + + +descriptor_data = "\n\x12\x61ntd/v1/data.proto\x12\x07\x61ntd.v1\x1a\x14\x61ntd/v1/common.proto\"\'\n\x14GetPublicDataRequest\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\"%\n\x15GetPublicDataResponse\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"$\n\x14PutPublicDataRequest\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"E\n\x15PutPublicDataResponse\x12\x1b\n\x04\x63ost\x18\x01 \x01(\x0b\x32\r.antd.v1.Cost\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\"*\n\x17StreamPublicDataRequest\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\"\x19\n\tDataChunk\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\")\n\x15GetPrivateDataRequest\x12\x10\n\x08\x64\x61ta_map\x18\x01 \x01(\t\"&\n\x16GetPrivateDataResponse\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"%\n\x15PutPrivateDataRequest\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"G\n\x16PutPrivateDataResponse\x12\x1b\n\x04\x63ost\x18\x01 \x01(\x0b\x32\r.antd.v1.Cost\x12\x10\n\x08\x64\x61ta_map\x18\x02 \x01(\t\"\x1f\n\x0f\x44\x61taCostRequest\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\x32\xbf\x03\n\x0b\x44\x61taService\x12J\n\tGetPublic\x12\x1d.antd.v1.GetPublicDataRequest\x1a\x1e.antd.v1.GetPublicDataResponse\x12J\n\tPutPublic\x12\x1d.antd.v1.PutPublicDataRequest\x1a\x1e.antd.v1.PutPublicDataResponse\x12\x46\n\x0cStreamPublic\x12 .antd.v1.StreamPublicDataRequest\x1a\x12.antd.v1.DataChunk0\x01\x12M\n\nGetPrivate\x12\x1e.antd.v1.GetPrivateDataRequest\x1a\x1f.antd.v1.GetPrivateDataResponse\x12M\n\nPutPrivate\x12\x1e.antd.v1.PutPrivateDataRequest\x1a\x1f.antd.v1.PutPrivateDataResponse\x12\x32\n\x07GetCost\x12\x18.antd.v1.DataCostRequest\x1a\r.antd.v1.CostBDZ8github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1\xaa\x02\x07\x41ntd.V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Antd + module V1 + GetPublicDataRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetPublicDataRequest").msgclass + GetPublicDataResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetPublicDataResponse").msgclass + PutPublicDataRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutPublicDataRequest").msgclass + PutPublicDataResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutPublicDataResponse").msgclass + StreamPublicDataRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.StreamPublicDataRequest").msgclass + DataChunk = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.DataChunk").msgclass + GetPrivateDataRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetPrivateDataRequest").msgclass + GetPrivateDataResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.GetPrivateDataResponse").msgclass + PutPrivateDataRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutPrivateDataRequest").msgclass + PutPrivateDataResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.PutPrivateDataResponse").msgclass + DataCostRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.DataCostRequest").msgclass + end +end diff --git a/antd-ruby/lib/antd/v1/data_services_pb.rb b/antd-ruby/lib/antd/v1/data_services_pb.rb new file mode 100644 index 0000000..1a8135d --- /dev/null +++ b/antd-ruby/lib/antd/v1/data_services_pb.rb @@ -0,0 +1,29 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: antd/v1/data.proto for package 'antd.v1' + +require 'grpc' +require 'antd/v1/data_pb' + +module Antd + module V1 + module DataService + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'antd.v1.DataService' + + rpc :GetPublic, ::Antd::V1::GetPublicDataRequest, ::Antd::V1::GetPublicDataResponse + rpc :PutPublic, ::Antd::V1::PutPublicDataRequest, ::Antd::V1::PutPublicDataResponse + rpc :StreamPublic, ::Antd::V1::StreamPublicDataRequest, stream(::Antd::V1::DataChunk) + rpc :GetPrivate, ::Antd::V1::GetPrivateDataRequest, ::Antd::V1::GetPrivateDataResponse + rpc :PutPrivate, ::Antd::V1::PutPrivateDataRequest, ::Antd::V1::PutPrivateDataResponse + rpc :GetCost, ::Antd::V1::DataCostRequest, ::Antd::V1::Cost + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/antd-ruby/lib/antd/v1/files_pb.rb b/antd-ruby/lib/antd/v1/files_pb.rb new file mode 100644 index 0000000..d366390 --- /dev/null +++ b/antd-ruby/lib/antd/v1/files_pb.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: antd/v1/files.proto + +require 'google/protobuf' + +require 'antd/v1/common_pb' + + +descriptor_data = "\n\x13\x61ntd/v1/files.proto\x12\x07\x61ntd.v1\x1a\x14\x61ntd/v1/common.proto\"!\n\x11UploadFileRequest\x12\x0c\n\x04path\x18\x01 \x01(\t\"\x96\x01\n\x14UploadPublicResponse\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\x12\x19\n\x11storage_cost_atto\x18\x03 \x01(\t\x12\x14\n\x0cgas_cost_wei\x18\x04 \x01(\t\x12\x15\n\rchunks_stored\x18\x05 \x01(\x04\x12\x19\n\x11payment_mode_used\x18\x06 \x01(\tJ\x04\x08\x01\x10\x02R\x04\x63ost\";\n\x15\x44ownloadPublicRequest\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\x12\x11\n\tdest_path\x18\x02 \x01(\t\"\x12\n\x10\x44ownloadResponse\"2\n\x0f\x46ileCostRequest\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x11\n\tis_public\x18\x02 \x01(\x08\x32\xfb\x02\n\x0b\x46ileService\x12I\n\x0cUploadPublic\x12\x1a.antd.v1.UploadFileRequest\x1a\x1d.antd.v1.UploadPublicResponse\x12K\n\x0e\x44ownloadPublic\x12\x1e.antd.v1.DownloadPublicRequest\x1a\x19.antd.v1.DownloadResponse\x12L\n\x0f\x44irUploadPublic\x12\x1a.antd.v1.UploadFileRequest\x1a\x1d.antd.v1.UploadPublicResponse\x12N\n\x11\x44irDownloadPublic\x12\x1e.antd.v1.DownloadPublicRequest\x1a\x19.antd.v1.DownloadResponse\x12\x36\n\x0bGetFileCost\x12\x18.antd.v1.FileCostRequest\x1a\r.antd.v1.CostBDZ8github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1\xaa\x02\x07\x41ntd.V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Antd + module V1 + UploadFileRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.UploadFileRequest").msgclass + UploadPublicResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.UploadPublicResponse").msgclass + DownloadPublicRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.DownloadPublicRequest").msgclass + DownloadResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.DownloadResponse").msgclass + FileCostRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.FileCostRequest").msgclass + end +end diff --git a/antd-ruby/lib/antd/v1/files_services_pb.rb b/antd-ruby/lib/antd/v1/files_services_pb.rb new file mode 100644 index 0000000..8b80ff4 --- /dev/null +++ b/antd-ruby/lib/antd/v1/files_services_pb.rb @@ -0,0 +1,28 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: antd/v1/files.proto for package 'antd.v1' + +require 'grpc' +require 'antd/v1/files_pb' + +module Antd + module V1 + module FileService + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'antd.v1.FileService' + + rpc :UploadPublic, ::Antd::V1::UploadFileRequest, ::Antd::V1::UploadPublicResponse + rpc :DownloadPublic, ::Antd::V1::DownloadPublicRequest, ::Antd::V1::DownloadResponse + rpc :DirUploadPublic, ::Antd::V1::UploadFileRequest, ::Antd::V1::UploadPublicResponse + rpc :DirDownloadPublic, ::Antd::V1::DownloadPublicRequest, ::Antd::V1::DownloadResponse + rpc :GetFileCost, ::Antd::V1::FileCostRequest, ::Antd::V1::Cost + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/antd-ruby/lib/antd/v1/health_pb.rb b/antd-ruby/lib/antd/v1/health_pb.rb new file mode 100644 index 0000000..20a345e --- /dev/null +++ b/antd-ruby/lib/antd/v1/health_pb.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: antd/v1/health.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x14\x61ntd/v1/health.proto\x12\x07\x61ntd.v1\"\x14\n\x12HealthCheckRequest\"\xc8\x01\n\x13HealthCheckResponse\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x0f\n\x07network\x18\x02 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t\x12\x13\n\x0b\x65vm_network\x18\x04 \x01(\t\x12\x16\n\x0euptime_seconds\x18\x05 \x01(\x04\x12\x14\n\x0c\x62uild_commit\x18\x06 \x01(\t\x12\x1d\n\x15payment_token_address\x18\x07 \x01(\t\x12\x1d\n\x15payment_vault_address\x18\x08 \x01(\t2S\n\rHealthService\x12\x42\n\x05\x43heck\x12\x1b.antd.v1.HealthCheckRequest\x1a\x1c.antd.v1.HealthCheckResponseBDZ8github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1\xaa\x02\x07\x41ntd.V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Antd + module V1 + HealthCheckRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.HealthCheckRequest").msgclass + HealthCheckResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("antd.v1.HealthCheckResponse").msgclass + end +end diff --git a/antd-ruby/lib/antd/v1/health_services_pb.rb b/antd-ruby/lib/antd/v1/health_services_pb.rb new file mode 100644 index 0000000..107d6d8 --- /dev/null +++ b/antd-ruby/lib/antd/v1/health_services_pb.rb @@ -0,0 +1,24 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: antd/v1/health.proto for package 'antd.v1' + +require 'grpc' +require 'antd/v1/health_pb' + +module Antd + module V1 + module HealthService + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'antd.v1.HealthService' + + rpc :Check, ::Antd::V1::HealthCheckRequest, ::Antd::V1::HealthCheckResponse + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/antd-ruby/test/test_client.rb b/antd-ruby/test/test_client.rb index 4d85693..93a571b 100644 --- a/antd-ruby/test/test_client.rb +++ b/antd-ruby/test/test_client.rb @@ -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 ---