gconfig_client

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

gconfig-client

基于gRPC协议,集群配置中心客户端程序

Install

go get github.com/ldongpo/gconfig-client

添加环境变量:

用于配置中心服务端微服务地址

export GO_GRPC_CONFIG_SERVER_HOST="127.0.0.1:9099"

服务端代码(暂未上传)

代码示例:
package main

import (
	"fmt"
	gConfig "github.com/ldongpo/gconfig-client"
)

func main() {
	var config gConfig.GRcpConfig
	config = gConfig.GRcpConfig{
		Env:       "test",  //环境
		Namespace: "semir", //命名空间
		Project:   "ts",    //项目
		Version:   "v1.0",  //版本
	}
	c, err := config.GetClient()
	if err != nil {
		fmt.Println(err)
		return
	}
	val := c.Get("redis.host")
	fmt.Println(val)
}

感谢:

viper

kitex

Documentation

Index

Constants

View Source
const (
	FN  = "application" //生成配置文件的名称
	Ext = "json"        //生成配置文件的后缀

	ServerHost = "GO_GRPC_CONFIG_SERVER_HOST"
)

Variables

View Source
var (
	I *info
)

Functions

This section is empty.

Types

type GRcpConfig

type GRcpConfig struct {
	Env       string //环境
	Namespace string //命名空间
	Project   string //项目
	Version   string //版本
	// contains filtered or unexported fields
}
var (
	C *GRcpConfig
)

func (*GRcpConfig) AllSettings

func (g *GRcpConfig) AllSettings() map[string]interface{}

func (*GRcpConfig) Get

func (g *GRcpConfig) Get(key string) interface{}

func (*GRcpConfig) GetBool

func (g *GRcpConfig) GetBool(key string) bool

func (*GRcpConfig) GetClient

func (g *GRcpConfig) GetClient() (*GRcpConfig, error)

func (*GRcpConfig) GetDuration

func (g *GRcpConfig) GetDuration(key string) time.Duration

func (*GRcpConfig) GetFloat64

func (g *GRcpConfig) GetFloat64(key string) float64

func (*GRcpConfig) GetInt

func (g *GRcpConfig) GetInt(key string) int

func (*GRcpConfig) GetInt32

func (g *GRcpConfig) GetInt32(key string) int32

func (*GRcpConfig) GetInt64

func (g *GRcpConfig) GetInt64(key string) int64

func (*GRcpConfig) GetIntSlice

func (g *GRcpConfig) GetIntSlice(key string) []int

func (*GRcpConfig) GetSizeInBytes

func (g *GRcpConfig) GetSizeInBytes(key string) uint

func (*GRcpConfig) GetString

func (g *GRcpConfig) GetString(key string) string

func (*GRcpConfig) GetStringMap

func (g *GRcpConfig) GetStringMap(key string) map[string]interface{}

func (*GRcpConfig) GetStringMapString

func (g *GRcpConfig) GetStringMapString(key string) map[string]string

func (*GRcpConfig) GetStringMapStringSlice

func (g *GRcpConfig) GetStringMapStringSlice(key string) map[string][]string

func (*GRcpConfig) GetStringSlice

func (g *GRcpConfig) GetStringSlice(key string) []string

func (*GRcpConfig) GetTime

func (g *GRcpConfig) GetTime(key string) time.Time

func (*GRcpConfig) GetUint

func (g *GRcpConfig) GetUint(key string) uint

func (*GRcpConfig) GetUint32

func (g *GRcpConfig) GetUint32(key string) uint32

func (*GRcpConfig) GetUint64

func (g *GRcpConfig) GetUint64(key string) uint64

Directories

Path Synopsis
kitex_gen
grpcConfig/grpcconfig
Code generated by Kitex v0.0.5.
Code generated by Kitex v0.0.5.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL