Skip to content

Commit

Permalink
remove redundant configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
guyinyou authored and zhouxinyu committed Oct 11, 2022
1 parent 2cf911c commit 5c72022
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 33 deletions.
2 changes: 1 addition & 1 deletion golang/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion golang/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions golang/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
6 changes: 2 additions & 4 deletions golang/example/consumer/simple_consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions golang/example/producer/async/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions golang/example/producer/delay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions golang/example/producer/fifo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions golang/example/producer/normal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions golang/example/producer/transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
Region = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion golang/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion golang/simple_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,17 @@ 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
}
sc := &defaultSimpleConsumer{
scOpts: *scOpts,
cli: cli.(*defaultClient),
groupName: config.Group,
groupName: config.ConsumerGroup,

awaitDuration: scOpts.awaitDuration,
subscriptionExpressions: scOpts.subscriptionExpressions,
Expand Down

0 comments on commit 5c72022

Please sign in to comment.