consul

package
v0.0.0-...-14be73a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeRegister

func DeRegister(c *gin.Context)

service deregister

func GetAllServices

func GetAllServices(c *gin.Context)

catalog all services

func GetHealthServiceByName

func GetHealthServiceByName(c *gin.Context)

/health/service/:name

func GetServiceByName

func GetServiceByName(c *gin.Context)

catalog services by serviceName

func Kv

func Kv(c *gin.Context)

func KvAll

func KvAll(c *gin.Context)

func Pass

func Pass(c *gin.Context)

check/pass/check_id

func Register

func Register(c *gin.Context)

service register

Types

type Addr

type Addr struct {
	Lan IpPort `json:"lan"`
	Wan IpPort `json:"wan"`
}

type CheckVo

type CheckVo struct {
	Name     string   `json:"name"`
	Args     []string `json:"args"`
	Interval string   `json:"interval"`
	Status   string   `json:"status"`
}

type HealthAddr

type HealthAddr struct {
	LanIpv4 IpPort `json:"lan_ipv4"`
	WanIpv4 IpPort `json:"wan_ipv4"`
}

type HealthServiceResp

type HealthServiceResp struct {
	Node    HealthServiceRespNode
	Service HealthServiceRespService
	Checks  []HealthServiceRespChecks
}

health service response

func GetHealthServiceResp

func GetHealthServiceResp(serviceName string) HealthServiceResp

init GetHealthServiceResponse by serviceName

type HealthServiceRespChecks

type HealthServiceRespChecks struct {
	Node    string
	CheckID string
	Name    string
	Status  string
}

type HealthServiceRespNode

type HealthServiceRespNode struct {
	ID              string
	Node            string
	Address         string
	Datacenter      string
	TaggedAddresses TaggedAddresses
}

type HealthServiceRespService

type HealthServiceRespService struct {
	ID              string
	Service         string
	Address         string
	TaggedAddresses HealthAddr
	Port            int
}

type IpPort

type IpPort struct {
	Address string `json:"address"`
	Port    int    `json:"port""`
}

type ServiceResp

type ServiceResp struct {
	ID                     string
	Node                   string
	Address                string
	Datacenter             string
	ServiceAddress         string
	ServiceID              string
	ServiceName            string
	ServicePort            int
	ServiceTaggedAddresses Addr
}

catalog service response json

type ServiceVo

type ServiceVo struct {
	Id      string  `json:"id" from:"id"`
	Name    string  `json:"name"`
	Port    int     `json:"port"`
	Address string  `json:"address"`
	Check   CheckVo `json:"check"`
}

*

{
  "id": "web1",
  "name": "web",
  "port": 80,
  "check": {
    "name": "ping check",
    "args": ["ping", "-c1", "learn.hashicorp.com"],
    "interval": "30s",
    "status": "passing"
  }
}

service register json

func GetServiceById

func GetServiceById(serviceId string) (ServiceVo, bool)

get service by id

func GetServices

func GetServices(name string) []ServiceVo

get service by name

type TaggedAddresses

type TaggedAddresses struct {
	Lan     string `json:"lan"`
	LanIpv4 string `json:"lan_ipv4"`
	Wan     string `json:"wan"`
	WanIpv4 string `json:"wan_ipv4"`
}

Jump to

Keyboard shortcuts

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