Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang: remove redundant configuration #249

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
aaron-ai marked this conversation as resolved.
Show resolved Hide resolved
// new simpleConsumer instance
simpleConsumer, err := golang.NewSimpleConsumer(&golang.Config{
Endpoint: Endpoint,
Group: GroupName,
Region: Region,
Endpoint: Endpoint,
ConsumerGroup: GroupName,
aaron-ai marked this conversation as resolved.
Show resolved Hide resolved
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