Skip to content

Commit a9c6351

Browse files
authored
feat: change name (#3)
1 parent a800af2 commit a9c6351

File tree

15 files changed

+67
-66
lines changed

15 files changed

+67
-66
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# goqu
2-
GoQu - Golang Queue Wrapper for all queue platforms
1+
# goqueue
2+
3+
GoQueue - Golang Queue Wrapper for all queue platforms

consumer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package goqu
1+
package goqueue
22

33
import "context"
44

consumer/option.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package consumer
22

3-
import "github.com/bxcodec/goqu"
3+
import "github.com/bxcodec/goqueue"
44

55
// Option represents the configuration options for the consumer.
66
type Option struct {
@@ -9,7 +9,7 @@ type Option struct {
99
// QueueName specifies the name of the queue to consume messages from.
1010
QueueName string
1111
// Middlewares is a list of middleware functions to be applied to the inbound message handler.
12-
Middlewares []goqu.InboundMessageHandlerMiddlewareFunc
12+
Middlewares []goqueue.InboundMessageHandlerMiddlewareFunc
1313
}
1414

1515
// OptionFunc is a function type that takes an `opt` parameter of type `*Option`.
@@ -35,7 +35,7 @@ func WithQueueName(name string) OptionFunc {
3535
// WithMiddlewares is an OptionFunc that sets the provided middlewares for the consumer.
3636
// Middlewares are used to process inbound messages before they are handled by the consumer.
3737
// The middlewares are applied in the order they are provided.
38-
func WithMiddlewares(middlewares ...goqu.InboundMessageHandlerMiddlewareFunc) OptionFunc {
38+
func WithMiddlewares(middlewares ...goqueue.InboundMessageHandlerMiddlewareFunc) OptionFunc {
3939
return func(opt *Option) {
4040
opt.Middlewares = middlewares
4141
}

consumer/rabbitmq/consumer.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
amqp "github.com/rabbitmq/amqp091-go"
1010
"github.com/sirupsen/logrus"
1111

12-
"github.com/bxcodec/goqu"
13-
"github.com/bxcodec/goqu/consumer"
14-
headerKey "github.com/bxcodec/goqu/headers/key"
15-
headerVal "github.com/bxcodec/goqu/headers/value"
16-
"github.com/bxcodec/goqu/middleware"
12+
"github.com/bxcodec/goqueue"
13+
"github.com/bxcodec/goqueue/consumer"
14+
headerKey "github.com/bxcodec/goqueue/headers/key"
15+
headerVal "github.com/bxcodec/goqueue/headers/value"
16+
"github.com/bxcodec/goqueue/middleware"
1717
)
1818

1919
// rabbitMQ is the subscriber handler for rabbitmq
@@ -28,7 +28,7 @@ type rabbitMQ struct {
2828

2929
var defaultOption = func() *consumer.Option {
3030
return &consumer.Option{
31-
Middlewares: []goqu.InboundMessageHandlerMiddlewareFunc{},
31+
Middlewares: []goqueue.InboundMessageHandlerMiddlewareFunc{},
3232
}
3333
}
3434

@@ -37,7 +37,7 @@ func NewConsumer(
3737
client *amqp.Connection,
3838
consumerChannel *amqp.Channel,
3939
requeueChannel *amqp.Channel,
40-
opts ...consumer.OptionFunc) goqu.Consumer {
40+
opts ...consumer.OptionFunc) goqueue.Consumer {
4141
opt := defaultOption()
4242
for _, o := range opts {
4343
o(opt)
@@ -84,7 +84,7 @@ func (r *rabbitMQ) initConsumer() {
8484
false,
8585
// queue arguments
8686
// TODO(bxcodec): to support custom queue arguments on consumer initialization
87-
// https://github.com/bxcodec/goqu/issues/1
87+
// https://github.com/bxcodec/goqueue/issues/1
8888
nil,
8989
)
9090
if err != nil {
@@ -99,7 +99,7 @@ func (r *rabbitMQ) initConsumer() {
9999
// If the context is canceled, the method stops consuming messages and returns.
100100
// The method returns an error if there was an issue consuming messages.
101101
func (r *rabbitMQ) Consume(ctx context.Context,
102-
h goqu.InboundMessageHandler,
102+
h goqueue.InboundMessageHandler,
103103
meta map[string]interface{}) (err error) {
104104
logrus.WithFields(logrus.Fields{
105105
"queue_name": r.option.QueueName,
@@ -115,7 +115,7 @@ func (r *rabbitMQ) Consume(ctx context.Context,
115115
}).Info("stopping the worker")
116116
return
117117
case receivedMsg := <-r.msgReceiver:
118-
msg := &goqu.Message{
118+
msg := &goqueue.Message{
119119
ID: extractHeaderString(receivedMsg.Headers, headerKey.AppID),
120120
Timestamp: extractHeaderTime(receivedMsg.Headers, headerKey.PublishedTimestamp),
121121
Action: receivedMsg.RoutingKey,
@@ -126,7 +126,7 @@ func (r *rabbitMQ) Consume(ctx context.Context,
126126
ServiceAgent: headerVal.GoquServiceAgent(extractHeaderString(receivedMsg.Headers, headerKey.QueueServiceAgent)),
127127
}
128128
msg.SetSchemaVersion(extractHeaderString(receivedMsg.Headers, headerKey.SchemaVer))
129-
m := goqu.InboundMessage{
129+
m := goqueue.InboundMessage{
130130
Message: *msg,
131131
RetryCount: extractHeaderInt(receivedMsg.Headers, headerKey.RetryCount),
132132
Metadata: map[string]interface{}{
@@ -161,9 +161,9 @@ func (r *rabbitMQ) Consume(ctx context.Context,
161161
err = receivedMsg.Nack(false, false)
162162
return
163163
},
164-
Requeue: func(ctx context.Context, delayFn goqu.DelayFn) (err error) {
164+
Requeue: func(ctx context.Context, delayFn goqueue.DelayFn) (err error) {
165165
if delayFn == nil {
166-
delayFn = goqu.DefaultDelayFn
166+
delayFn = goqueue.DefaultDelayFn
167167
}
168168
retries := extractHeaderInt(receivedMsg.Headers, headerKey.RetryCount)
169169
retries++

delayfn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package goqu
1+
package goqueue
22

33
type DelayFn func(retries int64) (delay int64)
44

encoding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package goqu
1+
package goqueue
22

33
import (
44
"context"
55
"encoding/json"
66
"sync"
77

8-
headerVal "github.com/bxcodec/goqu/headers/value"
8+
headerVal "github.com/bxcodec/goqueue/headers/value"
99
)
1010

1111
type EncoderFn func(ctx context.Context, m Message) (data []byte, err error)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/bxcodec/goqu
1+
module github.com/bxcodec/goqueue
22

33
go 1.20
44

headers/key/const.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package key
22

33
const (
4-
AppID = "goqu-app-id"
5-
PublishedTimestamp = "goqu-published-timestamp"
6-
RequeuedTimestamp = "goqu-requeued-timestamp"
7-
RetryCount = "goqu-retry-count"
8-
SchemaVer = "goqu-schema-version"
9-
ContentType = "goqu-content-type"
10-
QueueServiceAgent = "goqu-queue-service-agent"
11-
MessageID = "goqu-message-id"
4+
AppID = "goqueue-app-id"
5+
PublishedTimestamp = "goqueue-published-timestamp"
6+
RequeuedTimestamp = "goqueue-requeued-timestamp"
7+
RetryCount = "goqueue-retry-count"
8+
SchemaVer = "goqueue-schema-version"
9+
ContentType = "goqueue-content-type"
10+
QueueServiceAgent = "goqueue-queue-service-agent"
11+
MessageID = "goqueue-message-id"
1212
)

message.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package goqu
1+
package goqueue
22

33
import (
44
"time"
55

6-
headerVal "github.com/bxcodec/goqu/headers/value"
6+
headerVal "github.com/bxcodec/goqueue/headers/value"
77
)
88

99
// Message represents a message that will be published to the queue

middleware/middleware.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package middleware
33
import (
44
"context"
55

6-
"github.com/bxcodec/goqu"
6+
"github.com/bxcodec/goqueue"
77
"github.com/sirupsen/logrus"
88
)
99

1010
// ApplyHandlerMiddleware applies a series of middleware functions to an inbound message handler function.
1111
// It takes an inbound message handler function `h` and a variadic list of middleware functions `middleware`.
1212
// Each middleware function is applied to the handler function in the order they are provided.
1313
// The resulting handler function with all the middleware applied is returned.
14-
func ApplyHandlerMiddleware(h goqu.InboundMessageHandlerFunc, middleware ...goqu.InboundMessageHandlerMiddlewareFunc) goqu.InboundMessageHandlerFunc {
14+
func ApplyHandlerMiddleware(h goqueue.InboundMessageHandlerFunc, middleware ...goqueue.InboundMessageHandlerMiddlewareFunc) goqueue.InboundMessageHandlerFunc {
1515
for _, middleware := range middleware {
1616
h = middleware(h)
1717
}
@@ -21,7 +21,7 @@ func ApplyHandlerMiddleware(h goqu.InboundMessageHandlerFunc, middleware ...goqu
2121
// ApplyPublisherMiddleware applies the given publisher middleware functions to the provided publisher function.
2222
// It iterates over the middleware functions and applies them in the order they are provided.
2323
// The resulting publisher function is returned.
24-
func ApplyPublisherMiddleware(p goqu.PublisherFunc, middleware ...goqu.PublisherMiddlewareFunc) goqu.PublisherFunc {
24+
func ApplyPublisherMiddleware(p goqueue.PublisherFunc, middleware ...goqueue.PublisherMiddlewareFunc) goqueue.PublisherFunc {
2525
for _, middleware := range middleware {
2626
p = middleware(p)
2727
}
@@ -32,9 +32,9 @@ func ApplyPublisherMiddleware(p goqu.PublisherFunc, middleware ...goqu.Publisher
3232
// It wraps the provided `next` inbound message handler function and executes some additional logic after it.
3333
// The additional logic includes logging any error that occurred during the execution of the `next` function
3434
// and logging a message indicating that the middleware has been executed.
35-
func HelloWorldMiddlewareExecuteAfterHandler() goqu.InboundMessageHandlerMiddlewareFunc {
36-
return func(next goqu.InboundMessageHandlerFunc) goqu.InboundMessageHandlerFunc {
37-
return func(ctx context.Context, m goqu.InboundMessage) (err error) {
35+
func HelloWorldMiddlewareExecuteAfterHandler() goqueue.InboundMessageHandlerMiddlewareFunc {
36+
return func(next goqueue.InboundMessageHandlerFunc) goqueue.InboundMessageHandlerFunc {
37+
return func(ctx context.Context, m goqueue.InboundMessage) (err error) {
3838
err = next(ctx, m)
3939
if err != nil {
4040
logrus.Error("Error: ", err, "processing to sent the error to Sentry")
@@ -46,9 +46,9 @@ func HelloWorldMiddlewareExecuteAfterHandler() goqu.InboundMessageHandlerMiddlew
4646
}
4747

4848
// HelloWorldMiddlewareExecuteBeforeHandler returns a middleware function that logs a message before executing the handler.
49-
func HelloWorldMiddlewareExecuteBeforeHandler() goqu.InboundMessageHandlerMiddlewareFunc {
50-
return func(next goqu.InboundMessageHandlerFunc) goqu.InboundMessageHandlerFunc {
51-
return func(ctx context.Context, m goqu.InboundMessage) (err error) {
49+
func HelloWorldMiddlewareExecuteBeforeHandler() goqueue.InboundMessageHandlerMiddlewareFunc {
50+
return func(next goqueue.InboundMessageHandlerFunc) goqueue.InboundMessageHandlerFunc {
51+
return func(ctx context.Context, m goqueue.InboundMessage) (err error) {
5252
logrus.Info("hello-world-first-middleware executed")
5353
return next(ctx, m)
5454
}
@@ -57,9 +57,9 @@ func HelloWorldMiddlewareExecuteBeforeHandler() goqu.InboundMessageHandlerMiddle
5757

5858
// HelloWorldMiddlewareExecuteAfterPublisher returns a PublisherMiddlewareFunc that executes after the publisher function.
5959
// It logs any error that occurs during publishing and logs a message indicating that the last middleware has been executed.
60-
func HelloWorldMiddlewareExecuteAfterPublisher() goqu.PublisherMiddlewareFunc {
61-
return func(next goqu.PublisherFunc) goqu.PublisherFunc {
62-
return func(ctx context.Context, m goqu.Message) (err error) {
60+
func HelloWorldMiddlewareExecuteAfterPublisher() goqueue.PublisherMiddlewareFunc {
61+
return func(next goqueue.PublisherFunc) goqueue.PublisherFunc {
62+
return func(ctx context.Context, m goqueue.Message) (err error) {
6363
err = next(ctx, m)
6464
if err != nil {
6565
logrus.Error("got error while publishing the message: ", err)
@@ -73,9 +73,9 @@ func HelloWorldMiddlewareExecuteAfterPublisher() goqu.PublisherMiddlewareFunc {
7373

7474
// HelloWorldMiddlewareExecuteBeforePublisher is a function that returns a PublisherMiddlewareFunc.
7575
// It wraps the provided PublisherFunc with a middleware that logs a message before executing the next function.
76-
func HelloWorldMiddlewareExecuteBeforePublisher() goqu.PublisherMiddlewareFunc {
77-
return func(next goqu.PublisherFunc) goqu.PublisherFunc {
78-
return func(ctx context.Context, e goqu.Message) (err error) {
76+
func HelloWorldMiddlewareExecuteBeforePublisher() goqueue.PublisherMiddlewareFunc {
77+
return func(next goqueue.PublisherFunc) goqueue.PublisherFunc {
78+
return func(ctx context.Context, e goqueue.Message) (err error) {
7979
logrus.Info("hello-world-first-middleware executed")
8080
return next(ctx, e)
8181
}

0 commit comments

Comments
 (0)