Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomwright/deliver
Publish and subscribe to messages using standard interfaces.
https://github.com/tomwright/deliver
consumer consumers kafka message-queue publish publish-subscribe publisher publishing subscribe
Last synced: 11 days ago
JSON representation
Publish and subscribe to messages using standard interfaces.
- Host: GitHub
- URL: https://github.com/tomwright/deliver
- Owner: TomWright
- License: mit
- Created: 2019-07-02T14:05:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-05T21:01:59.000Z (over 5 years ago)
- Last Synced: 2024-10-25T21:56:36.064Z (about 2 months ago)
- Topics: consumer, consumers, kafka, message-queue, publish, publish-subscribe, publisher, publishing, subscribe
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/TomWright/deliver.svg?branch=master)](https://travis-ci.org/TomWright/deliver)
[![codecov](https://codecov.io/gh/TomWright/deliver/branch/master/graph/badge.svg)](https://codecov.io/gh/TomWright/deliver)
[![Documentation](https://godoc.org/github.com/TomWright/deliver?status.svg)](https://godoc.org/github.com/TomWright/deliver)# deliver
```
go get -u github.com/tomwright/deliver
```Publish + consume messages with standard interfaces.
# Quick Start
This quick start assumes you already have your `Subscriber` or `Producer` created already.
For information on creating those objects, [see Implementations below](#implementations).
## Message
Below is an example message that may be published when a user has been created.
```
type UserCreated struct {
Username string `json:"username"`
}func (m *UserCreated) Type() string {
return "user.created"
}func (m *UserCreated) Payload() ([]byte, error) {
return json.Marshal(m)
}func (m *UserCreated) WithPayload(bytes []byte) error {
return json.Unmarshal(bytes, m)
}
```## Publishing
- [Example Kafka Publisher](/examples/kafka_publisher)
## Subscribing
- [Example Kafka Subscriber](/examples/kafka_subscriber)
# Implementations
## Kafka
- `Message.Type()` response is used as the topic.
- Messages are marked before the given `ConsumerFn` is executed.Setup:
```
brokers := []string{"cmg-local-kafka:9092"}
publisher, err := deliver.NewKafkaPublisher(brokers)
subscriber := deliver.NewKafkaSubscriber(brokers)
```