server

package
v0.0.0-...-796898b Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package server 路由、负载、监听外部服务包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Server

func Server(engine *gin.Engine)

Server 服务器管理服务路由

func ServiceGroup

func ServiceGroup() map[string]*Services

ServiceGroup 全局服务器群组

Types

type Service

type Service struct {
	ID     string `json:"id"`
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Health string `json:"health"`
}

Service 服务器信息

func NewService

func NewService(host string, port int) *Service

NewService 服务器对象新建

func (*Service) Equal

func (a *Service) Equal(host string, port int) bool

Equal 比较服务器是否相同

func (*Service) EqualService

func (a *Service) EqualService(service *Service) bool

EqualService 比较服务器是否相同

func (*Service) GetHost

func (a *Service) GetHost() string

GetHost 获取服务器信息地址

func (*Service) GetPort

func (a *Service) GetPort() int

GetPort 获取服务器信息端口号

type ServiceReq

type ServiceReq struct {
	Name    string  `json:"name"`
	Service Service `json:"service"`
}

ServiceReq 服务器新增请求对象

type Services

type Services struct {
	Services []*Service `json:"services"`
}

Services 服务器对象集合

func GetServices

func GetServices(serviceName string) *Services

GetServices 根据服务名称获取本地服务器列表,如果没有,则新建

func (*Services) Add

func (services *Services) Add(service Service)

Add Service 服务器对象集合内新增

func (*Services) Remove

func (services *Services) Remove(position int)

Remove Service 服务器对象集合内移除

Jump to

Keyboard shortcuts

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