Streaming-Based Config is a helper library for accessing structured configurations based on event streaming/subscription.
To install the Streaming-Based-Config library, you can use go get
:
go get github.com/Autodoc-Technology/streaming-based-config
Here's a basic example of how to use the Streaming-Based-Config library:
sub := sbc.NewSubscriber[SimpleConfig](
sbctransport.NewDemoTransport([]byte(`{"value": 1, "value2": "hello"}`), 3*time.Second),
sbc.DefaultKeyBuilder[SimpleConfig](),
)
confSubs, err := sub.Subscribe(ctx)
if err != nil {
log.Fatalf("Failed to subscribe: %v", err)
}
defer confSubs.Unsubscribe()
// get the current value
config := confSubs.Get()
log.Printf("Get Config: %+v", config)
// subscribe to the values stream
for val := range confSubs.GetUpdates() {
log.Printf("Config: %+v", val)
}
For more detailed examples, please refer to the example
directory.
- Basic code structure
- Unit tests for most of the code
- Nats transport implementation
- Consul transport implementation
- Unit tests for Subscriber/Subscriptions (with mocks)
- Kafka transport implementation
We welcome contributions from the community. If you wish to contribute, please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a pull request
This project is Apache 2.0 licensed. For more information, please refer to the LICENSE
file.
Project Link: https://github.com/Autodoc-Technology/streaming-based-config