Skip to content

Latest commit

 

History

History
116 lines (89 loc) · 3.68 KB

README.md

File metadata and controls

116 lines (89 loc) · 3.68 KB

project-logo

Protoconf GOLANG client

codify configuration, instant delivery

license last-commit


Table of Contents

📍 Overview

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.


🧩 Features

  • 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

⚙️ Installation

To install the package, use the following command:

go get github.com/protoconf/client-go

🤖 Usage

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()
}

🤝 Contributing

Contributions are welcome! Here are several ways you can contribute:

🎗 License

This project is protected under the MIT License.
For more details, refer to the LICENSE file.