nacos

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

*

  • @Time : 2020/12/17 2:25 下午
  • @Author : MassAdobe
  • @Description: nacos

*

*

  • @Time : 2020/12/17 2:25 下午
  • @Author : MassAdobe
  • @Description: nacos

*

*

  • @Time : 2020/12/17 4:24 下午
  • @Author : MassAdobe
  • @Description: nacos

*

*

  • @Time : 2020/12/17 4:25 下午
  • @Author : MassAdobe
  • @Description: nacos

*

Index

Constants

This section is empty.

Variables

View Source
var (
	NacosContent    string                       // nacos配置中心配置内容
	NacosRegistPojo map[int]interface{}          // nacos注册的自主配置结构体
	RateMap         map[string]ratelimit.Limiter // 限流Map
	PastRateMap     map[string]int               // 历史限流Map
)

Functions

func InitNacos

func InitNacos()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 2:51 下午
  • @Description: 初始化nacos配置

*

func InitNacosProfile

func InitNacosProfile()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 4:24 下午
  • @Description: 处理首次nacos获取到的配置信息

*

func InitRateProfile added in v1.3.4

func InitRateProfile()

*

  • @Author: MassAdobe
  • @TIME: 2021/1/8 11:47 上午
  • @Description: 初始化限流配置

*

func InsertSelfProfile added in v1.2.0

func InsertSelfProfile(st interface{})

*

  • @Author: MassAdobe
  • @TIME: 2020/12/28 4:07 下午
  • @Description: 插入自定义结构

*

func ListenConfiguration added in v1.1.0

func ListenConfiguration()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/21 2:58 下午
  • @Description: 监听配置文件变化

*

func NacosConfiguration

func NacosConfiguration()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 2:50 下午
  • @Description: nacos配置中心

*

func NacosDeregister

func NacosDeregister()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 4:57 下午
  • @Description: nacos注销服务

*

func NacosDiscovery

func NacosDiscovery()

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 3:16 下午
  • @Description: nacos服务注册发现

*

func NacosGetServer

func NacosGetServer(serviceName, groupName string) (instance *model.Instance, err error)

*

  • @Author: MassAdobe
  • @TIME: 2020/12/18 2:32 下午
  • @Description: 获取服务调用参数

*

func ReadNacosSelfProfile added in v1.1.0

func ReadNacosSelfProfile(content string, pojo interface{})

*

  • @Author: MassAdobe
  • @TIME: 2020/12/21 3:39 下午
  • @Description: 返回配置文件自定义内容

*

func ReadRateProfile added in v1.3.4

func ReadRateProfile(profile *InitNacosConfiguration)

*

  • @Author: MassAdobe
  • @TIME: 2021/1/8 11:51 上午
  • @Description: 读取限流配置

*

func RequestPath

func RequestPath(path string) string

*

  • @Author: MassAdobe
  • @TIME: 2020/12/18 11:39 上午
  • @Description: 拼装请求主地址

*

Types

type InitNacosConfiguration

type InitNacosConfiguration struct {
	Serve struct {
		Port       uint64  `yaml:"port"`        // 服务端口号
		ServerName string  `yaml:"server-name"` // 服务名
		Weight     float64 `yaml:"weight"`      // nacos中权重
	} `yaml:"serve"`

	Log struct {
		Path  string `yaml:"path"`  // 日志地址
		Level string `yaml:"level"` // 日志级别
	} `yaml:"log"`

	Gorm struct {
		Read struct {
			Username string `yaml:"username"` // 数据库用户名
			PassWord string `yaml:"password"` // 数据库密码
			Ip       string `yaml:"ip"`       // 数据库IP
			Port     int    `yaml:"port"`     // 数据库端口
			Dbname   string `yaml:"dbname"`   // 数据库名称
		} `yaml:"read"`
		Write struct {
			Username string `yaml:"username"` // 数据库用户名
			PassWord string `yaml:"password"` // 数据库密码
			Ip       string `yaml:"ip"`       // 数据库IP
			Port     int    `yaml:"port"`     // 数据库端口
			Dbname   string `yaml:"dbname"`   // 数据库名称
		} `yaml:"write"`
	} `yaml:"gorm"`

	Feign struct {
		RetryNum int `yaml:"retry-num"` // 内部调用重试次数
	} `yaml:"feign"`

	Redis struct {
		MaxIdle        int    `yaml:"max-idle"`        // 最大挂起数
		MaxActive      int    `yaml:"max-active"`      // 最大活跃数
		IdleTimeout    int    `yaml:"idle-timeout"`    // 最大挂起时间(秒)
		IpPort         string `yaml:"ip-port"`         // redis的IP和端口
		PassWord       string `yaml:"password"`        // 密码口令
		Database       int    `yaml:"database"`        // 数据库号:0-15
		ConnectTimeout int    `yaml:"connect-timeout"` // 连接超时时间(秒)
		ReadTimeout    int    `yaml:"read-timeout"`    // 读超时时间(秒)
		WriteTimeout   int    `yaml:"write-timeout"`   // 写超时时间(秒)
	} `yaml:"redis"`

	Rate struct {
		All              bool           `yaml:"all"`                // 是否是全局
		Rate             int            `yaml:"rate"`               // 限流数量
		InterfaceAndRate map[string]int `yaml:"interface-and-rate"` // 限流接口以及限流数
	} `yaml:"rate"`

	AccessToken struct {
		Verify string `yaml:"verify"` // 校验字段
	} `yaml:"access-token"` // 用户携带token
}

*

  • @Author: MassAdobe
  • @TIME: 2020/12/17 4:26 下午
  • @Description: nacos配置文件配置

*

var (
	InitConfiguration InitNacosConfiguration // 初始化配置
)

func ReadNacosProfile added in v1.1.0

func ReadNacosProfile(content string) *InitNacosConfiguration

*

  • @Author: MassAdobe
  • @TIME: 2020/12/21 3:05 下午
  • @Description: 返回配置文件内容

*

Jump to

Keyboard shortcuts

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