configer

package module
v0.0.0-...-4db9781 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 9 Imported by: 0

README

conf-starter

config starter

Documentation

Overview

包 configer 实现了读取nacos配置的封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientConfig constant.ClientConfig
	ServerConfig []constant.ServerConfig
}

用于连接nacos的client 的config信息

func (*Config) CreateNewConfigClient

func (c *Config) CreateNewConfigClient() config_client.IConfigClient

CreateNewConfigClient 创建用于查询配置的客户端

type Configer

type Configer struct {
	Viper        *viper.Viper
	ServerConfig NacosServerConfig
	ClientConfig NacosClientConfig
	Params       Params
}

包含了 viper.Viper 的结构体

func (*Configer) BindNacosClientParams

func (c *Configer) BindNacosClientParams() Config

func (*Configer) BindTargetParams

func (c *Configer) BindTargetParams() Params

func (*Configer) ReadParamsFromFile

func (c *Configer) ReadParamsFromFile(filePath string) error

从配置文件中获取连接nacos的配置信息

type FilePath

type FilePath struct {
	Type string
	Name string
	Path string
}

func ParseFilePath

func ParseFilePath(filepath string) FilePath

type NacosClientConfig

type NacosClientConfig struct {
	NamespaceId string
	TimeoutMs   string
	Username    string
	Password    string
}

type NacosServerConfig

type NacosServerConfig struct {
	IpAddr      string
	Port        string
	ContextPath string
	Scheme      string
}

type Params

type Params struct {
	DataID  string
	Group   string
	Content string
}

需要获取的nacos上的config

func (*Params) GetNacosConfig

func (p *Params) GetNacosConfig(configClient config_client.IConfigClient) (string, error)

GetNacosConfig 从Nacos中读取配置

func (*Params) PublishNacosConfig

func (p *Params) PublishNacosConfig(configClient config_client.IConfigClient) (bool, error)

PublishNacosConfig 从Nacos中读取配置

Directories

Path Synopsis
示例 演示了如何使用configer
示例 演示了如何使用configer

Jump to

Keyboard shortcuts

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