Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nepet/eventbus
A simplistic event bus for golang
https://github.com/nepet/eventbus
event eventbus golang pubsub
Last synced: about 1 month ago
JSON representation
A simplistic event bus for golang
- Host: GitHub
- URL: https://github.com/nepet/eventbus
- Owner: nepet
- License: mit
- Created: 2020-10-03T17:05:58.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-03T17:58:27.000Z (about 4 years ago)
- Last Synced: 2024-06-20T16:49:39.023Z (6 months ago)
- Topics: event, eventbus, golang, pubsub
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Eventbus
[![Test Coverage](https://codecov.io/gh/nepet/eventbus/master/graph/badge.svg)](https://codecov.io/gh/nepet/eventbus)
#### A simple Implementation of an event bus in golangThis repository is an implementation of the publisher/subscriber pattern in golang. It is meant to be as simple as
possible to cover as many cases as possible.## Install
```
go get github.com/nepet/eventbus
```### Event
```
type Event interface {
IsEvent()
}
```An event is something that gets published. The interface only requires for a `IsEvent()` method that should do nothing
and just ensures that a struct is meant to be an event. Any struct can implement this method to be used as an event.### Handler
```
type Handler interface {
Handle(interface{Event})
}
```A handler handles an event without a return value. It is up to the developer how the
`Handle(interface{Event})` method is used.### Mock
The repository also contains a handler mock and a mock for the event bus. This allows you to easily use the bus in unit
tests.### Examples
The examples provide an exemplary implementation of a handler and an event.