https://github.com/devwithzain/thebroadcaststore
https://github.com/devwithzain/thebroadcaststore
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devwithzain/thebroadcaststore
- Owner: devwithzain
- Created: 2024-07-31T19:25:50.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T20:44:27.000Z (over 1 year ago)
- Last Synced: 2025-01-12T01:44:40.014Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://thebroadcaststore.vercel.app
- Size: 52.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BroadcastStore
A distributed broadcast message store implementation for handling pub/sub
messaging patterns.
## Features
- Distributed message broadcasting
- Persistent message storage
- Publisher/Subscriber pattern support
- Message deduplication
- Fault tolerance and high availability
- Horizontal scaling capabilities
## Installation
```bash
go get github.com/yourusername/broadcaststore
```
## Quick Start
```go
import "github.com/yourusername/broadcaststore"
// Create a new broadcast store
store := broadcaststore.New(broadcaststore.Config{
StoragePath: "/tmp/broadcast-store",
})
// Start the store
if err := store.Start(); err != nil {
panic(err)
}
// Publish a message
store.Publish("channel-1", []byte("Hello World"))
// Subscribe to messages
sub := store.Subscribe("channel-1")
for msg := range sub.Messages() {
fmt.Printf("Received: %s\n", string(msg.Data))
}
```
## Configuration
| Option | Description | Default |
| --------------- | ----------------------------- | -------------------- |
| StoragePath | Path to store persistent data | /tmp/broadcast-store |
| MaxMessageSize | Maximum message size in bytes | 1MB |
| RetentionPeriod | How long to retain messages | 24h |
## API Reference
### Store Operations
- `New(config Config) *Store` - Create a new broadcast store
- `Start() error` - Start the store
- `Stop() error` - Stop the store
- `Publish(channel string, data []byte) error` - Publish a message
- `Subscribe(channel string) *Subscription` - Subscribe to a channel
### Subscription Operations
- `Messages() <-chan Message` - Get message channel
- `Close() error` - Close subscription
- `Unsubscribe()` - Unsubscribe from channel
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
for details.