jt2594838 commented on code in PR #179:
URL: https://github.com/apache/iotdb-client-go/pull/179#discussion_r4608722430


##########
subscription/internal/record/tablet.go:
##########


Review Comment:
   Is it possible to reuse the structures already defined in Session-go?



##########
subscription/README.md:
##########
@@ -0,0 +1,390 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Go Subscription API
+
+The module implements `SubscriptionSession` management, Pull consumption with 
record polling, commits, progress, seek, processor pipelines, and background 
connection coordination, and Push consumption with sequential callbacks and 
acknowledgment strategies. Poll response decoding, record decoding, and message 
release are also connected. Built-in Watermark and ColumnAlign processors are 
available for the Pull pipeline. These implementations have not been compiled 
or exercised at runtime; this document describes the code and its contracts.
+
+The module path is `github.com/apache/iotdb-client-go/subscription`. It uses 
Go 1.25 and maintains dependencies and versions separately from the existing 
`github.com/apache/iotdb-client-go/v2` Session module. Its direct dependencies 
are `github.com/apache/iotdb-client-go/v2` at 
`v2.0.0-20260914074454-a25f68aa9681`, which provides existing types such as 
`TSDataType` and `ColumnCategory`, and `github.com/apache/thrift` at `v0.24.0`, 
which provides the RPC transport and protocol. It adds no TsFile, cgo, or TLS 
dependency and does not change the existing Session interfaces.
+
+The Java reference is `iotdb-client/subscription` at IoTDB commit 
`d9122d837610`. The supported payload format is records: this module defines no 
TsFile handler, download, file-management, or Reader API. Topic management and 
`Subscribe` do not reject TsFile topics in advance. Dispatching a file payload 
during decoding returns `ErrUnsupportedTsFile`; that payload must not be 
delivered or acknowledged.
+
+Standalone [tree and table examples](../example/subscription/README.md) cover 
ordinary record Pull/Push consumption and incremental subscriptions with 
progress, checkpoint resume, and optional processors. They belong to the 
independent example module, alongside the existing Session and database/sql 
examples, and use the Session client to prepare sample data.
+
+## Package Responsibilities and Import Migration
+
+Public business APIs now live in packages within this subscription module. The 
root package contains only shared `Dialect`, `TreeDialect`, `TableDialect`, 
`ConnectionConfig`, and sentinel errors. Previous root business imports must 
move to the owning package; there are no root compatibility aliases or 
forwarding constructors. Public type and method names retain their original 
meanings.
+
+| Package under `github.com/apache/iotdb-client-go/subscription` | Public 
responsibility |
+| --- | --- |
+| Root `subscription` | Model selection, shared connection settings, and error 
identities used with `errors.Is` |
+| `session` | `SubscriptionSession`, its configuration/default/constructor, 
topic and subscription management DTOs, and SQL management operations |
+| `consumer` | Pull/Push lifecycle and configuration/defaults/constructors, 
`AckStrategy`, `ConsumeFunc`, consumer identity, `PollResult`, and `Positioner` 
|
+| `payload` | Messages, kinds, batches, rows, columns, commit contexts, 
topic/region progress, and Writer identity/progress types |
+| `processor` | Processing capability interfaces, buffering metadata, 
Watermark and ColumnAlign implementations/configuration/constructors |
+
+The snippets below use explicit aliases so local variables named `consumer`, 
`session`, or `processor` do not hide package constructors:
+
+```go
+import (
+    "github.com/apache/iotdb-client-go/subscription"
+    subconsumer "github.com/apache/iotdb-client-go/subscription/consumer"
+    subpayload "github.com/apache/iotdb-client-go/subscription/payload"
+    subprocessor "github.com/apache/iotdb-client-go/subscription/processor"
+    subsession "github.com/apache/iotdb-client-go/subscription/session"
+)
+```
+
+Import only the packages used by your program. For example, migrate 
`subscription.NewSubscriptionSession` to `subsession.NewSubscriptionSession`, 
consumer constructors to `subconsumer`, `SubscriptionMessage` and 
`TopicProgress` to `subpayload`, and processor constructors/interfaces to 
`subprocessor`. Shared settings, model constants, and sentinel errors continue 
to use `subscription`.
+
+Seven internal packages implement the lower-level boundaries:
+
+| Internal package | Responsibility |
+| --- | --- |
+| `internal/wire` | Java-compatible primitive binary readers/writers and 
bounds checking |
+| `internal/transport` | Plain TCP/framed Thrift client construction, socket 
cancellation, and idempotent connection shutdown |
+| `internal/identifier` | SQL identifier validation and protocol identifier 
parsing |
+| `internal/configutil` | Shared connection defaults/copying/validation and 
dialect normalization |
+| `internal/record` | Concrete record/watermark messages, borrowed batch 
storage, ordering views, release, and ownership |
+| `internal/protocol` | Subscription request/response codecs, commit/progress 
formats, Tablet decoding, continuation checks, and payload dispatch |
+| `internal/rpcsession` | Authentication, Session/statement IDs, RPC calls, 
SHOW result pagination/decoding, and query cleanup |
+
+The root shared package has no dependency on business packages. `payload` 
defines the shared contracts; concrete record storage implements those 
contracts internally. `session` coordinates management over 
`internal/rpcsession`; `consumer` coordinates providers, protocol events, 
progress, and processor pipelines; `processor` consumes payload contracts and 
builds owned record output through internal record support. Lower-level 
packages do not import these public coordinators. All seven internal packages 
remain in the existing subscription module and are unavailable as external 
public import paths.
+
+Package boundaries do not add modules or dependencies. The subscription 
module, the existing independent example module, and the independent E2E module 
retain their own `go.mod` files alongside the root Session module. The example 
and E2E modules keep local replacements for the two production modules. Their 
module paths and dependency versions are unchanged by this package migration.
+
+## Configuration and Data Model Selection
+
+In this section, model constants and `ConnectionConfig` belong to the root 
package; management configuration belongs to `session`, and consumer 
configuration and acknowledgment types belong to `consumer`.
+
+Go uses `Dialect` to distinguish the tree and table models. Management and 
consumption each share a contract rather than duplicating Java's tree/table 
types and Builder hierarchy.
+
+Java's `ISubscriptionTreeSession/ISubscriptionTableSession`, tree/table Pull 
interfaces, and tree/table Push interfaces have identical method signatures 
within each pair. Go therefore uses `SubscriptionSession`, 
`SubscriptionPullConsumer`, and `SubscriptionPushConsumer` for those common 
operations. Configuration selects the model through `Dialect`; each instance 
uses one model.
+
+Only the public method contract is shared. Management sessions pass the model 
when connecting. Consumer handshakes carry the selected model, and record 
decoding distinguishes tree device paths from table databases, tables, and TAG 
identities. Sharing an interface does not require the two models to use the 
same internal implementation.
+
+| Public Go type | Java counterpart | Go representation |
+| --- | --- | --- |
+| `Dialect`, `TreeDialect`, `TableDialect` | Tree/table Session and Consumer 
types, SQL dialect | Select the model in `SubscriptionSessionConfig` or 
`SubscriptionConsumerConfig` |
+| `ConnectionConfig` | Session/Consumer Builder settings for nodes, 
authentication, connection timeout, and maximum frame size | `NodeURLs` 
represents either a single node or cluster seed addresses; durations use 
`time.Duration`; plaintext and encrypted passwords are mutually exclusive |
+| `SubscriptionSessionConfig` | `SubscriptionTreeSessionBuilder`, 
`SubscriptionTableSessionBuilder` | Obtain defaults through 
`DefaultSubscriptionSessionConfig`, then pass them to `NewSubscriptionSession`; 
construction does not connect |
+| `SubscriptionConsumerConfig` | `AbstractSubscriptionConsumerBuilder` | 
Shared configuration for consumer identity, ownership, heartbeats, endpoint 
synchronization, and parallelism |
+| `SubscriptionPullConsumerConfig` | `AbstractSubscriptionPullConsumerBuilder` 
| `AutoCommit == nil` selects Java's default, `true`; a pointer to `false` 
explicitly selects manual commits |
+| `SubscriptionPushConsumerConfig` | `AbstractSubscriptionPushConsumerBuilder` 
| Combines a Handler, ACK strategy, and polling interval and timeout |
+| `AckStrategy`, `AckAfterConsume`, `AckBeforeConsume` | 
`AckStrategy.AFTER_CONSUME`, `BEFORE_CONSUME` | The zero value acknowledges 
after consumption; callback failure does not cause redelivery when 
acknowledgment precedes consumption |
+
+`SubscriptionConsumerConfig.OwnerEpoch == nil` means that no epoch was 
supplied; a pointer to zero explicitly supplies epoch 0. 
`DefaultSubscriptionConsumerConfig`, `DefaultSubscriptionPullConsumerConfig`, 
and `DefaultSubscriptionPushConsumerConfig` are available. The default Push 
Handler remains nil, so callers must supply a real handler. Internal 
normalization copies endpoint slices and optional pointers. Zero durations 
select defaults, negative durations return errors, and positive values below 
Java's minimum are raised to that minimum. Construct consumers with 
`NewSubscriptionPullConsumer` or `NewSubscriptionPushConsumer`; neither 
constructor connects to the network.
+
+The management session defaults are `localhost:6667`, the tree model, 
root/root authentication, a 64 MiB frame limit, and a ten-second connection and 
authentication timeout. Java management sessions do not limit connection time 
by default; the Go entry point uses a bounded timeout here. The constructor 
fills empty endpoints, username, and dialect, as well as zero timeout and frame 
size, validates addresses and mutually exclusive authentication, and copies the 
endpoint slice. Passwords are always preserved as supplied, including empty 
strings. Start with the default configuration function when root/root defaults 
are needed. To use an encrypted password, clear `Password` and set 
`EncryptedPassword`.

Review Comment:
   No need to involve too many technical details and comparisons with the Java 
edition. 
   Concentrate on what a real user would concern.
   If you wish, may put them in a separate technical report.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to