Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
guyinyou authored and zhouxinyu committed Oct 11, 2022
1 parent 5c72022 commit 9542c7d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
24 changes: 12 additions & 12 deletions golang/example/consumer/simple_consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ import (
"os"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

const (
Topic = "xxxxxx"
GroupName = "xxxxxx"
Endpoint = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
Topic = "xxxxxx"
ConsumerGroup = "xxxxxx"
Endpoint = "xxxxxx"
AccessKey = "xxxxxx"
SecretKey = "xxxxxx"
)

var (
Expand All @@ -49,19 +49,19 @@ var (
func main() {
// log to console
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new simpleConsumer instance
simpleConsumer, err := golang.NewSimpleConsumer(&golang.Config{
simpleConsumer, err := rmq_client.NewSimpleConsumer(&rmq_client.Config{
Endpoint: Endpoint,
ConsumerGroup: GroupName,
ConsumerGroup: ConsumerGroup,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithAwaitDuration(awaitDuration),
golang.WithSubscriptionExpressions(map[string]*golang.FilterExpression{
Topic: golang.SUB_ALL,
rmq_client.WithAwaitDuration(awaitDuration),
rmq_client.WithSubscriptionExpressions(map[string]*rmq_client.FilterExpression{
Topic: rmq_client.SUB_ALL,
}),
)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions golang/example/producer/async/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

Expand All @@ -39,16 +39,16 @@ const (
func main() {
// log to console
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new producer instance
producer, err := golang.NewProducer(&golang.Config{
producer, err := rmq_client.NewProducer(&rmq_client.Config{
Endpoint: Endpoint,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithTopics(Topic),
rmq_client.WithTopics(Topic),
)
if err != nil {
log.Fatal(err)
Expand All @@ -62,15 +62,15 @@ func main() {
defer producer.GracefulStop()
for i := 0; i < 10; i++ {
// new a message
msg := &golang.Message{
msg := &rmq_client.Message{
Topic: Topic,
Body: []byte("this is a message : " + strconv.Itoa(i)),
}
// set keys and tag
msg.SetKeys("a", "b")
msg.SetTag("ab")
// send message in async
producer.SendAsync(context.TODO(), msg, func(ctx context.Context, resp []*golang.SendReceipt, err error) {
producer.SendAsync(context.TODO(), msg, func(ctx context.Context, resp []*rmq_client.SendReceipt, err error) {
if err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions golang/example/producer/delay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

Expand All @@ -39,16 +39,16 @@ const (
func main() {
// log to console
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new producer instance
producer, err := golang.NewProducer(&golang.Config{
producer, err := rmq_client.NewProducer(&rmq_client.Config{
Endpoint: Endpoint,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithTopics(Topic),
rmq_client.WithTopics(Topic),
)
if err != nil {
log.Fatal(err)
Expand All @@ -62,7 +62,7 @@ func main() {
defer producer.GracefulStop()
for i := 0; i < 10; i++ {
// new a message
msg := &golang.Message{
msg := &rmq_client.Message{
Topic: Topic,
Body: []byte("this is a message : " + strconv.Itoa(i)),
}
Expand Down
10 changes: 5 additions & 5 deletions golang/example/producer/fifo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

Expand All @@ -39,16 +39,16 @@ const (
func main() {
// log to console
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new producer instance
producer, err := golang.NewProducer(&golang.Config{
producer, err := rmq_client.NewProducer(&rmq_client.Config{
Endpoint: Endpoint,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithTopics(Topic),
rmq_client.WithTopics(Topic),
)
if err != nil {
log.Fatal(err)
Expand All @@ -62,7 +62,7 @@ func main() {
defer producer.GracefulStop()
for i := 0; i < 10; i++ {
// new a message
msg := &golang.Message{
msg := &rmq_client.Message{
Topic: Topic,
Body: []byte("this is a message : " + strconv.Itoa(i)),
}
Expand Down
10 changes: 5 additions & 5 deletions golang/example/producer/normal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

Expand All @@ -38,16 +38,16 @@ const (

func main() {
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new producer instance
producer, err := golang.NewProducer(&golang.Config{
producer, err := rmq_client.NewProducer(&rmq_client.Config{
Endpoint: Endpoint,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithTopics(Topic),
rmq_client.WithTopics(Topic),
)
if err != nil {
log.Fatal(err)
Expand All @@ -62,7 +62,7 @@ func main() {

for i := 0; i < 10; i++ {
// new a message
msg := &golang.Message{
msg := &rmq_client.Message{
Topic: Topic,
Body: []byte("this is a message : " + strconv.Itoa(i)),
}
Expand Down
16 changes: 8 additions & 8 deletions golang/example/producer/transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/apache/rocketmq-clients/golang"
rmq_client "github.com/apache/rocketmq-clients/golang"
"github.com/apache/rocketmq-clients/golang/credentials"
)

Expand All @@ -39,22 +39,22 @@ const (
func main() {
// log to console
os.Setenv("mq.consoleAppender.enabled", "true")
golang.ResetLogger()
rmq_client.ResetLogger()
// new producer instance
producer, err := golang.NewProducer(&golang.Config{
producer, err := rmq_client.NewProducer(&rmq_client.Config{
Endpoint: Endpoint,
Credentials: &credentials.SessionCredentials{
AccessKey: AccessKey,
AccessSecret: SecretKey,
},
},
golang.WithTransactionChecker(&golang.TransactionChecker{
Check: func(msg *golang.MessageView) golang.TransactionResolution {
rmq_client.WithTransactionChecker(&rmq_client.TransactionChecker{
Check: func(msg *rmq_client.MessageView) rmq_client.TransactionResolution {
log.Printf("check transaction message: %v", msg)
return golang.COMMIT
return rmq_client.COMMIT
},
}),
golang.WithTopics(Topic),
rmq_client.WithTopics(Topic),
)
if err != nil {
log.Fatal(err)
Expand All @@ -68,7 +68,7 @@ func main() {
defer producer.GracefulStop()
for i := 0; i < 10; i++ {
// new a message
msg := &golang.Message{
msg := &rmq_client.Message{
Topic: Topic,
Body: []byte("this is a message : " + strconv.Itoa(i)),
}
Expand Down

0 comments on commit 9542c7d

Please sign in to comment.