go-commandbus
A slight and pluggable command-bus for Go
About go-commandbus
GO CommandBus
A slight and pluggable command-bus for Go.
Install
Use go get.
$ go get github.com/lana/go-commandbus
Then import the package into your own code:
import "github.com/lana/go-commandbus"
Usage
package main
import (
"context"
"log"
"github.com/lana/go-commandbus"
)
type CreateUser struct {
Name string
}
func CreateHandler(ctx context.Context, cmd *CreateUser) error {
log.Printf("user %s created", cmd.Name)
return nil
}
func main() {
bus := commandbus.New()
err := bus.Register(&CreateUser{}, CreateHandler)
if err != nil {
log.Error(err)
os.Exit(1)
}
err = bus.Execute(context.Background(), &CreateUser{"go-commandbus"})
if err != nil {
log.Error(err)
os.Exit(1)
}
}
License
This project is released under the MIT licence. See LICENSE for more details.
Frequently Asked Questions
What is go-commandbus?
go-commandbus is a Miscellaneous library for the Go programming language. A slight and pluggable command-bus for Go
How do I install go-commandbus?
Install go-commandbus with the Go module system using `go get lana/go-commandbus`. Check the repository for the current installation instructions.
What category does go-commandbus belong to?
go-commandbus is listed under Miscellaneous, specifically Uncategorized.