Protoconf GOLANG client
codify configuration, instant delivery
protoconf_loader
is a Go package that provides a flexible and robust configuration management solution.
It supports loading configuration from files, watching for file changes, and subscribing to configuration updates from a Protoconf server.
- Load configuration from files
- Watch configuration files for changes
- Subscribe to configuration updates from a Protoconf server
- Hot Reload of configuration changes
- Thread-safe access to configuration values
- Support for various data types (int32, int64, uint32, uint64, float32, float64, bool, string)
- Custom error handling and logging
To install the package, use the following command:
go get github.com/protoconf/client-go
Here's a basic example of how to use the protoconf_loader:
package main
import (
"context"
"log"
"github.com/protoconf/client-go/"
"github.com/protoconf/protoconf/examples/protoconf/src/crawler"
"google.golang.org/protobuf/proto"
)
func main() {
// Initialize the configuration with the default configuration.
crawlerConfig := &crawler.CrawlerService{LogLevel: 3}
// Create a new configuration instance
cfg, err := protoconf_loader.NewConfiguration(crawlerConfig, "path/to/config")
if err != nil {
log.Fatalf("Failed to create configuration: %v", err)
}
// Load the configuration
err = cfg.LoadConfig("path/to/config", "config_file_name")
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
config.OnConfigChange(func(c proto.Message) {
log("got new config",c)
})
// Start watching for changes
err = config.WatchConfig(context.Background())
if err != nil {
log.Fatalf("Failed to start watching configuration: %v", err)
}
// Stop watching when done
cfg.StopWatching()
}
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
client-go
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
This project is protected under the MIT License.
For more details, refer to the LICENSE file.