zdpgo_consul

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 5 Imported by: 0

README

zdpgo_consul

介绍

go操作consul

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consul

type Consul struct {
	// contains filtered or unexported fields
}

Consul consul核心对象

func New

func New(config ConsulConfig) *Consul

New 创建consul的实例 @param config consul配置对象

func (*Consul) Client

func (c *Consul) Client() *api.Client

Client 获取consul客户端

func (*Consul) DeRegister

func (c *Consul) DeRegister(id string) error

DeRegister 从consul注销grpc服务

func (*Consul) GetGrpcClientConn

func (c *Consul) GetGrpcClientConn(serviceName string) *grpc.ClientConn

GetGrpcClientConn 获取GRPC的客户端连接 @param serviceName,consul中的grpc服务名称

func (*Consul) Register

func (c *Consul) Register(config ServiceConfig)

Register 注册Grpc微服务到consul @param host 地址 @param port 端口号 @param name 名称 @param id ID @param tags 标签列表 @param isGrpc 是否为grpc

type ConsulConfig

type ConsulConfig struct {
	Debug       bool   // 是否为debug模式
	LogFilePath string // 日志存放路径
	Host        string // consul地址
	Port        uint16 // consul端口号
}

ConsulConfig consul配置对象

type ServiceConfig

type ServiceConfig struct {
	Host string   // 地址
	Port uint16   // 端口号
	Name string   // 名称
	Id   string   // ID
	Tags []string // 标签列表
}

ServiceConfig service服务配置对象

Directories

Path Synopsis
backoff
Package backoff provides an exponential-backoff implementation.
Package backoff provides an exponential-backoff implementation.
internal/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
tests
Package tests is used for integration tests
Package tests is used for integration tests

Jump to

Keyboard shortcuts

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