register

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// API 提供API访问的服务
	API = ServiceType("api")
	// Worker 后台作业服务
	Worker = ServiceType("worker")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HeatbeatResonse

type HeatbeatResonse interface {
	TTL() int64
}

HeatbeatResonse 心态的返回

type Register

type Register interface {
	Registe(service *ServiceInstance) (<-chan HeatbeatResonse, error)
	UnRegiste() error
}

Register 服务注册接口

type ServiceInstance

type ServiceInstance struct {
	Region       string      `json:"region,omitempty"`
	InstanceName string      `json:"instanceName,omitempty"`
	ServiceName  string      `json:"serviceName,omitempty"`
	Type         ServiceType `json:"serviceType,omitempty"`
	Address      string      `json:"address,omitempty"`
	Version      string      `json:"version,omitempty"`
	GitBranch    string      `json:"gitBranch,omitempty"`
	GitCommit    string      `json:"gitCommit,omitempty"`
	BuildEnv     string      `json:"buildEnv,omitempty"`
	BuildAt      string      `json:"buildAt,omitempty"`
	Online       int64       `json:"online,omitempty"` // 毫秒时间戳

	Meta map[string]interface{} `json:"meta,omitempty"`

	Prefix   string        `json:"-"`
	Interval time.Duration `json:"-"`
	TTL      int64         `json:"-"`
}

ServiceInstance todo

func (*ServiceInstance) MakeRegistryKey

func (s *ServiceInstance) MakeRegistryKey() string

MakeRegistryKey 构建etcd对应的key

func (*ServiceInstance) Name

func (s *ServiceInstance) Name() string

Name 实例显示名称

func (*ServiceInstance) Validate

func (s *ServiceInstance) Validate() error

Validate 服务实例注册参数校验

type ServiceType

type ServiceType string

ServiceType 服务类型

func ParseInstanceKey

func ParseInstanceKey(key string) (serviceName, region, instanceName string, serviceType ServiceType, err error)

ParseInstanceKey 解析key中的服务信息

Jump to

Keyboard shortcuts

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