Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/banyc/simple-messaging
Brokerless messaging. Pub/Sub. Producer/Consumer. Best effort. Pure Go. No C. No CGO. NO libwhatsoever.
https://github.com/banyc/simple-messaging
best-effort brokerless messaging producer-consumer pubsub
Last synced: about 1 month ago
JSON representation
Brokerless messaging. Pub/Sub. Producer/Consumer. Best effort. Pure Go. No C. No CGO. NO libwhatsoever.
- Host: GitHub
- URL: https://github.com/banyc/simple-messaging
- Owner: Banyc
- Created: 2021-12-30T14:42:08.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-04T02:28:11.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T05:38:44.140Z (6 months ago)
- Topics: best-effort, brokerless, messaging, producer-consumer, pubsub
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Messaging
Simple messaging for pub/sub and producer/consumer. Pure Go!
# Usage
## Request-Response
Producer:
```go
consumerAddr, err := net.ResolveTCPAddr("tcp", "localhost:8080")
if err != nil {
panic(err)
}
producer := messaging.NewProducer(consumerAddr)
producer.Start()
defer producer.Close()producer.EnsureSent([]byte("Hello World!"))
```Consumer:
```go
consumerListenAddr, err := net.ResolveTCPAddr("tcp", ":8080")
if err != nil {
panic(err)
}
consumer := messaging.NewConsumer(consumerListenAddr, 1024)
consumer.Start()
defer consumer.Close()message := consumer.Receive()
```## Pub-Sub
Subscriber:
```go
pubAddr, err := net.ResolveTCPAddr("tcp", "localhost:8080")
if err != nil {
panic(err)
}
sub := messaging.NewSubscriber(pubAddr, 1024)
sub.Start()
defer sub.Close()message := sub.EnsureReceived()
```Publisher:
```go
pubListenAddr, err := net.ResolveTCPAddr("tcp", ":8080")
if err != nil {
panic(err)
}
pub := messaging.NewPublisher(pubListenAddr)
pub.Start()
defer pub.Close()pub.Send([]byte("Hello World!"))
```# TODO
- [ ] Receivers confirm receipt of messages via reply
- make sure every message is delivered at least once