gunli commented on code in PR #8111:
URL: https://github.com/apache/inlong/pull/8111#discussion_r1209652770


##########
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/README.md:
##########
@@ -0,0 +1,197 @@
+# dataproxy-sdk-golang
+
+## Overview
+
+dataproxy-sdk-golang is the golang version of InLong data proxy client SDK.
+

Review Comment:
   fixed now



##########
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/README.md:
##########
@@ -0,0 +1,197 @@
+# dataproxy-sdk-golang
+
+## Overview
+
+dataproxy-sdk-golang is the golang version of InLong data proxy client SDK.
+
+
+
+## Features
+
+- Service discovery;
+- Connection pool, buffer pool, byte pool;
+- Backoff retry;
+- Concurrently batch send;
+- Send synchronously;
+- Send asynchronously;
+- Close gracefully;
+- Hookable debug log;
+- Heartbeat;
+- Metrics;
+- Snappy compress;
+- Additional column;
+- Server offline re-balance;
+
+
+## Usage
+
+### example
+
+refer: cli/main.go
+
+``` go
+package main
+
+import (
+       "context"
+       "errors"
+       "flag"
+       "fmt"
+       "log"
+       "strings"
+       "time"
+
+       "go.uber.org/atomic"
+
+       
"github.com/apache/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy"
+)
+
+var (
+       set      string
+       url      string
+       groupID  string
+       streamID string
+       payload  string
+       count    int
+       addCols  mapFlag
+       async    bool
+       succeed  atomic.Int32
+       failed   atomic.Int32
+)
+
+type mapFlag map[string]string
+
+func (f mapFlag) String() string {
+       return fmt.Sprintf("%v", map[string]string(f))
+}
+
+func (f mapFlag) Set(value string) error {
+       split := strings.SplitN(value, "=", 2)
+       if len(split) < 2 {
+               return errors.New("invalid map flag")
+       }
+
+       f[split[0]] = split[1]
+       return nil
+}
+
+func main() {
+       addCols = make(map[string]string)
+       flag.StringVar(&set, "set", "SH_IEG", "dataproxy set")
+       flag.StringVar(&url, "url", dataproxy.DefaultURL, "dataproxy URL")
+       flag.StringVar(&groupID, "group-id", "b_ieg_tglogv3_test", "dataproxy 
group ID")
+       flag.StringVar(&streamID, "stream-id", "GameSvrState", "dataproxy 
stream ID")
+       flag.StringVar(&payload, "payload", 
"GameSvrState|GameSvrId-Test|2023-01-11 10:08:30|127.0.0.1|1", "message 
payload")
+       flag.IntVar(&count, "count", 10, "send count")
+       flag.Var(&addCols, "col", "add columns, for example: -col k1=v1 -col 
k2=v2")
+       flag.BoolVar(&async, "async", false, "send asynchronously")
+       flag.Parse()
+
+       var err error
+       client, err := dataproxy.NewClient(
+               dataproxy.WithSet(set),
+               dataproxy.WithGroupID(groupID),
+               dataproxy.WithURL(url),
+               dataproxy.WithMetricsName("clit"),
+               dataproxy.WithAddColumns(addCols),
+       )
+
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       msg := dataproxy.Message{GroupID: groupID, StreamID: streamID, Payload: 
[]byte(payload)}
+       for i := 0; i < count; i++ {
+               if !async {
+                       err = client.Send(context.Background(), msg)
+                       if err != nil {
+                               fmt.Println(err)
+                       }
+               } else {
+                       client.SendAsync(context.Background(), msg, onResult)
+               }
+       }
+
+       if async {
+               wait()
+       }
+}
+
+func onResult(msg dataproxy.Message, err error) {
+       if err != nil {
+               fmt.Println("error message, streamID = " + msg.StreamID + ", 
Payload = " + string(msg.Payload))
+               failed.Add(1)
+       } else {
+               succeed.Add(1)
+       }
+}
+
+func wait() {
+       for {
+               if int(succeed.Load()+failed.Load()) >= count {
+                       fmt.Println("succeed:", succeed.Load())
+                       fmt.Println("failed:", failed.Load())
+                       return
+               }
+               time.Sleep(1 * time.Second)
+       }
+}
+
+```
+
+### Options
+
+refer: dataproxy/options.go
+
+``` go
+// Options is the data proxy go client configs

Review Comment:
   fixed now



-- 
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