discoverconsul

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

实现文件 基于 consul 实现的服务发现

Index

Constants

View Source
const (

	// DiscoverTag 用于docker发现的tag, 所有希望被discover服务发现的节点,
	// 都应该在Dockerfile中设置 ENV SERVICE_TAGS=braid
	DiscoverTag = "braid"
)

Variables

View Source
var (
	// ErrConfigConvert 配置转换失败
	ErrConfigConvert = errors.New("convert config error")
)

Functions

func BuildWithOption

func BuildWithOption(info meta.ServiceInfo, log *blog.Logger, cli *bconsul.Client, ps module.IPubsub, opts ...Option) module.IDiscover

Types

type Option

type Option func(*Parm)

Option consul discover config wrapper

func WithBlacklist

func WithBlacklist(lst []string) Option

WithBlacklist add blacklist

func WithSyncServiceInterval

func WithSyncServiceInterval(interval time.Duration) Option

WithSyncServiceInterval 修改config中的interval

func WithSyncServiceWeightInterval

func WithSyncServiceWeightInterval(interval time.Duration) Option

WithSyncServiceWeightInterval 修改权重同步间隔

func WithTag

func WithTag(discoverTag string) Option

WithTag 修改config中的discover tag

type Parm

type Parm struct {

	// 同步节点信息间隔
	SyncServicesInterval time.Duration

	// 同步节点权重间隔
	SyncServiceWeightInterval time.Duration

	// 过滤标签
	Tag string

	// 黑名单列表,在黑名单的服务将不会被加入到 services 中
	Blacklist []string
}

Parm discover config

Jump to

Keyboard shortcuts

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