server

package
Version: v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigInfo

type ConfigInfo struct {
	Routes []Route
}

ConfigInfo represents service configurator

type Option

type Option func(c *ServiceInfo)

Option 可选项

func WithAddress

func WithAddress(address string) Option

WithAddress 设置地址

func WithKind

func WithKind(kind constant.ServiceKind) Option

WithKind 设置类型

func WithMetaData

func WithMetaData(key, value string) Option

WithMetaData 设置metadata信息

func WithName added in v0.3.11

func WithName(name string) Option

WithName 定义服务名称

func WithScheme

func WithScheme(scheme string) Option

WithScheme 设置协议

type Route

type Route struct {
	// 权重组,按照
	WeightGroups []WeightGroup
	// 方法名
	Method string
}

Route ...

type Server

type Server interface {
	standard.Component
	GracefulStop(ctx context.Context) error
	Info() *ServiceInfo
}

Server ...

type Service

type Service struct {
	Namespace string            `json:"namespace" toml:"namespace"`
	Name      string            `json:"name" toml:"name"`
	Labels    map[string]string `json:"labels" toml:"labels"`
	Methods   []string          `json:"methods" toml:"methods"`
}

Service ...

type ServiceInfo

type ServiceInfo struct {
	Name       string               `json:"name"`
	Scheme     string               `json:"scheme"`
	Address    string               `json:"address"`
	Weight     float64              `json:"weight"`
	Enable     bool                 `json:"enable"`
	Healthy    bool                 `json:"healthy"`
	Metadata   map[string]string    `json:"metadata"`
	Region     string               `json:"region"`
	Zone       string               `json:"zone"`
	Kind       constant.ServiceKind `json:"kind"`
	Deployment string               `json:"deployment"` // Deployment 部署组: 不同组的流量隔离,  比如某些服务给内部调用和第三方调用,可以配置不同的deployment,进行流量隔离
	Group      string               `json:"group"`      // Group 流量组: 流量在Group之间进行负载均衡
	Services   map[string]*Service  `json:"services" toml:"services"`
}

ServiceInfo represents service info

func ApplyOptions

func ApplyOptions(options ...Option) ServiceInfo

ApplyOptions 设置可选项

func (ServiceInfo) Label

func (si ServiceInfo) Label() string

Label ...

type WeightGroup

type WeightGroup struct {
	Group  string
	Weight int
}

WeightGroup ...

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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