You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by "chengxilo (via GitHub)" <gi...@apache.org> on 2026/03/26 04:28:17 UTC

[PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

chengxilo opened a new pull request, #3032:
URL: https://github.com/apache/iggy/pull/3032

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Address https://github.com/apache/iggy/pull/2964#discussion_r2952160233
   
   ## Rationale
   
   <!--
   Why is this change needed? If the issue explains it well, a one-liner is fine.
   -->
   The rust side now serializes threads_count, free_disk_space, and total_disk_space on the wire (in core/server/src/binary/mapper.rs), but the go Stats struct (foreign/go/contracts/stats.go) and its deserializer (foreign/go/binary_serialization/stats_serializer.go) don't read these fields.
   
   (Yeah, I copied the comment) 😋
   
   ## What changed?
   
   <!--
   2-4 sentences. Problem first (before), then solution (after).
   
   GOOD:
   
   "Messages were unavailable when background message_saver committed the
   journal and started async disk I/O before completion. Polling during
   this window found neither journal nor disk data.
   
   The fix freezes journal batches in the in-flight buffer before async persist."
   
   GOOD:
   
   "When many small messages accumulate in the journal, the flush passes
   thousands of IO vectors to writev(), exceeding IOV_MAX (1024 on Linux)."
   
   BAD:
   - Walls of text
   - "This PR adds..." (we can see the diff)
   -->
   1. Adds attributes to `Stats`, also the tests.
   2. Removed `TcpStats` and update the function related to it as `Stats` is already enough for our logic.
   
   ## Local Execution
   
   - Passed
   - Pre-commit hooks ran
   
   <!--
   You must run your code locally before submitting.
   "Relying on CI" is not acceptable - PRs from authors who haven't run the code will be closed.
   
   Did you have `prek` installed? It runs automatically on commit and covers all project languages. See [CONTRIBUTING.md](https://github.com/apache/iggy/blob/master/CONTRIBUTING.md).
   -->
   
   ## AI Usage
   
   <!--
   If AI tools were used, please answer:
   1. Which tools? (e.g., GitHub Copilot, Claude, ChatGPT)
   4. Scope of usage? (e.g., autocomplete, generated functions, entire implementation)
   5. How did you verify the generated code works correctly?
   6. Can you explain every line of the code if asked?
   
   If no AI tools were used, write "None" or delete this section.
   -->
   1. Claude Opus 4.6
   2. Code generation and review.
   3. I checked it with the rust implementation of stats.
   4. Yes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "spetz (via GitHub)" <gi...@apache.org>.
spetz merged PR #3032:
URL: https://github.com/apache/iggy/pull/3032


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "chengxilo (via GitHub)" <gi...@apache.org>.
chengxilo commented on code in PR #3032:
URL: https://github.com/apache/iggy/pull/3032#discussion_r3074811395


##########
foreign/go/contracts/stats.go:
##########
@@ -17,27 +17,142 @@
 
 package iggcon
 
+import (
+	"fmt"
+
+	"github.com/apache/iggy/foreign/go/internal/codec"
+)
+
+// CacheMetrics holds cache hit/miss statistics for a single partition.
+type CacheMetrics struct {
+	StreamId    uint32  `json:"stream_id"`

Review Comment:
   Currently Go SDK doesn't support HTTP. the json tags are actually outdated auto-generated code(I guess).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3032:
URL: https://github.com/apache/iggy/pull/3032#issuecomment-4203075903

   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.
   
   If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.
   
   Thank you for your contribution!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3032:
URL: https://github.com/apache/iggy/pull/3032#issuecomment-4131583941

   ## [Codecov](https://app.codecov.io/gh/apache/iggy/pull/3032?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `89.55224%` with `7 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 70.60%. Comparing base ([`cea62a9`](https://app.codecov.io/gh/apache/iggy/commit/cea62a95d111231932f2b7deaceba6a96959e222?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`097595c`](https://app.codecov.io/gh/apache/iggy/commit/097595c4cd0b9802608cb5e8ba6c2fb30f89b328?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/iggy/pull/3032?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [foreign/go/contracts/stats.go](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&filepath=foreign%2Fgo%2Fcontracts%2Fstats.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Zm9yZWlnbi9nby9jb250cmFjdHMvc3RhdHMuZ28=) | 93.75% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [foreign/go/client/tcp/tcp\_utilities.go](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&filepath=foreign%2Fgo%2Fclient%2Ftcp%2Ftcp_utilities.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Zm9yZWlnbi9nby9jbGllbnQvdGNwL3RjcF91dGlsaXRpZXMuZ28=) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3032      +/-   ##
   ============================================
   - Coverage     72.15%   70.60%   -1.55%     
     Complexity      930      930              
   ============================================
     Files          1120     1120              
     Lines         93489    93521      +32     
     Branches      70835    70835              
   ============================================
   - Hits          67453    66033    -1420     
   - Misses        23469    25023    +1554     
   + Partials       2567     2465     -102     
   ```
   
   | [Components](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [Rust Core](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.89% <ø> (ø)` | |
   | [Java SDK](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `62.08% <ø> (ø)` | |
   | [C# SDK](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `67.64% <ø> (ø)` | |
   | [Python SDK](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.43% <ø> (ø)` | |
   | [Node SDK](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.44% <ø> (ø)` | |
   | [Go SDK](https://app.codecov.io/gh/apache/iggy/pull/3032/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `8.88% <89.55%> (-29.81%)` | :arrow_down: |
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/iggy/pull/3032?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [foreign/go/client/tcp/tcp\_utilities.go](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&filepath=foreign%2Fgo%2Fclient%2Ftcp%2Ftcp_utilities.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Zm9yZWlnbi9nby9jbGllbnQvdGNwL3RjcF91dGlsaXRpZXMuZ28=) | `0.00% <0.00%> (-80.00%)` | :arrow_down: |
   | [foreign/go/contracts/stats.go](https://app.codecov.io/gh/apache/iggy/pull/3032?src=pr&el=tree&filepath=foreign%2Fgo%2Fcontracts%2Fstats.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Zm9yZWlnbi9nby9jb250cmFjdHMvc3RhdHMuZ28=) | `93.75% <93.75%> (ø)` | |
   
   ... and [41 files with indirect coverage changes](https://app.codecov.io/gh/apache/iggy/pull/3032/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "mmodzelewski (via GitHub)" <gi...@apache.org>.
mmodzelewski commented on code in PR #3032:
URL: https://github.com/apache/iggy/pull/3032#discussion_r3071308714


##########
foreign/go/contracts/stats.go:
##########
@@ -17,27 +17,142 @@
 
 package iggcon
 
+import (
+	"fmt"
+
+	"github.com/apache/iggy/foreign/go/internal/codec"
+)
+
+// CacheMetrics holds cache hit/miss statistics for a single partition.
+type CacheMetrics struct {
+	StreamId    uint32  `json:"stream_id"`
+	TopicId     uint32  `json:"topic_id"`
+	PartitionId uint32  `json:"partition_id"`
+	Hits        uint64  `json:"hits"`
+	Misses      uint64  `json:"misses"`
+	HitRatio    float32 `json:"hit_ratio"`
+}
+
+// cacheMetricsWireSize is the fixed size of a CacheMetrics entry on the wire:
+// stream_id(4) + topic_id(4) + partition_id(4) + hits(8) + misses(8) + hit_ratio(4) = 32.
+const cacheMetricsWireSize = 4 + 4 + 4 + 8 + 8 + 4
+
 type Stats struct {
-	ProcessId           uint32  `json:"process_id"`
-	CpuUsage            float32 `json:"cpu_usage"`
-	TotalCpuUsage       float32 `json:"total_cpu_usage"`
-	MemoryUsage         uint64  `json:"memory_usage"`
-	TotalMemory         uint64  `json:"total_memory"`
-	AvailableMemory     uint64  `json:"available_memory"`
-	RunTime             uint64  `json:"run_time"`
-	StartTime           uint64  `json:"start_time"`
-	ReadBytes           uint64  `json:"read_bytes"`
-	WrittenBytes        uint64  `json:"written_bytes"`
-	MessagesSizeBytes   uint64  `json:"messages_size_bytes"`
-	StreamsCount        uint32  `json:"streams_count"`
-	TopicsCount         uint32  `json:"topics_count"`
-	PartitionsCount     uint32  `json:"partitions_count"`
-	SegmentsCount       uint32  `json:"segments_count"`
-	MessagesCount       uint64  `json:"messages_count"`
-	ClientsCount        uint32  `json:"clients_count"`
-	ConsumerGroupsCount uint32  `json:"consumer_groups_count"`
-	Hostname            string  `json:"hostname"`
-	OsName              string  `json:"os_name"`
-	OsVersion           string  `json:"os_version"`
-	KernelVersion       string  `json:"kernel_version"`
+	ProcessId           uint32         `json:"process_id"`
+	CpuUsage            float32        `json:"cpu_usage"`
+	TotalCpuUsage       float32        `json:"total_cpu_usage"`
+	MemoryUsage         uint64         `json:"memory_usage"`
+	TotalMemory         uint64         `json:"total_memory"`
+	AvailableMemory     uint64         `json:"available_memory"`
+	RunTime             uint64         `json:"run_time"`
+	StartTime           uint64         `json:"start_time"`
+	ReadBytes           uint64         `json:"read_bytes"`
+	WrittenBytes        uint64         `json:"written_bytes"`
+	MessagesSizeBytes   uint64         `json:"messages_size_bytes"`
+	StreamsCount        uint32         `json:"streams_count"`
+	TopicsCount         uint32         `json:"topics_count"`
+	PartitionsCount     uint32         `json:"partitions_count"`
+	SegmentsCount       uint32         `json:"segments_count"`
+	MessagesCount       uint64         `json:"messages_count"`
+	ClientsCount        uint32         `json:"clients_count"`
+	ConsumerGroupsCount uint32         `json:"consumer_groups_count"`
+	Hostname            string         `json:"hostname"`
+	OsName              string         `json:"os_name"`
+	OsVersion           string         `json:"os_version"`
+	KernelVersion       string         `json:"kernel_version"`
+	IggyServerVersion   string         `json:"iggy_server_version"`
+	IggyServerSemver    *uint32        `json:"iggy_server_semver,omitempty"`
+	CacheMetrics        []CacheMetrics `json:"cache_metrics"`
+	ThreadsCount        uint32         `json:"threads_count"`
+	FreeDiskSpace       uint64         `json:"free_disk_space"`
+	TotalDiskSpace      uint64         `json:"total_disk_space"`
+}
+
+func (cm *CacheMetrics) MarshalBinary() ([]byte, error) {
+	w := codec.NewWriterCap(32)
+	w.U32(cm.StreamId)
+	w.U32(cm.TopicId)
+	w.U32(cm.PartitionId)
+	w.U64(cm.Hits)
+	w.U64(cm.Misses)
+	w.F32(cm.HitRatio)
+	return w.Bytes(), w.Err()
+}
+
+func (cm *CacheMetrics) UnmarshalBinary(data []byte) error {
+	r := codec.NewReader(data)
+	cm.StreamId = r.U32()
+	cm.TopicId = r.U32()
+	cm.PartitionId = r.U32()
+	cm.Hits = r.U64()
+	cm.Misses = r.U64()
+	cm.HitRatio = r.F32()
+	return r.Err()
+}
+
+func (s *Stats) UnmarshalBinary(payload []byte) error {
+	r := codec.NewReader(payload)
+	s.ProcessId = r.U32()
+	s.CpuUsage = r.F32()
+	s.TotalCpuUsage = r.F32()
+	s.MemoryUsage = r.U64()
+	s.TotalMemory = r.U64()
+	s.AvailableMemory = r.U64()
+	s.RunTime = r.U64()
+	s.StartTime = r.U64()
+	s.ReadBytes = r.U64()
+	s.WrittenBytes = r.U64()
+	s.MessagesSizeBytes = r.U64()
+	s.StreamsCount = r.U32()
+	s.TopicsCount = r.U32()
+	s.PartitionsCount = r.U32()
+	s.SegmentsCount = r.U32()
+	s.MessagesCount = r.U64()
+	s.ClientsCount = r.U32()
+	s.ConsumerGroupsCount = r.U32()
+	s.Hostname = r.U32LenStr()
+	s.OsName = r.U32LenStr()
+	s.OsVersion = r.U32LenStr()
+	s.KernelVersion = r.U32LenStr()
+	s.IggyServerVersion = r.U32LenStr()
+
+	if r.Err() != nil {
+		return r.Err()
+	}
+
+	// iggy_server_semver is optional. If at least 8 bytes remain, the next 4

Review Comment:
   Server encoding has been fixed and now the format is stable. If the semver is missing, it will be encoded as 0, so the following check is no longer required.



##########
foreign/go/contracts/stats.go:
##########
@@ -17,27 +17,142 @@
 
 package iggcon
 
+import (
+	"fmt"
+
+	"github.com/apache/iggy/foreign/go/internal/codec"
+)
+
+// CacheMetrics holds cache hit/miss statistics for a single partition.
+type CacheMetrics struct {
+	StreamId    uint32  `json:"stream_id"`

Review Comment:
   Will this struct work for HTTP? Metrics are serialized as Map with computed strings as keys.
   ```
   impl CacheMetricsKey {
       pub fn to_string_key(&self) -> String {
           format!("{}-{}-{}", self.stream_id, self.topic_id, self.partition_id)
       }
   }
   ```



##########
foreign/go/contracts/stats.go:
##########
@@ -17,27 +17,142 @@
 
 package iggcon
 
+import (
+	"fmt"
+
+	"github.com/apache/iggy/foreign/go/internal/codec"
+)
+
+// CacheMetrics holds cache hit/miss statistics for a single partition.
+type CacheMetrics struct {
+	StreamId    uint32  `json:"stream_id"`
+	TopicId     uint32  `json:"topic_id"`
+	PartitionId uint32  `json:"partition_id"`
+	Hits        uint64  `json:"hits"`
+	Misses      uint64  `json:"misses"`
+	HitRatio    float32 `json:"hit_ratio"`
+}
+
+// cacheMetricsWireSize is the fixed size of a CacheMetrics entry on the wire:
+// stream_id(4) + topic_id(4) + partition_id(4) + hits(8) + misses(8) + hit_ratio(4) = 32.
+const cacheMetricsWireSize = 4 + 4 + 4 + 8 + 8 + 4
+
 type Stats struct {
-	ProcessId           uint32  `json:"process_id"`
-	CpuUsage            float32 `json:"cpu_usage"`
-	TotalCpuUsage       float32 `json:"total_cpu_usage"`
-	MemoryUsage         uint64  `json:"memory_usage"`
-	TotalMemory         uint64  `json:"total_memory"`
-	AvailableMemory     uint64  `json:"available_memory"`
-	RunTime             uint64  `json:"run_time"`
-	StartTime           uint64  `json:"start_time"`
-	ReadBytes           uint64  `json:"read_bytes"`
-	WrittenBytes        uint64  `json:"written_bytes"`
-	MessagesSizeBytes   uint64  `json:"messages_size_bytes"`
-	StreamsCount        uint32  `json:"streams_count"`
-	TopicsCount         uint32  `json:"topics_count"`
-	PartitionsCount     uint32  `json:"partitions_count"`
-	SegmentsCount       uint32  `json:"segments_count"`
-	MessagesCount       uint64  `json:"messages_count"`
-	ClientsCount        uint32  `json:"clients_count"`
-	ConsumerGroupsCount uint32  `json:"consumer_groups_count"`
-	Hostname            string  `json:"hostname"`
-	OsName              string  `json:"os_name"`
-	OsVersion           string  `json:"os_version"`
-	KernelVersion       string  `json:"kernel_version"`
+	ProcessId           uint32         `json:"process_id"`
+	CpuUsage            float32        `json:"cpu_usage"`
+	TotalCpuUsage       float32        `json:"total_cpu_usage"`
+	MemoryUsage         uint64         `json:"memory_usage"`
+	TotalMemory         uint64         `json:"total_memory"`
+	AvailableMemory     uint64         `json:"available_memory"`
+	RunTime             uint64         `json:"run_time"`
+	StartTime           uint64         `json:"start_time"`
+	ReadBytes           uint64         `json:"read_bytes"`
+	WrittenBytes        uint64         `json:"written_bytes"`
+	MessagesSizeBytes   uint64         `json:"messages_size_bytes"`
+	StreamsCount        uint32         `json:"streams_count"`
+	TopicsCount         uint32         `json:"topics_count"`
+	PartitionsCount     uint32         `json:"partitions_count"`
+	SegmentsCount       uint32         `json:"segments_count"`
+	MessagesCount       uint64         `json:"messages_count"`
+	ClientsCount        uint32         `json:"clients_count"`
+	ConsumerGroupsCount uint32         `json:"consumer_groups_count"`
+	Hostname            string         `json:"hostname"`
+	OsName              string         `json:"os_name"`
+	OsVersion           string         `json:"os_version"`
+	KernelVersion       string         `json:"kernel_version"`
+	IggyServerVersion   string         `json:"iggy_server_version"`
+	IggyServerSemver    *uint32        `json:"iggy_server_semver,omitempty"`
+	CacheMetrics        []CacheMetrics `json:"cache_metrics"`
+	ThreadsCount        uint32         `json:"threads_count"`
+	FreeDiskSpace       uint64         `json:"free_disk_space"`
+	TotalDiskSpace      uint64         `json:"total_disk_space"`
+}
+
+func (cm *CacheMetrics) MarshalBinary() ([]byte, error) {
+	w := codec.NewWriterCap(32)
+	w.U32(cm.StreamId)
+	w.U32(cm.TopicId)
+	w.U32(cm.PartitionId)
+	w.U64(cm.Hits)
+	w.U64(cm.Misses)
+	w.F32(cm.HitRatio)
+	return w.Bytes(), w.Err()
+}
+
+func (cm *CacheMetrics) UnmarshalBinary(data []byte) error {
+	r := codec.NewReader(data)
+	cm.StreamId = r.U32()
+	cm.TopicId = r.U32()
+	cm.PartitionId = r.U32()
+	cm.Hits = r.U64()
+	cm.Misses = r.U64()
+	cm.HitRatio = r.F32()
+	return r.Err()
+}
+
+func (s *Stats) UnmarshalBinary(payload []byte) error {
+	r := codec.NewReader(payload)
+	s.ProcessId = r.U32()
+	s.CpuUsage = r.F32()
+	s.TotalCpuUsage = r.F32()
+	s.MemoryUsage = r.U64()
+	s.TotalMemory = r.U64()
+	s.AvailableMemory = r.U64()
+	s.RunTime = r.U64()
+	s.StartTime = r.U64()
+	s.ReadBytes = r.U64()
+	s.WrittenBytes = r.U64()
+	s.MessagesSizeBytes = r.U64()
+	s.StreamsCount = r.U32()
+	s.TopicsCount = r.U32()
+	s.PartitionsCount = r.U32()
+	s.SegmentsCount = r.U32()
+	s.MessagesCount = r.U64()
+	s.ClientsCount = r.U32()
+	s.ConsumerGroupsCount = r.U32()
+	s.Hostname = r.U32LenStr()
+	s.OsName = r.U32LenStr()
+	s.OsVersion = r.U32LenStr()
+	s.KernelVersion = r.U32LenStr()
+	s.IggyServerVersion = r.U32LenStr()
+
+	if r.Err() != nil {
+		return r.Err()
+	}
+
+	// iggy_server_semver is optional. If at least 8 bytes remain, the next 4
+	// bytes are the semver and the following 4 are cache_metrics_count.
+	// If only 4 bytes remain, there is no semver and those 4 bytes are cache_metrics_count.
+	if r.Remaining() >= 8 {
+		v := r.U32()
+		s.IggyServerSemver = &v
+	}
+
+	cacheCount := int(r.U32())
+	if r.Err() != nil {
+		return r.Err()
+	}
+
+	if cacheCount > r.Remaining()/cacheMetricsWireSize {
+		return fmt.Errorf("stats: cache metrics count %d exceeds remaining bytes %d", cacheCount, r.Remaining())
+	}
+
+	if cacheCount > 0 {
+		s.CacheMetrics = make([]CacheMetrics, cacheCount)
+		for i := range s.CacheMetrics {
+			r.Obj(cacheMetricsWireSize, &s.CacheMetrics[i])
+		}
+	}
+
+	if r.Err() == nil && r.Remaining() >= 4 {

Review Comment:
   these 3 properties will always be there



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(go): update stats field and its deserialization logic to align with rust SDK [iggy]

Posted by "chengxilo (via GitHub)" <gi...@apache.org>.
chengxilo commented on code in PR #3032:
URL: https://github.com/apache/iggy/pull/3032#discussion_r3074811395


##########
foreign/go/contracts/stats.go:
##########
@@ -17,27 +17,142 @@
 
 package iggcon
 
+import (
+	"fmt"
+
+	"github.com/apache/iggy/foreign/go/internal/codec"
+)
+
+// CacheMetrics holds cache hit/miss statistics for a single partition.
+type CacheMetrics struct {
+	StreamId    uint32  `json:"stream_id"`

Review Comment:
   Currently Go SDK doesn't support HTTP. the json tags are actually outdated auto-generated code(I guess). Maybe we can address it when we implement the HTTP client.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org