This is an automated email from the ASF dual-hosted git repository.
goodboycoder pushed a commit to branch feature/add-ospp-sample
in repository https://gitbox.apache.org/repos/asf/incubator-seata-go-samples.git
The following commit(s) were added to refs/heads/feature/add-ospp-sample by
this push:
new 9f98e98 upd-ospp (#78)
9f98e98 is described below
commit 9f98e982c0d7e218da6147080144c818d2e05625
Author: flypiggy <[email protected]>
AuthorDate: Thu Oct 30 23:13:33 2025 +0800
upd-ospp (#78)
---
.../advanced/load-balancing/client.go | 55 ++++++++++++++
grpc-communication/basic/client/main.go | 82 +++++++++++++++++++++
grpc-communication/basic/config/seata-grpc.yml | 83 ++++++++++++++++++++++
3 files changed, 220 insertions(+)
diff --git a/grpc-communication/advanced/load-balancing/client.go
b/grpc-communication/advanced/load-balancing/client.go
new file mode 100644
index 0000000..b66d643
--- /dev/null
+++ b/grpc-communication/advanced/load-balancing/client.go
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+// Package main demonstrates GRPC load balancing strategies with Seata server
+package main
+
+import (
+ "context"
+ "fmt"
+
+ "seata.apache.org/seata-go/pkg/client"
+ "seata.apache.org/seata-go/pkg/tm"
+)
+
+// TODO: Implement when GRPC load balancing features are merged
+// This sample will demonstrate:
+// 1. Round-robin load balancing
+// 2. Weighted load balancing
+// 3. Consistent hash load balancing
+// 4. Health-check based load balancing
+
+func main() {
+ fmt.Println("=== GRPC Load Balancing Sample ===")
+ fmt.Println("TODO: Implement advanced load balancing strategies")
+
+ // Placeholder initialization
+ client.Init()
+
+ // TODO: Demonstrate different load balancing strategies
+ err := tm.WithGlobalTx(context.Background(), &tm.GtxConfig{
+ Name: "LoadBalancingSample",
+ }, func(ctx context.Context) error {
+ // TODO: Show load balancing in action
+ fmt.Println("Demonstrating load balancing across multiple Seata
servers")
+ return nil
+ })
+
+ if err != nil {
+ fmt.Printf("Load balancing sample failed: %v\n", err)
+ }
+}
diff --git a/grpc-communication/basic/client/main.go
b/grpc-communication/basic/client/main.go
new file mode 100644
index 0000000..6270411
--- /dev/null
+++ b/grpc-communication/basic/client/main.go
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+// Package main demonstrates basic GRPC communication with Seata server
+package main
+
+import (
+ "context"
+ "flag"
+ "fmt"
+ "log"
+ "time"
+
+ "seata.apache.org/seata-go/pkg/client"
+ "seata.apache.org/seata-go/pkg/tm"
+ "seata.apache.org/seata-go/pkg/util/log"
+)
+
+var (
+ configPath = flag.String("config", "../config/seata-grpc.yml", "config
file path")
+)
+
+func main() {
+ flag.Parse()
+
+ fmt.Println("=== Seata GRPC Communication Basic Client Sample ===")
+ fmt.Println("This sample demonstrates basic GRPC communication between
client and Seata server")
+
+ // Initialize seata client with GRPC protocol
+ // The configuration will specify GRPC as the communication protocol
+ client.InitPath(*configPath)
+ log.Info("Seata client initialized with GRPC protocol")
+
+ // TODO: Once new GRPC features are merged, this will demonstrate:
+ // 1. Direct GRPC connection to Seata server
+ // 2. Enhanced GRPC communication features
+ // 3. Improved performance and reliability
+
+ // For now, demonstrate basic global transaction that works with
current version
+ err := tm.WithGlobalTx(context.Background(), &tm.GtxConfig{
+ Name: "BasicGrpcCommunicationSample",
+ Timeout: 30 * time.Second,
+ }, func(ctx context.Context) error {
+ // This transaction will use the configured GRPC protocol to
communicate with Seata server
+ fmt.Printf("Global transaction started with XID: %s\n",
tm.GetXID(ctx))
+ fmt.Println("Communication protocol: GRPC")
+
+ // TODO: Add more sophisticated GRPC communication examples
once new features are available:
+ // - Streaming communication
+ // - Load balancing
+ // - Connection pooling
+ // - Monitoring and metrics
+
+ // Simulate business logic
+ fmt.Println("Executing business logic...")
+ time.Sleep(1 * time.Second)
+ fmt.Println("Business logic completed successfully")
+
+ return nil
+ })
+
+ if err != nil {
+ log.Fatalf("Global transaction failed: %v", err)
+ }
+
+ fmt.Println("✓ Basic GRPC communication sample completed successfully")
+ fmt.Println("✓ This demonstrates the foundation for advanced GRPC
features")
+}
diff --git a/grpc-communication/basic/config/seata-grpc.yml
b/grpc-communication/basic/config/seata-grpc.yml
new file mode 100644
index 0000000..606fc56
--- /dev/null
+++ b/grpc-communication/basic/config/seata-grpc.yml
@@ -0,0 +1,83 @@
+# Seata GRPC Communication Configuration
+# This configuration demonstrates how to enable GRPC protocol for Seata
communication
+
+seata:
+ enabled: true
+ application-id: "grpc-communication-sample"
+ tx-service-group: "grpc_tx_group"
+ enable-auto-data-source-proxy: false
+
+ # Transport configuration - GRPC protocol
+ transport:
+ # Set protocol to grpc to enable GRPC communication
+ protocol: "grpc"
+ server: "NIO"
+ heartbeat: true
+ enableClientBatchSendRequest: false
+ threadFactory:
+ bossThreadPrefix: "NettyBoss"
+ workerThreadPrefix: "NettyServerNIOWorker"
+ serverExecutorThreadPrefix: "NettyServerBizHandler"
+ shareBossWorker: false
+ clientSelectorThreadPrefix: "NettyClientSelector"
+ clientSelectorThreadSize: 1
+ clientWorkerThreadPrefix: "NettyClientWorkerThread"
+ bossThreadSize: 1
+ workerThreadSize: "default"
+ shutdown:
+ wait: 3
+ serialization: "seata"
+ compressor: "none"
+
+ # Service discovery configuration
+ service:
+ vgroup-mapping:
+ grpc_tx_group: "default"
+ grouplist:
+ default: "127.0.0.1:8091"
+ enable-degrade: false
+ disable-global-transaction: false
+
+ # Registry configuration
+ registry:
+ type: "file"
+ file:
+ name: "file.conf"
+
+ # Client configuration
+ client:
+ rm:
+ async-commit-buffer-limit: 10000
+ lock:
+ retry-interval: 10
+ retry-times: 30
+ retry-policy-branch-rollback-on-conflict: true
+ tm:
+ commit-retry-count: 5
+ rollback-retry-count: 5
+ default-global-transaction-timeout: 60000
+ degrade-check: false
+ degrade-check-period: 2000
+ degrade-check-allow-times: 10
+ undo:
+ data-validation: true
+ log-serialization: "jackson"
+ log-table: "undo_log"
+ only-care-update-columns: true
+ load-balance:
+ type: "RandomLoadBalance"
+ virtual-nodes: 10
+
+ # TODO: Enhanced GRPC-specific configurations will be added here
+ # when new GRPC features are merged:
+ # grpc:
+ # connection-pool:
+ # max-connections: 10
+ # min-connections: 1
+ # load-balancing:
+ # strategy: "round_robin"
+ # streaming:
+ # enabled: true
+ # monitoring:
+ # enabled: true
+ # metrics-port: 9090
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]