-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: hide unnecessary fns (#13)
- Loading branch information
Showing
30 changed files
with
513 additions
and
604 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package consumer | ||
|
||
import ( | ||
"github.com/bxcodec/goqueue/internal/consumer" | ||
"github.com/bxcodec/goqueue/internal/consumer/rabbitmq" | ||
"github.com/bxcodec/goqueue/options" | ||
consumerOpts "github.com/bxcodec/goqueue/options/consumer" | ||
) | ||
|
||
func NewConsumer(platform options.Platform, opts ...consumerOpts.ConsumerOptionFunc) consumer.Consumer { | ||
switch platform { | ||
case consumerOpts.ConsumerPlatformRabbitMQ: | ||
return rabbitmq.NewConsumer(opts...) | ||
case consumerOpts.ConsumerPlatformGooglePubSub: | ||
// TODO (bxcodec): implement google pubsub publisher | ||
case consumerOpts.ConsumerPlatformSQS: | ||
// TODO (bxcodec): implement sns publisher | ||
default: | ||
panic("unknown publisher platform") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package goqueue | ||
package interfaces | ||
|
||
type DelayFn func(retries int64) (delay int64) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package goqueue | ||
package interfaces | ||
|
||
import ( | ||
"time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package consumer | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bxcodec/goqueue/interfaces" | ||
) | ||
|
||
// Consumer represents an entity that consumes messages from a queue. | ||
// | ||
//go:generate mockery --name Consumer | ||
type Consumer interface { | ||
// Consume consumes messages from the queue and passes them to the provided handler. | ||
// It takes a context, an InboundMessageHandler, and a map of metadata as parameters. | ||
// It returns an error if there was a problem consuming the messages. | ||
Consume(ctx context.Context, handler interfaces.InboundMessageHandler, meta map[string]interface{}) (err error) | ||
|
||
// Stop stops the consumer from consuming messages. | ||
// It takes a context as a parameter and returns an error if there was a problem stopping the consumer. | ||
Stop(ctx context.Context) (err error) | ||
} |
Oops, something went wrong.