service

package
v1.13.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 41 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// Master is
	Master = "master"
	// Service is
	Service = "service"
	// Namespace namespace string
	Namespace = "namespace"
	// ID id
	ID = "id"
	// Version version
	Version = "version"
)
View Source
const (
	// MaxBatchSize max batch size
	MaxBatchSize = 100
	// MaxQuerySize max query size
	MaxQuerySize = 100
)
View Source
const (
	// SystemNamespace polaris system namespace
	SystemNamespace = "Polaris"
	// DefaultNamespace default namespace
	DefaultNamespace = "default"
	// ProductionNamespace default namespace
	ProductionNamespace = "Production"
	// DefaultTLL default ttl
	DefaultTLL = 5
)
View Source
const (
	// QueryDefaultOffset default query offset
	QueryDefaultOffset = 0
	// QueryDefaultLimit default query limit
	QueryDefaultLimit = 100
	// QueryMaxLimit default query max
	QueryMaxLimit = 100

	// MaxMetadataLength metadata max length
	MaxMetadataLength = 64

	MaxBusinessLength   = 64
	MaxOwnersLength     = 1024
	MaxDepartmentLength = 1024
	MaxCommentLength    = 1024

	// service表
	MaxDbServiceNameLength      = 128
	MaxDbServiceNamespaceLength = 64
	MaxDbServicePortsLength     = 8192
	MaxDbServiceBusinessLength  = 128
	MaxDbServiceDeptLength      = 1024
	MaxDbServiceCMDBLength      = 1024
	MaxDbServiceCommentLength   = 1024
	MaxDbServiceOwnerLength     = 1024
	MaxDbServiceToken           = 2048

	// instance表
	MaxDbInsHostLength     = 128
	MaxDbInsProtocolLength = 32
	MaxDbInsVersionLength  = 32
	MaxDbInsLogicSetLength = 128

	// circuitbreaker表
	MaxDbCircuitbreakerName       = 128
	MaxDbCircuitbreakerNamespace  = 64
	MaxDbCircuitbreakerBusiness   = 64
	MaxDbCircuitbreakerDepartment = 1024
	MaxDbCircuitbreakerComment    = 1024
	MaxDbCircuitbreakerOwner      = 1024
	MaxDbCircuitbreakerVersion    = 32

	// platform表
	MaxPlatformIDLength     = 32
	MaxPlatformNameLength   = 128
	MaxPlatformDomainLength = 1024
	MaxPlatformQPS          = 65535

	// ratelimit表
	MaxDbRateLimitName = 64

	// MaxDbRoutingName routing_config_v2 表
	MaxDbRoutingName = 64
)

some options config

View Source
const (
	MetadataInternalAutoCreated string = "internal-auto-created"
)

Variables

View Source
var (
	// MasterCircuitBreakers master circuit breakers
	MasterCircuitBreakers = map[string]bool{
		"id":         true,
		"namespace":  true,
		"name":       true,
		"owner":      true,
		"business":   true,
		"department": true,
		"offset":     true,
		"limit":      true,
	}

	// ReleaseCircuitBreakers release circuit breakers
	ReleaseCircuitBreakers = map[string]bool{
		"id":      true,
		"version": true,
		"offset":  true,
		"limit":   true,
	}

	// ServiceParams service params
	ServiceParams = map[string]bool{
		Service:   true,
		Namespace: true,
	}
)
View Source
var (
	// InstanceFilterAttributes 查询实例支持的过滤字段
	InstanceFilterAttributes = map[string]bool{
		"service":       true,
		"namespace":     true,
		"host":          true,
		"port":          true,
		"keys":          true,
		"values":        true,
		"protocol":      true,
		"version":       true,
		"health_status": true,
		"healthy":       true,
		"isolate":       true,
		"weight":        true,
		"logic_set":     true,
		"cmdb_region":   true,
		"cmdb_zone":     true,
		"cmdb_idc":      true,
		"priority":      true,
		"offset":        true,
		"limit":         true,
	}
	// InsFilter2toreAttr 查询字段转为存储层的属性值,映射表
	InsFilter2toreAttr = map[string]string{
		"service": "name",
		"healthy": "health_status",
	}
	// NotInsFilterAttr 不属于 instance 表属性的字段
	NotInsFilterAttr = map[string]bool{
		"keys":   true,
		"values": true,
	}
)
View Source
var (
	// Namespace2SidLayoutID namespace to sid layout id
	Namespace2SidLayoutID = map[string]uint32{
		"Production":  1,
		"Development": 2,
		"Pre-release": 3,
		"Test":        4,
		"Polaris":     5,
		"default":     6,
	}

	// SidLayoutID2Namespace sid layout id to namespace
	SidLayoutID2Namespace = map[uint32]string{
		1: "Production",
		2: "Development",
		3: "Pre-release",
		4: "Test",
		5: "Polaris",
		6: "default",
	}
)
View Source
var (
	// AliasFilterAttributes filer attrs alias
	AliasFilterAttributes = map[string]bool{
		"alias":           true,
		"alias_namespace": true,
		"namespace":       true,
		"service":         true,
		"owner":           true,
		"offset":          true,
		"limit":           true,
	}
)
View Source
var (
	// RateLimitFilters rate limit filters
	RateLimitFilters = map[string]bool{
		"id":        true,
		"name":      true,
		"service":   true,
		"namespace": true,
		"brief":     true,
		"method":    true,
		"labels":    true,
		"disable":   true,
		"offset":    true,
		"limit":     true,
	}
)
View Source
var (
	// RoutingConfigFilterAttrs router config filter attrs
	RoutingConfigFilterAttrs = map[string]bool{
		"service":   true,
		"namespace": true,
		"offset":    true,
		"limit":     true,
	}
)
View Source
var (
	// RoutingConfigV2FilterAttrs router config filter attrs
	RoutingConfigV2FilterAttrs = map[string]bool{
		"id":                    true,
		"name":                  true,
		"service":               true,
		"namespace":             true,
		"source_service":        true,
		"destination_service":   true,
		"source_namespace":      true,
		"destination_namespace": true,
		"enable":                true,
		"offset":                true,
		"limit":                 true,
		"order_field":           true,
		"order_type":            true,
	}
)
View Source
var (
	ServiceFilterAttributes = map[string]int{
		"name":        serviceFilter,
		"namespace":   serviceFilter,
		"business":    serviceFilter,
		"department":  serviceFilter,
		"cmdb_mod1":   serviceFilter,
		"cmdb_mod2":   serviceFilter,
		"cmdb_mod3":   serviceFilter,
		"owner":       serviceFilter,
		"offset":      serviceFilter,
		"limit":       serviceFilter,
		"platform_id": serviceFilter,
		"host":        instanceFilter,
		"port":        instanceFilter,
		"keys":        serviceMetaFilter,
		"values":      serviceMetaFilter,
	}
)

Functions

func CalculateInstanceID

func CalculateInstanceID(namespace string, service string, vpcID string, host string, port uint32) (string, error)

CalculateInstanceID 计算实例ID Deprecated: use common/utils.CalculateInstanceID instead

func CalculateRuleID

func CalculateRuleID(name, namespace string) string

CalculateRuleID 计算规则ID Deprecated: use common/utils.CalculateRuleID instead

func CheckDbCircuitBreakerFieldLen

func CheckDbCircuitBreakerFieldLen(req *api.CircuitBreaker) (*api.Response, bool)

CheckDbCircuitBreakerFieldLen 检查DB中circuitBreaker表对应的入参字段合法性

func CheckDbInstanceFieldLen

func CheckDbInstanceFieldLen(req *api.Instance) (*api.Response, bool)

CheckDbInstanceFieldLen 检查DB中service表对应的入参字段合法性

func CheckDbMetaDataFieldLen

func CheckDbMetaDataFieldLen(metaData map[string]string) error

CheckDbMetaDataFieldLen 检查metadata的K,V是否超过DB中对应字段的最大字符长度限制 Deprecated: use common/utils.CheckDbMetaDataFieldLen instead

func CheckDbServiceAliasFieldLen

func CheckDbServiceAliasFieldLen(req *api.ServiceAlias) (*api.Response, bool)

CheckDbServiceAliasFieldLen 检查DB中service表对应的入参字段合法性

func CheckDbServiceFieldLen

func CheckDbServiceFieldLen(req *api.Service) (*api.Response, bool)

CheckDbServiceFieldLen 检查DB中service表对应的入参字段合法性

func CheckDbStrFieldLen

func CheckDbStrFieldLen(param *wrappers.StringValue, dbLen int) error

CheckDbStrFieldLen 检查name字段是否超过DB中对应字段的最大字符长度限制 Deprecated: use common/utils.CheckDbStrFieldLen instead

func ComputeNamespace

func ComputeNamespace(modID uint32, cmdID uint32) []string

ComputeNamespace 根据SID分析,返回其对应的namespace

func CreateCl5SidList

func CreateCl5SidList(sidConfigs []*model.SidConfig) *l5.Cl5SidList

CreateCl5SidList 构造sidConfigs

func Initialize

func Initialize(ctx context.Context, namingOpt *Config, opts ...InitOption) error

Initialize 初始化

func ParseIPInt2Str

func ParseIPInt2Str(ip uint32) string

ParseIPInt2Str uint32的IP转换为字符串型

func ParseIPStr2Int

func ParseIPStr2Int(ip string) (uint32, error)

ParseIPStr2Int 字符串IP转为uint32 转换失败的,需要明确错误

func ParseIPStr2IntV2

func ParseIPStr2IntV2(ip string) uint32

ParseIPStr2IntV2 字符串IP转为Int,V2

func ParseInstanceArgs

func ParseInstanceArgs(query map[string]string) (*store.InstanceArgs, error)

ParseInstanceArgs 解析服务实例的 ip 和 port 查询参数 Deprecated: use common/utils.ParseInstanceArgs instead

func ParseOffsetAndLimit

func ParseOffsetAndLimit(query map[string]string) (uint32, uint32, error)

ParseOffsetAndLimit 统一格式化处理Offset和limit参数 Deprecated: use common/utils.ParseOffsetAndLimit instead

func ParseOperator

func ParseOperator(ctx context.Context) string

ParseOperator 从ctx中获取operator Deprecated: use common/utils.ParseOperator instead

func ParsePlatformID

func ParsePlatformID(ctx context.Context) string

ParsePlatformID 从ctx中获取Platform-Id Deprecated: use common/utils.ParsePlatformID instead

func ParsePlatformToken

func ParsePlatformToken(ctx context.Context) string

ParsePlatformToken 从ctx中获取Platform-Token Deprecated: use common/utils.ParsePlatformToken instead

func ParseQueryLimit

func ParseQueryLimit(limit string) (uint32, error)

ParseQueryLimit 格式化处理limit参数 Deprecated: use common/utils.ParseQueryLimit instead

func ParseQueryOffset

func ParseQueryOffset(offset string) (uint32, error)

ParseQueryOffset 格式化处理offset参数 Deprecated: use common/utils.ParseQueryOffset instead

func ParseRequestID

func ParseRequestID(ctx context.Context) string

ParseRequestID 从ctx中获取Request-ID Deprecated: use common/utils.ParseRequestID instead

func ParseSetID

func ParseSetID(str string) []string

ParseSetID 解析metadata保存的setID字符串

func ParseToken

func ParseToken(ctx context.Context) string

ParseToken 从ctx中获取token Deprecated: use common/utils.ParseToken instead

func ParseWeight

func ParseWeight(str string) []uint32

ParseWeight 解析metadata保存的weight字符串

func ZapInstanceID

func ZapInstanceID(id string) zap.Field

ZapInstanceID 生成instanceID的日志描述 Deprecated: use common/utils.ZapInstanceID instead

func ZapPlatformID

func ZapPlatformID(id string) zap.Field

ZapPlatformID 生成Platform-ID的日志描述 Deprecated: use common/utils.ZapPlatformID instead

func ZapRequestID

func ZapRequestID(id string) zap.Field

ZapRequestID 生成Request-ID的日志描述 Deprecated: use common/utils.ZapRequestID instead

Types

type CircuitBreakerOperateServer

type CircuitBreakerOperateServer interface {

	// CreateCircuitBreakers Create a CircuitBreaker rule
	CreateCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

	// CreateCircuitBreakerVersions Create a melt rule version
	CreateCircuitBreakerVersions(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

	// DeleteCircuitBreakers Delete CircuitBreaker rules
	DeleteCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

	// UpdateCircuitBreakers Modify the CircuitBreaker rule
	UpdateCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

	// ReleaseCircuitBreakers Release CircuitBreaker rule
	ReleaseCircuitBreakers(ctx context.Context, req []*api.ConfigRelease) *api.BatchWriteResponse

	// UnBindCircuitBreakers Solution CircuitBreaker rule
	UnBindCircuitBreakers(ctx context.Context, req []*api.ConfigRelease) *api.BatchWriteResponse

	// GetCircuitBreaker Get CircuitBreaker regular according to ID and VERSION
	GetCircuitBreaker(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetCircuitBreakerVersions Query all versions of the CircuitBreaker rule
	GetCircuitBreakerVersions(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetMasterCircuitBreakers Query Master CircuitBreaker rules
	GetMasterCircuitBreakers(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetReleaseCircuitBreakers Query the released CircuitBreaker rule according to the rule ID
	GetReleaseCircuitBreakers(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetCircuitBreakerByService Binding CircuitBreaker rule based on service query
	GetCircuitBreakerByService(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetCircuitBreakerToken Get CircuitBreaker rules token
	GetCircuitBreakerToken(ctx context.Context, req *api.CircuitBreaker) *api.Response
}

CircuitBreakerOperateServer Melting rule related treatment

type Client2Api

type Client2Api func(client *model.Client) *api.Client

type ClientServer

type ClientServer interface {

	// RegisterInstance create one instance by client
	RegisterInstance(ctx context.Context, req *api.Instance) *api.Response

	// DeregisterInstance delete onr instance by client
	DeregisterInstance(ctx context.Context, req *api.Instance) *api.Response

	// ReportClient Client gets geographic location information
	ReportClient(ctx context.Context, req *api.Client) *api.Response

	// GetReportClientWithCache Used to obtain the ReportClient information and serve as the SD result of Prometheus
	GetReportClientWithCache(ctx context.Context, query map[string]string) *model.PrometheusDiscoveryResponse

	// GetServiceWithCache Used for client acquisition service information
	GetServiceWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

	// ServiceInstancesCache Used for client acquisition service instance information
	ServiceInstancesCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

	// GetRoutingConfigWithCache User Client Get Service Routing Configuration Information
	GetRoutingConfigWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

	// GetRateLimitWithCache User Client Get Service Limit Configuration Information
	GetRateLimitWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

	// GetCircuitBreakerWithCache Fuse configuration information for obtaining services for clients
	GetCircuitBreakerWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse
}

ClientServer Client related operation Client operation interface definition

type ClientV2Server

type ClientV2Server interface {
	// GetRoutingConfigWithCache User Client Get Service Routing Configuration Information
	GetRoutingConfigV2WithCache(ctx context.Context, req *apiv2.Service) *apiv2.DiscoverResponse

	// GetCircuitBreakerWithCache Fuse configuration information for obtaining services for clients
	GetCircuitBreakerV2WithCache(ctx context.Context, req *apiv2.Service) *apiv2.DiscoverResponse
}

ClientV2Server Client related operation Client operation interface definition

type Config

type Config struct {
	Auth  map[string]interface{} `yaml:"auth"`
	Batch map[string]interface{} `yaml:"batch"`
}

Config 核心逻辑层配置

type DiscoverServer

type DiscoverServer interface {
	// DiscoverServerV1
	DiscoverServerV1
	// DiscoverServerV2
	DiscoverServerV2
	// Service alias operation interface definition
	ServiceAliasOperateServer
	// Service operation interface definition
	ServiceOperateServer
	// Instance Operation Interface Definition
	InstanceOperateServer
	// Client operation interface definition
	ClientServer
	// Get cache management
	Cache() *cache.CacheManager
	// L5 related operations
	L5OperateServer
	// GetServiceInstanceRevision Get the version of the service
	GetServiceInstanceRevision(serviceID string, instances []*model.Instance) (string, error)
}

DiscoverServer Server discovered by the service

func GetServer

func GetServer() (DiscoverServer, error)

GetServer 获取已经初始化好的Server

func TestInitialize

func TestInitialize(ctx context.Context, namingOpt *Config, cacheOpt *cache.Config, bc *batch.Controller,
	cacheMgr *cache.CacheManager, storage store.Store, namespaceSvr namespace.NamespaceOperateServer,
	healthSvr *healthcheck.Server, authSvr auth.AuthServer) (DiscoverServer, error)

TestInitialize 初始化

type DiscoverServerV1

type DiscoverServerV1 interface {
	// Fuse rule operation interface definition
	CircuitBreakerOperateServer
	// Lamflow rule operation interface definition
	RateLimitOperateServer
	// Routing rules operation interface definition
	RouteRuleOperateServer
}

type DiscoverServerV2

type DiscoverServerV2 interface {
	// ClientV2Server
	ClientV2Server
	// RouteRuleV2OperateServer Routing rules operation interface definition
	RouteRuleV2OperateServer
}

type InitOption

type InitOption func(s *Server)

func WithBatchController

func WithBatchController(c *batch.Controller) InitOption

func WithCacheManager

func WithCacheManager(cacheOpt *cache.Config, c *cache.CacheManager) InitOption

func WithHealthCheckSvr

func WithHealthCheckSvr(svr *healthcheck.Server) InitOption

func WithHiddenService

func WithHiddenService(c map[model.ServiceKey]struct{}) InitOption

func WithStorage

func WithStorage(storage store.Store) InitOption

type InstanceOperateServer

type InstanceOperateServer interface {

	// CreateInstances Batch creation instance
	CreateInstances(ctx context.Context, reqs []*api.Instance) *api.BatchWriteResponse

	// DeleteInstances Batch delete instance
	DeleteInstances(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

	// DeleteInstancesByHost Delete instance according to HOST information batch
	DeleteInstancesByHost(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

	// UpdateInstances Batch update instance
	UpdateInstances(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

	// UpdateInstancesIsolate Batch update instance isolation state
	UpdateInstancesIsolate(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

	// GetInstances Get an instance list
	GetInstances(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetInstancesCount Get an instance quantity
	GetInstancesCount(ctx context.Context) *api.BatchQueryResponse

	// GetInstanceLabels Get an instance tag under a service
	GetInstanceLabels(ctx context.Context, query map[string]string) *api.Response

	// CleanInstance Clean up instance
	CleanInstance(ctx context.Context, req *api.Instance) *api.Response
}

InstanceOperateServer Example related operations

type L5OperateServer

type L5OperateServer interface {

	// SyncByAgentCmd Get routing information according to SID list
	SyncByAgentCmd(ctx context.Context, sbac *l5.Cl5SyncByAgentCmd) (*l5.Cl5SyncByAgentAckCmd, error)

	// RegisterByNameCmd Look for the corresponding SID list according to the list of service names
	RegisterByNameCmd(rbnc *l5.Cl5RegisterByNameCmd) (*l5.Cl5RegisterByNameAckCmd, error)
}

L5OperateServer L5 related operations

type RateLimitOperateServer

type RateLimitOperateServer interface {

	// CreateRateLimits Create a RateLimit rule
	CreateRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

	// DeleteRateLimits Delete current RateLimit rules
	DeleteRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

	// EnableRateLimits Enable the RateLimit rule
	EnableRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

	// UpdateRateLimits Modify the RateLimit rule
	UpdateRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

	// GetRateLimits Query RateLimit rules
	GetRateLimits(ctx context.Context, query map[string]string) *api.BatchQueryResponse
}

RateLimitOperateServer Lamflow rule related operation

type ReportClientOperateServer

type ReportClientOperateServer interface {
	// GetReportClients Query the client information reported
	GetReportClients(ctx context.Context, query map[string]string) *api.BatchQueryResponse
}

ReportClientOperateServer Report information operation interface on the client

type ResourceEvent

type ResourceEvent struct {
	ReqService *api.Service
	Service    *model.Service
	IsRemove   bool
}

ResourceEvent 资源事件

type ResourceHook

type ResourceHook interface {

	// Before
	//  @param ctx
	//  @param resourceType
	Before(ctx context.Context, resourceType model.Resource)

	// After
	//  @param ctx
	//  @param resourceType
	//  @param res
	After(ctx context.Context, resourceType model.Resource, res *ResourceEvent) error
}

ResourceHook The listener is placed before and after the resource operation, only normal flow

type RouteRuleOperateServer

type RouteRuleOperateServer interface {
	// CreateRoutingConfigs Batch creation routing configuration
	CreateRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

	// DeleteRoutingConfigs Batch delete routing configuration
	DeleteRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

	// UpdateRoutingConfigs Batch update routing configuration
	UpdateRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

	// GetRoutingConfigs Inquiry route configuration to OSS
	GetRoutingConfigs(ctx context.Context, query map[string]string) *api.BatchQueryResponse
}

RouteRuleOperateServer Routing rules related operations

type RouteRuleV2OperateServer

type RouteRuleV2OperateServer interface {
	// CreateRoutingConfigs Batch creation routing configuration
	CreateRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse
	// DeleteRoutingConfigs Batch delete routing configuration
	DeleteRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse
	// UpdateRoutingConfigs Batch update routing configuration
	UpdateRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse
	// GetRoutingConfigs Inquiry route configuration to OSS
	GetRoutingConfigsV2(ctx context.Context, query map[string]string) *apiv2.BatchQueryResponse
	// EnableRoutings batch enable routing rules
	EnableRoutings(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse
}

RouteRuleV2OperateServer Routing rules related operations

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 对接API层的server层,用以处理业务逻辑

func GetOriginServer

func GetOriginServer() (*Server, error)

GetOriginServer 获取已经初始化好的Server

func (*Server) Cache

func (s *Server) Cache() *cache.CacheManager

Cache 返回Cache

func (*Server) CleanInstance

func (s *Server) CleanInstance(ctx context.Context, req *api.Instance) *api.Response

CleanInstance 清理无效的实例(flag == 1)

func (*Server) CreateCircuitBreaker

func (s *Server) CreateCircuitBreaker(ctx context.Context, req *api.CircuitBreaker) *api.Response

CreateCircuitBreaker 创建单个熔断规则

func (*Server) CreateCircuitBreakerVersion

func (s *Server) CreateCircuitBreakerVersion(ctx context.Context, req *api.CircuitBreaker) *api.Response

CreateCircuitBreakerVersion 创建单个熔断规则版本

func (*Server) CreateCircuitBreakerVersions

func (s *Server) CreateCircuitBreakerVersions(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

CreateCircuitBreakerVersions 批量创建熔断规则版本

func (*Server) CreateCircuitBreakers

func (s *Server) CreateCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

CreateCircuitBreakers 批量创建熔断规则

func (*Server) CreateInstance

func (s *Server) CreateInstance(ctx context.Context, req *api.Instance) *api.Response

CreateInstance 创建单个服务实例 注意:创建实例需要对服务进行加锁保护服务不被删除

func (*Server) CreateInstances

func (s *Server) CreateInstances(ctx context.Context, reqs []*api.Instance) *api.BatchWriteResponse

CreateInstances 批量创建服务实例

func (*Server) CreateRateLimit

func (s *Server) CreateRateLimit(ctx context.Context, req *api.Rule, svcId string) *api.Response

CreateRateLimit 创建限流规则

func (*Server) CreateRateLimits

func (s *Server) CreateRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

CreateRateLimits 批量创建限流规则

func (*Server) CreateRoutingConfig

func (s *Server) CreateRoutingConfig(ctx context.Context, req *api.Routing) *api.Response

CreateRoutingConfig 创建一个路由配置 Deprecated: 该方法准备舍弃 CreateRoutingConfig 创建一个路由配置 创建路由配置需要锁住服务,防止服务被删除

func (*Server) CreateRoutingConfigs

func (s *Server) CreateRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

CreateRoutingConfigs 批量创建路由配置

func (*Server) CreateRoutingConfigsV2

func (s *Server) CreateRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse

CreateRoutingConfigsV2 批量创建路由配置

func (*Server) CreateService

func (s *Server) CreateService(ctx context.Context, req *api.Service) *api.Response

CreateService 创建单个服务

func (*Server) CreateServiceAlias

func (s *Server) CreateServiceAlias(ctx context.Context, req *api.ServiceAlias) *api.Response

CreateServiceAlias 创建服务别名

func (*Server) CreateServices

func (s *Server) CreateServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

CreateServices 批量创建服务

func (*Server) DeleteCircuitBreaker

func (s *Server) DeleteCircuitBreaker(ctx context.Context, req *api.CircuitBreaker) *api.Response

DeleteCircuitBreaker 删除单个熔断规则

func (*Server) DeleteCircuitBreakers

func (s *Server) DeleteCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

DeleteCircuitBreakers 批量删除熔断规则

func (*Server) DeleteInstance

func (s *Server) DeleteInstance(ctx context.Context, req *api.Instance) *api.Response

DeleteInstance 删除单个服务实例

func (*Server) DeleteInstanceByHost

func (s *Server) DeleteInstanceByHost(ctx context.Context, req *api.Instance) *api.Response

DeleteInstanceByHost 根据host删除服务实例

func (*Server) DeleteInstances

func (s *Server) DeleteInstances(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

DeleteInstances 批量删除服务实例

func (*Server) DeleteInstancesByHost

func (s *Server) DeleteInstancesByHost(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

DeleteInstancesByHost 根据host批量删除服务实例

func (*Server) DeleteRateLimit

func (s *Server) DeleteRateLimit(ctx context.Context, req *api.Rule) *api.Response

DeleteRateLimit 删除单个限流规则

func (*Server) DeleteRateLimits

func (s *Server) DeleteRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

DeleteRateLimits 批量删除限流规则

func (*Server) DeleteRoutingConfig

func (s *Server) DeleteRoutingConfig(ctx context.Context, req *api.Routing) *api.Response

DeleteRoutingConfig 删除一个路由配置 Deprecated: 该方法准备舍弃 DeleteRoutingConfig 删除一个路由配置

func (*Server) DeleteRoutingConfigs

func (s *Server) DeleteRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

DeleteRoutingConfigs 批量删除路由配置

func (*Server) DeleteRoutingConfigsV2

func (s *Server) DeleteRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse

DeleteRoutingConfigsV2 批量删除路由配置

func (*Server) DeleteService

func (s *Server) DeleteService(ctx context.Context, req *api.Service) *api.Response

DeleteService 删除单个服务

删除操作需要对服务进行加锁操作,
防止有与服务关联的实例或者配置有新增的操作

func (*Server) DeleteServiceAlias

func (s *Server) DeleteServiceAlias(ctx context.Context, req *api.ServiceAlias) *api.Response

DeleteServiceAlias 删除服务别名

需要带上源服务name,namespace,token
另外一种删除别名的方式,是直接调用删除服务的接口,也是可行的

func (*Server) DeleteServiceAliases

func (s *Server) DeleteServiceAliases(ctx context.Context, req []*api.ServiceAlias) *api.BatchWriteResponse

DeleteServiceAliases 删除服务别名列表

func (*Server) DeleteServices

func (s *Server) DeleteServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

DeleteServices 批量删除服务

func (*Server) DeregisterInstance

func (s *Server) DeregisterInstance(ctx context.Context, req *api.Instance) *api.Response

DeregisterInstance delete one instance

func (*Server) EnableRateLimit

func (s *Server) EnableRateLimit(ctx context.Context, req *api.Rule) *api.Response

EnableRateLimit 启用限流规则

func (*Server) EnableRateLimits

func (s *Server) EnableRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

func (*Server) EnableRoutings

func (s *Server) EnableRoutings(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse

EnableRoutings batch enable routing rules

func (*Server) GetCircuitBreaker

func (s *Server) GetCircuitBreaker(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetCircuitBreaker 根据id和version查询熔断规则

func (*Server) GetCircuitBreakerByService

func (s *Server) GetCircuitBreakerByService(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetCircuitBreakerByService 根据服务查询绑定熔断规则

func (*Server) GetCircuitBreakerToken

func (s *Server) GetCircuitBreakerToken(ctx context.Context, req *api.CircuitBreaker) *api.Response

GetCircuitBreakerToken 查询熔断规则的token

func (*Server) GetCircuitBreakerV2WithCache

func (s *Server) GetCircuitBreakerV2WithCache(ctx context.Context, req *apiv2.Service) *apiv2.DiscoverResponse

GetCircuitBreakerWithCache Fuse configuration information for obtaining services for clients

func (*Server) GetCircuitBreakerVersions

func (s *Server) GetCircuitBreakerVersions(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetCircuitBreakerVersions 根据id查询熔断规则所有版本

func (*Server) GetCircuitBreakerWithCache

func (s *Server) GetCircuitBreakerWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

GetCircuitBreakerWithCache 获取缓存中的熔断规则信息

func (*Server) GetInstanceLabels

func (s *Server) GetInstanceLabels(ctx context.Context, query map[string]string) *api.Response

func (*Server) GetInstances

func (s *Server) GetInstances(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetInstances 查询服务实例

func (*Server) GetInstancesCount

func (s *Server) GetInstancesCount(ctx context.Context) *api.BatchQueryResponse

GetInstancesCount 查询总的服务实例,不带过滤条件的

func (*Server) GetMasterCircuitBreakers

func (s *Server) GetMasterCircuitBreakers(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetMasterCircuitBreakers 查询master熔断规则

func (*Server) GetRateLimitWithCache

func (s *Server) GetRateLimitWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

GetRateLimitWithCache 获取缓存中的限流规则信息

func (*Server) GetRateLimits

func (s *Server) GetRateLimits(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetRateLimits 查询限流规则

func (*Server) GetReleaseCircuitBreakers

func (s *Server) GetReleaseCircuitBreakers(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetReleaseCircuitBreakers 根据规则id查询已发布规则

func (*Server) GetReportClientWithCache

func (s *Server) GetReportClientWithCache(ctx context.Context,
	query map[string]string) *model.PrometheusDiscoveryResponse

GetReportClientWithCache Used for client acquisition service information

func (*Server) GetReportClients

func (s *Server) GetReportClients(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetReportClients create one instance

func (*Server) GetRoutingConfigV2WithCache

func (s *Server) GetRoutingConfigV2WithCache(ctx context.Context, req *apiv2.Service) *apiv2.DiscoverResponse

GetRoutingConfigWithCache User Client Get Service Routing Configuration Information

func (*Server) GetRoutingConfigWithCache

func (s *Server) GetRoutingConfigWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

GetRoutingConfigWithCache 获取缓存中的路由配置信息

func (*Server) GetRoutingConfigs

func (s *Server) GetRoutingConfigs(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetRoutingConfigs 批量获取路由配置 Deprecated: 该方法准备舍弃 GetRoutingConfigs 提供给OSS的查询路由配置的接口

func (*Server) GetRoutingConfigsV2

func (s *Server) GetRoutingConfigsV2(ctx context.Context, query map[string]string) *apiv2.BatchQueryResponse

GetRoutingConfigsV2 提供给OSS的查询路由配置的接口

func (*Server) GetServiceAliases

func (s *Server) GetServiceAliases(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetServiceAliases 查找服务别名

func (*Server) GetServiceInstanceRevision

func (s *Server) GetServiceInstanceRevision(serviceID string, instances []*model.Instance) (string, error)

GetServiceInstanceRevision 获取服务实例的revision

func (*Server) GetServiceOwner

func (s *Server) GetServiceOwner(ctx context.Context, req []*api.Service) *api.BatchQueryResponse

GetServiceOwner 查询服务负责人

func (*Server) GetServiceToken

func (s *Server) GetServiceToken(ctx context.Context, req *api.Service) *api.Response

GetServiceToken 查询Service的token

func (*Server) GetServiceWithCache

func (s *Server) GetServiceWithCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

GetServiceWithCache 根据元数据查询服务

func (*Server) GetServices

func (s *Server) GetServices(ctx context.Context, query map[string]string) *api.BatchQueryResponse

GetServices 查询服务 注意:不包括别名

func (*Server) GetServicesCount

func (s *Server) GetServicesCount(ctx context.Context) *api.BatchQueryResponse

GetServicesCount 查询服务总数

func (*Server) HealthServer

func (s *Server) HealthServer() *healthcheck.Server

HealthServer 健康检查Server

func (*Server) Namespace

func (s *Server) Namespace() namespace.NamespaceOperateServer

Namespace 返回NamespaceOperateServer

func (*Server) RecordDiscoverStatis

func (s *Server) RecordDiscoverStatis(service, discoverNamespace string)

RecordDiscoverStatis 打印服务发现统计

func (*Server) RecordHistory

func (s *Server) RecordHistory(entry *model.RecordEntry)

RecordHistory server对外提供history插件的简单封装

func (*Server) RegisterByNameCmd

func (s *Server) RegisterByNameCmd(rbnc *l5.Cl5RegisterByNameCmd) (*l5.Cl5RegisterByNameAckCmd, error)

RegisterByNameCmd 根据名字获取sid信息

func (*Server) RegisterInstance

func (s *Server) RegisterInstance(ctx context.Context, req *api.Instance) *api.Response

RegisterInstance create one instance

func (*Server) ReleaseCircuitBreaker

func (s *Server) ReleaseCircuitBreaker(ctx context.Context, req *api.ConfigRelease) *api.Response

ReleaseCircuitBreaker 发布单个熔断规则

func (*Server) ReleaseCircuitBreakers

func (s *Server) ReleaseCircuitBreakers(ctx context.Context, req []*api.ConfigRelease) *api.BatchWriteResponse

ReleaseCircuitBreakers 批量发布熔断规则

func (*Server) ReportClient

func (s *Server) ReportClient(ctx context.Context, req *api.Client) *api.Response

ReportClient 客户端上报信息

func (*Server) ServiceInstancesCache

func (s *Server) ServiceInstancesCache(ctx context.Context, req *api.Service) *api.DiscoverResponse

ServiceInstancesCache 根据服务名查询服务实例列表

func (*Server) SetResourceHooks

func (s *Server) SetResourceHooks(hooks ...ResourceHook)

SetResourceHooks 设置资源操作的Hook

func (*Server) SyncByAgentCmd

func (s *Server) SyncByAgentCmd(ctx context.Context, sbac *l5.Cl5SyncByAgentCmd) (
	*l5.Cl5SyncByAgentAckCmd, error)

SyncByAgentCmd 根据sid获取路由信息 老函数: Stat::instance()->inc_sync_req_cnt(); 保存client的IP,该函数只是存储到本地的缓存中 Stat::instance()->add_agent(sbac.agent_ip());

func (*Server) UnBindCircuitBreaker

func (s *Server) UnBindCircuitBreaker(ctx context.Context, req *api.ConfigRelease) *api.Response

UnBindCircuitBreaker 解绑单个熔断规则

func (*Server) UnBindCircuitBreakers

func (s *Server) UnBindCircuitBreakers(ctx context.Context, req []*api.ConfigRelease) *api.BatchWriteResponse

UnBindCircuitBreakers 批量解绑熔断规则

func (*Server) UpdateCircuitBreaker

func (s *Server) UpdateCircuitBreaker(ctx context.Context, req *api.CircuitBreaker) *api.Response

UpdateCircuitBreaker 修改单个熔断规则

func (*Server) UpdateCircuitBreakers

func (s *Server) UpdateCircuitBreakers(ctx context.Context, req []*api.CircuitBreaker) *api.BatchWriteResponse

UpdateCircuitBreakers 批量修改熔断规则

func (*Server) UpdateInstance

func (s *Server) UpdateInstance(ctx context.Context, req *api.Instance) *api.Response

UpdateInstance 修改单个服务实例

func (*Server) UpdateInstanceIsolate

func (s *Server) UpdateInstanceIsolate(ctx context.Context, req *api.Instance) *api.Response

UpdateInstanceIsolate 修改服务实例隔离状态 @note 必填参数为service+namespace+ip

func (*Server) UpdateInstances

func (s *Server) UpdateInstances(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

UpdateInstances 批量修改服务实例

func (*Server) UpdateInstancesIsolate

func (s *Server) UpdateInstancesIsolate(ctx context.Context, req []*api.Instance) *api.BatchWriteResponse

UpdateInstancesIsolate 批量修改服务实例隔离状态 @note 必填参数为service+namespace+host

func (*Server) UpdateRateLimit

func (s *Server) UpdateRateLimit(ctx context.Context, req *api.Rule) *api.Response

UpdateRateLimit 更新限流规则

func (*Server) UpdateRateLimits

func (s *Server) UpdateRateLimits(ctx context.Context, request []*api.Rule) *api.BatchWriteResponse

UpdateRateLimits 批量更新限流规则

func (*Server) UpdateRoutingConfig

func (s *Server) UpdateRoutingConfig(ctx context.Context, req *api.Routing) *api.Response

UpdateRoutingConfig 更新一个路由配置 Deprecated: 该方法准备舍弃 UpdateRoutingConfig 更新单个路由配置

func (*Server) UpdateRoutingConfigs

func (s *Server) UpdateRoutingConfigs(ctx context.Context, req []*api.Routing) *api.BatchWriteResponse

UpdateRoutingConfigs 批量更新路由配置

func (*Server) UpdateRoutingConfigsV2

func (s *Server) UpdateRoutingConfigsV2(ctx context.Context, req []*apiv2.Routing) *apiv2.BatchWriteResponse

UpdateRoutingConfigsV2 批量更新路由配置

func (*Server) UpdateService

func (s *Server) UpdateService(ctx context.Context, req *api.Service) *api.Response

UpdateService 修改单个服务

func (*Server) UpdateServiceAlias

func (s *Server) UpdateServiceAlias(ctx context.Context, req *api.ServiceAlias) *api.Response

UpdateServiceAlias 修改服务别名

func (*Server) UpdateServiceToken

func (s *Server) UpdateServiceToken(ctx context.Context, req *api.Service) *api.Response

UpdateServiceToken 更新服务token

func (*Server) UpdateServices

func (s *Server) UpdateServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

UpdateServices 批量修改服务

type Service2Api

type Service2Api func(service *model.Service) *api.Service

Service2Api *model.service转换为*api.service

type ServiceAliasOperateServer

type ServiceAliasOperateServer interface {

	// CreateServiceAlias Create a service alias
	CreateServiceAlias(ctx context.Context, req *api.ServiceAlias) *api.Response

	// DeleteServiceAliases Batch delete service alias
	DeleteServiceAliases(ctx context.Context, req []*api.ServiceAlias) *api.BatchWriteResponse

	// UpdateServiceAlias Update service alias
	UpdateServiceAlias(ctx context.Context, req *api.ServiceAlias) *api.Response

	// GetServiceAliases Get a list of service alias
	GetServiceAliases(ctx context.Context, query map[string]string) *api.BatchQueryResponse
}

ServiceAliasOperateServer Service alias related operations

type ServiceOperateServer

type ServiceOperateServer interface {

	// CreateServices Batch creation service
	CreateServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

	// DeleteServices Batch delete service
	DeleteServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

	// UpdateServices Batch update service
	UpdateServices(ctx context.Context, req []*api.Service) *api.BatchWriteResponse

	// UpdateServiceToken Update service token
	UpdateServiceToken(ctx context.Context, req *api.Service) *api.Response

	// GetServices Get a list of service
	GetServices(ctx context.Context, query map[string]string) *api.BatchQueryResponse

	// GetServicesCount Total number of services
	GetServicesCount(ctx context.Context) *api.BatchQueryResponse

	// GetServiceToken Get service token
	GetServiceToken(ctx context.Context, req *api.Service) *api.Response

	// GetServiceOwner Owner for obtaining service
	GetServiceOwner(ctx context.Context, req []*api.Service) *api.BatchQueryResponse
}

ServiceOperateServer Service related operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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