Extending Tork
Broker
The Broker
component is responsible for routing messages between the Coordinator and Worker nodes.
Types
There are two types of Broker
implementations that are supported out of the box with Tork:
- In-memory
- RabbitMQ
Registering a custom Broker
To register a custom Broker
implementation follow the instructions on the Extending Tork guide to get Tork running in embedded mode.
Update your main
function to make use of the engine.RegisterBrokerProvider
hook:
func main() {
if err := conf.LoadConfig(); err != nil {
fmt.Println(err)
os.Exit(1)
}
engine.RegisterBrokerProvider("mymq", func() (mq.Broker, error) {
// example of using config
// url := conf.String("broker.mymq.url")
return nil, errors.Errorf("not implementd yet")
})
if err := cli.New().Run(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Update your config file to make use of your implementation:
[broker]
type = mymq
[broker.mymq]
url = mydb://user@password:localhost