Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

trpc.group/trpc-go/trpc-config-etcd

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trpc.group/trpc-go/trpc-config-etcd

Go Modules
Version
v1.0.0
Version published
Created
Source

English | 中文

tRPC-Go etcd configuration plugin

Go Reference Go Report Card LICENSE Releases Docs Tests Coverage

The plugin encapsulates etcd-client, facilitating rapid access to configurations in etcd within the tRPC-Go framework.

Get started

Step 1

Anonymous import this package

import _ "trpc.group/trpc-go/trpc-config-etcd"

Step 2

In the trpc_go.yaml configuration file, set the Endpoint and Dialtimeout, for the complete configuration, refer to Config

plugins:                 
  config:
    etcd:
      endpoints:
        - localhost:2379
      dialtimeout: 5s

Step 3

After calling trpc.NewServer, retrieve the etcd configuration item.

func main() {
	trpc.NewServer()

    // Get the configuration item with the key "foo"
	value, err := config.GetString("foo")
	if err != nil {
		panic(err)
	}
	fmt.Println(value)

      // Watch changes to the configuration item with the key "foo"
	ch, err := config.Get("etcd").Watch(context.Background(), "foo")
	if err != nil {
		panic(err)
	}
	for rsp := range ch {
		fmt.Println(rsp.Value())
	}
}

Notes

The plugin currently only supports reading configurations, and the Get and Put functions are not yet implemented.

FAQs

Package last updated on 17 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts