zdpgo_consul

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 4 Imported by: 0

README

zdpgo_consul

go使用consul作为注册中心

版本历史

  • v0.1.2 2022/07/23 新增:负载均衡

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, error)

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

func (*Consul) Client

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

Client 获取consul客户端

func (*Consul) DeRegisterGrpc added in v0.1.2

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

DeRegisterGrpc 从consul注销grpc服务

func (*Consul) DeRegisterHTTP added in v0.1.2

func (c *Consul) DeRegisterHTTP(config DeregisterHTTPConfig) error

DeRegisterHTTP 注销HTTP服务

func (*Consul) GetGrpcClientConn

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

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

func (*Consul) RegisterGrpc added in v0.1.2

func (c *Consul) RegisterGrpc(config ServiceConfig) error

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

func (*Consul) RegisterHTTP added in v0.1.2

func (c *Consul) RegisterHTTP(config WebConfig) error

RegisterHTTP 注册HTTP服务

type ConsulConfig

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

ConsulConfig consul配置对象

type DeregisterHTTPConfig added in v0.1.2

type DeregisterHTTPConfig struct {
	ConsulHost string // consul主机地址
	ConsulPort uint16 // consul端口号
	ServerId   string // 服务id
}

DeregisterHTTPConfig 注销http服务的配置

type ServiceConfig

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

ServiceConfig service服务配置对象

type WebConfig added in v0.1.2

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

WebConfig web服务配置对象

Directories

Path Synopsis
api
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.

Jump to

Keyboard shortcuts

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