This is an automated email from the ASF dual-hosted git repository.

yukon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git

commit 5c7202294b54af1c128906a1b32612ff54b8286c
Author: guyinyou <[email protected]>
AuthorDate: Tue Sep 27 10:54:01 2022 +0800

    remove redundant configuration
---
 golang/client.go                                | 2 +-
 golang/client_test.go                           | 1 -
 golang/config.go                                | 9 ++++-----
 golang/example/consumer/simple_consumer/main.go | 6 ++----
 golang/example/producer/async/main.go           | 4 ----
 golang/example/producer/delay/main.go           | 4 ----
 golang/example/producer/fifo/main.go            | 4 ----
 golang/example/producer/normal/main.go          | 4 ----
 golang/example/producer/transaction/main.go     | 4 ----
 golang/producer_test.go                         | 1 -
 golang/simple_consumer.go                       | 5 ++++-
 11 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/golang/client.go b/golang/client.go
index ee0dc62..c094f1e 100644
--- a/golang/client.go
+++ b/golang/client.go
@@ -507,7 +507,7 @@ func (cli *defaultClient) Sign(ctx context.Context) 
context.Context {
                        innerMD.EncryptHeader,
                        innerMD.Credential,
                        cli.config.Credentials.AccessKey,
-                       cli.config.Region,
+                       "",
                        innerMD.Rocketmq,
                        innerMD.SignedHeaders,
                        innerMD.DateTime,
diff --git a/golang/client_test.go b/golang/client_test.go
index b2a9328..25b43af 100644
--- a/golang/client_test.go
+++ b/golang/client_test.go
@@ -28,7 +28,6 @@ func TestCLINewClient(t *testing.T) {
        endpoints := fmt.Sprintf("%s:%d", fakeHost, fakePort)
        cli, err := NewClient(&Config{
                Endpoint:    endpoints,
-               Group:       "",
                Credentials: &credentials.SessionCredentials{},
        })
        if err != nil {
diff --git a/golang/config.go b/golang/config.go
index c07ce09..42ead57 100644
--- a/golang/config.go
+++ b/golang/config.go
@@ -20,9 +20,8 @@ package golang
 import "github.com/apache/rocketmq-clients/golang/credentials"
 
 type Config struct {
-       Endpoint    string `validate:"required"`
-       Region      string
-       NameSpace   string
-       Group       string                          `validate:"required"`
-       Credentials *credentials.SessionCredentials `validate:"required"`
+       Endpoint      string `validate:"required"`
+       NameSpace     string
+       ConsumerGroup string
+       Credentials   *credentials.SessionCredentials `validate:"required"`
 }
diff --git a/golang/example/consumer/simple_consumer/main.go 
b/golang/example/consumer/simple_consumer/main.go
index c4139b2..b6ff29c 100644
--- a/golang/example/consumer/simple_consumer/main.go
+++ b/golang/example/consumer/simple_consumer/main.go
@@ -32,7 +32,6 @@ const (
        Topic     = "xxxxxx"
        GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -53,9 +52,8 @@ func main() {
        golang.ResetLogger()
        // new simpleConsumer instance
        simpleConsumer, err := golang.NewSimpleConsumer(&golang.Config{
-               Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
+               Endpoint:      Endpoint,
+               ConsumerGroup: GroupName,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/example/producer/async/main.go 
b/golang/example/producer/async/main.go
index 6c1e1df..dde45dd 100644
--- a/golang/example/producer/async/main.go
+++ b/golang/example/producer/async/main.go
@@ -31,9 +31,7 @@ import (
 
 const (
        Topic     = "xxxxxx"
-       GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -45,8 +43,6 @@ func main() {
        // new producer instance
        producer, err := golang.NewProducer(&golang.Config{
                Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/example/producer/delay/main.go 
b/golang/example/producer/delay/main.go
index 695e107..c896cc3 100644
--- a/golang/example/producer/delay/main.go
+++ b/golang/example/producer/delay/main.go
@@ -31,9 +31,7 @@ import (
 
 const (
        Topic     = "xxxxxx"
-       GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -45,8 +43,6 @@ func main() {
        // new producer instance
        producer, err := golang.NewProducer(&golang.Config{
                Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/example/producer/fifo/main.go 
b/golang/example/producer/fifo/main.go
index c2250d3..816d299 100644
--- a/golang/example/producer/fifo/main.go
+++ b/golang/example/producer/fifo/main.go
@@ -31,9 +31,7 @@ import (
 
 const (
        Topic     = "xxxxxx"
-       GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -45,8 +43,6 @@ func main() {
        // new producer instance
        producer, err := golang.NewProducer(&golang.Config{
                Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/example/producer/normal/main.go 
b/golang/example/producer/normal/main.go
index 5be7497..d88ac01 100644
--- a/golang/example/producer/normal/main.go
+++ b/golang/example/producer/normal/main.go
@@ -31,9 +31,7 @@ import (
 
 const (
        Topic     = "xxxxxx"
-       GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -44,8 +42,6 @@ func main() {
        // new producer instance
        producer, err := golang.NewProducer(&golang.Config{
                Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/example/producer/transaction/main.go 
b/golang/example/producer/transaction/main.go
index ac38d38..09a5db1 100644
--- a/golang/example/producer/transaction/main.go
+++ b/golang/example/producer/transaction/main.go
@@ -31,9 +31,7 @@ import (
 
 const (
        Topic     = "xxxxxx"
-       GroupName = "xxxxxx"
        Endpoint  = "xxxxxx"
-       Region    = "xxxxxx"
        AccessKey = "xxxxxx"
        SecretKey = "xxxxxx"
 )
@@ -45,8 +43,6 @@ func main() {
        // new producer instance
        producer, err := golang.NewProducer(&golang.Config{
                Endpoint: Endpoint,
-               Group:    GroupName,
-               Region:   Region,
                Credentials: &credentials.SessionCredentials{
                        AccessKey:    AccessKey,
                        AccessSecret: SecretKey,
diff --git a/golang/producer_test.go b/golang/producer_test.go
index 312fcd7..1313e69 100644
--- a/golang/producer_test.go
+++ b/golang/producer_test.go
@@ -52,7 +52,6 @@ func TestProducer(t *testing.T) {
        endpoints := fmt.Sprintf("%s:%d", fakeHost, fakePort)
        p, err := NewProducer(&Config{
                Endpoint:    endpoints,
-               Group:       MOCK_GROUP,
                Credentials: &credentials.SessionCredentials{},
        })
        if err != nil {
diff --git a/golang/simple_consumer.go b/golang/simple_consumer.go
index 81e98b8..fbb8844 100644
--- a/golang/simple_consumer.go
+++ b/golang/simple_consumer.go
@@ -320,6 +320,9 @@ var NewSimpleConsumer = func(config *Config, opts 
...SimpleConsumerOption) (Simp
        for _, opt := range opts {
                opt.apply(scOpts)
        }
+       if len(config.ConsumerGroup) == 0 {
+               return nil, fmt.Errorf("consumerGroup could not be nil")
+       }
        cli, err := scOpts.clientFunc(config)
        if err != nil {
                return nil, err
@@ -327,7 +330,7 @@ var NewSimpleConsumer = func(config *Config, opts 
...SimpleConsumerOption) (Simp
        sc := &defaultSimpleConsumer{
                scOpts:    *scOpts,
                cli:       cli.(*defaultClient),
-               groupName: config.Group,
+               groupName: config.ConsumerGroup,
 
                awaitDuration:           scOpts.awaitDuration,
                subscriptionExpressions: scOpts.subscriptionExpressions,

Reply via email to