Skip to content

Conversation

@mcuadros
Copy link
Contributor

@mcuadros mcuadros commented May 8, 2018

This PR changes the implementation of the different queue to a pattern where allows extensibility without modification of the code. Allowing to register different implementation following the database pattern for the standard library

This is an example of the new usage, where the implementation should be imported:

import ( "fmt" "log" "gopkg.in/src-d/go-queue.v0"	_ "gopkg.in/src-d/go-queue.v0/memory" ) func main() { b, err := queue.NewBroker("memory://") if err != nil { log.Fatal(err)	}
mcuadros added 2 commits May 8, 2018 19:16
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
@mcuadros mcuadros requested review from ajnavarro and smola May 8, 2018 17:33
Copy link
Contributor

@smola smola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a couple of comments.

register.go Outdated
type BrokerBuilder func(uri string) (Broker, error)

// Register registers a new BrokerBuilder to be used by NewBroker, this function
// should be used in an init function in the implementation packages sush as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sush/such/

memory/memory.go Outdated
func NewMemoryBroker() Broker {
return &memoryBroker{make(map[string]Queue)}
// NewMemoryBroker creates a new Broker for an in-memory queue.
func NewMemoryBroker() queue.Broker {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it is on its own package, we might want to call this just NewBroker or New. Same with the AMQP one.

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
@mcuadros mcuadros merged commit a5c2f0b into src-d:master May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants