Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lana/go-commandbus
Simple command bus for GO
https://github.com/lana/go-commandbus
Last synced: about 2 months ago
JSON representation
Simple command bus for GO
- Host: GitHub
- URL: https://github.com/lana/go-commandbus
- Owner: lana
- License: mit
- Created: 2019-10-03T20:08:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-26T15:20:42.000Z (almost 3 years ago)
- Last Synced: 2024-07-31T20:52:23.310Z (4 months ago)
- Language: Go
- Size: 21.5 KB
- Stars: 12
- Watchers: 23
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-commandbus - A slight and pluggable command-bus for Go. (Miscellaneous / Uncategorized)
- zero-alloc-awesome-go - go-commandbus - A slight and pluggable command-bus for Go. (Miscellaneous / Uncategorized)
- awesome-go-extra - go-commandbus - 10-03T20:08:22Z|2022-01-26T15:20:42Z| (Microsoft Office / Uncategorized)
README
# GO CommandBus
[![Build Status](https://img.shields.io/travis/lana/go-commandbus/master.svg?style=flat-square)](https://travis-ci.org/lana/go-commandbus)
[![Codecov branch](https://img.shields.io/codecov/c/github/lana/go-commandbus/master.svg?style=flat-square)](https://codecov.io/gh/lana/go-commandbus)
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/lana/go-commandbus)
[![Go Report Card](https://goreportcard.com/badge/github.com/lana/go-commandbus?style=flat-square)](https://goreportcard.com/report/github.com/lana/go-commandbus)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/lana/go-commandbus/blob/master/LICENSE)A slight and pluggable command-bus for Go.
## Install
Use go get.
```sh
$ go get github.com/lana/go-commandbus
```Then import the package into your own code:
```
import "github.com/lana/go-commandbus"
```## Usage
```go
package mainimport (
"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](https://github.com/lana/go-commandbus/blob/master/LICENSE) for more details.