serviceCenter

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Micro Service Discovery Author: Vincent Young Version: v1.0.0

Based: Etcd EtcdKeyRule: /{Prefix}/{SupportService}/{ServiceAddr}

Support: 1. Load Balance Strategy: polling、random 2. Auto find the normal node 3. Multi services 4. Service cluster 5. Optional etcd prefix

TODO: 1. Discover center cluster 2. Etcd value more service info (v1.0.0: Only addr string) 3. Optional service (v1.0.0: Need to hard code in discovery file) 4. Optimize error output 5. Add get all services method, so can implement load balance out of discovery (v1.0.0: Load balance in discovery)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunDiscovery

func RunDiscovery(host string, port int, prefix string, lb SupportLoadBalance)

func RunRegister

func RunRegister(host string, port int, prefix string, service SupportService, serviceAddr string)

Types

type Discovery

type Discovery struct {
	// contains filtered or unexported fields
}
var D *Discovery

func (*Discovery) GetService

func (d *Discovery) GetService(s SupportService) (addr string)

func (*Discovery) SetLoadBalance

func (d *Discovery) SetLoadBalance(lb SupportLoadBalance)

func (*Discovery) UpdateServiceStatus

func (d *Discovery) UpdateServiceStatus(s SupportService, addr string, status ServiceStatus)

type Service

type Service struct {
	Name   SupportService
	Addr   string
	Status ServiceStatus
}

type ServiceMap

type ServiceMap map[SupportService][]*Service

type ServiceStatus

type ServiceStatus int
const (
	ServiceStatusNormal  ServiceStatus = 1
	ServiceStatusFailure ServiceStatus = 0
)

type SupportLoadBalance

type SupportLoadBalance int
const (
	SupportLoadBalancePolling SupportLoadBalance = iota
	SupportLoadBalanceRandom
)

type SupportService

type SupportService string
const (
	SupportServiceGood    SupportService = "good"
	SupportServiceAddress SupportService = "address"
)

Jump to

Keyboard shortcuts

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