model

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 20 Imported by: 18

Documentation

Index

Constants

View Source
const (
	OperatorRoleKey       string = "operator_role"
	OperatorPrincipalType string = "operator_principal"
	OperatorIDKey         string = "operator_id"
	OperatorOwnerKey      string = "operator_owner"
	OperatorLinkStrategy  string = "operator_link_strategy"
	LinkUsersKey          string = "link_users"
	LinkGroupsKey         string = "link_groups"
	RemoveLinkUsersKey    string = "remove_link_users"
	RemoveLinkGroupsKey   string = "remove_link_groups"

	TokenDetailInfoKey string = "TokenInfo"
	TokenForUser       string = "uid"
	TokenForUserGroup  string = "groupid"

	ResourceAttachmentKey string = "resource_attachment"
)
View Source
const (
	// MetaKeyPolarisService service identifier by self registration
	MetaKeyPolarisService = "polaris_service"

	// MetaKeyBuildRevision build revision for server
	MetaKeyBuildRevision = "build-revision"
)
View Source
const (
	LabelKeyPath          = "$path"
	LabelKeyMethod        = "$method"
	LabelKeyHeader        = "$header"
	LabelKeyQuery         = "$query"
	LabelKeyCallerService = "$caller_service"
	LabelKeyCallerIP      = "$caller_ip"
)
View Source
const (
	// V2RuleIDKey v2 版本的规则路由 ID
	V2RuleIDKey = "__routing_v2_id__"
	// V1RuleIDKey v1 版本的路由规则 ID
	V1RuleIDKey = "__routing_v1_id__"
	// V1RuleRouteIndexKey v1 版本 route 规则在自己 route 链中的 index 信息
	V1RuleRouteIndexKey = "__routing_v1_route_index__"
	// V1RuleRouteTypeKey 标识当前 v2 路由规则在 v1 的 inBound 还是 outBound
	V1RuleRouteTypeKey = "__routing_v1_route_type__"
	// V1RuleInRoute inBound 类型
	V1RuleInRoute = "in"
	// V1RuleOutRoute outBound 类型
	V1RuleOutRoute = "out"
)
View Source
const CtxEventKeyMetadata = "ctx_event_metadata"

CtxEventKeyMetadata 用于将metadata从Context中传入并取出

View Source
const (

	// DefaultStrategySuffix 默认策略的名称前缀
	DefaultStrategySuffix string = "的默认策略"
)
View Source
const (
	StatReportPrometheus string = "prometheus"
)

Variables

View Source
var (
	// ErrorNoUser 没有找到对应的用户
	ErrorNoUser error = errors.New("no such user")

	// ErrorNoUserGroup 没有找到对应的用户组
	ErrorNoUserGroup error = errors.New("no such user group")

	// ErrorNoNamespace 没有找到对应的命名空间
	ErrorNoNamespace error = errors.New("no such namespace")

	// ErrorNoService 没有找到对应的服务
	ErrorNoService error = errors.New("no such service")

	// ErrorWrongUsernameOrPassword 用户或者密码错误
	ErrorWrongUsernameOrPassword error = errors.New("name or password is wrong")

	// ErrorTokenNotExist token 不存在
	ErrorTokenNotExist error = errors.New("token not exist")

	// ErrorTokenInvalid 非法的 token
	ErrorTokenInvalid error = errors.New("invalid token")

	// ErrorTokenDisabled token 已经被禁用
	ErrorTokenDisabled error = errors.New("token already disabled")
)
View Source
var (
	// RuleRoutingTypeUrl 记录 anypb.Any 中关于 RuleRoutingConfig 的 url 信息
	RuleRoutingTypeUrl string
	// MetaRoutingTypeUrl 记录 anypb.Any 中关于 MetadataRoutingConfig 的 url 信息
	MetaRoutingTypeUrl string
)
View Source
var (
	// PrincipalNames principal name map
	PrincipalNames = map[PrincipalType]string{
		PrincipalUser:  "user",
		PrincipalGroup: "group",
	}
)
View Source
var (
	UserRoleNames = map[UserRoleType]string{
		AdminUserRole:      "admin",
		OwnerUserRole:      "main",
		SubAccountUserRole: "sub",
	}
)
View Source
var WeightEnum = map[string]WeightType{
	"dynamic": WEIGHTDYNAMIC,
	"static":  WEIGHTSTATIC,
}

WeightEnum weight enum map

View Source
var WeightString = map[WeightType]string{
	WEIGHTDYNAMIC: "dynamic",
	WEIGHTSTATIC:  "static",
}

WeightString weight string map

Functions

func Arguments2Labels

func Arguments2Labels(arguments []*apitraffic.MatchArgument) map[string]*apimodel.MatchString

Arguments2Labels 将参数列表适配成旧的标签模型

func BuildDefaultStrategyName

func BuildDefaultStrategyName(role PrincipalType, name string) string

BuildDefaultStrategyName 构建默认鉴权策略的名称信息

func CheckPrincipalType

func CheckPrincipalType(role int) error

CheckPrincipalType 检查鉴权策略成员角色信息

func Int2bool

func Int2bool(entry int) bool

Int2bool 整数转换为bool值

func ParseRouteRuleAnyToMessage added in v1.14.0

func ParseRouteRuleAnyToMessage(policy apitraffic.RoutingPolicy, anyMessage *anypb.Any) (proto.Message, error)

ParseRouteRuleAnyToMessage convert the any routing proto to message object

func StatusBoolToInt

func StatusBoolToInt(value bool) int

StatusBoolToInt 状态bool转int

func Store2ClientStat

func Store2ClientStat(clientStatStore *ClientStatStore) *apiservice.StatInfo

func WithAccessResources

func WithAccessResources(accessResources map[apisecurity.ResourceType][]ResourceEntry) acquireContextOption

WithAccessResources 设置本次访问的资源

@param accessResources
@return acquireContextOption

func WithAttachment

func WithAttachment(attachment map[string]interface{}) acquireContextOption

WithAttachment 设置本次请求的额外携带信息

@param attachment
@return acquireContextOption

func WithFromClient

func WithFromClient() acquireContextOption

WithFromClient 设置本次请求来自客户端

func WithFromConsole

func WithFromConsole() acquireContextOption

WithFromConsole 设置本次请求来自控制台

func WithMethod

func WithMethod(method string) acquireContextOption

WithMethod 本次操作函数名称

func WithModule

func WithModule(module BzModule) acquireContextOption

WithModule 设置本次请求的模块

@param module
@return acquireContextOption

func WithOperation

func WithOperation(operation ResourceOperation) acquireContextOption

WithOperation 设置本次的操作类型

@param operation
@return acquireContextOption

func WithRequestContext

func WithRequestContext(ctx context.Context) acquireContextOption

WithRequestContext 设置请求上下文

@param ctx
@return acquireContextOption

Types

type AcquireContext

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

AcquireContext 每次鉴权请求上下文信息

func NewAcquireContext

func NewAcquireContext(options ...acquireContextOption) *AcquireContext

NewAcquireContext 创建一个请求响应

@param options
@return *AcquireContext

func (*AcquireContext) GetAccessResources

func (authCtx *AcquireContext) GetAccessResources() map[apisecurity.ResourceType][]ResourceEntry

GetAccessResources 获取本次请求的资源

@receiver authCtx
@return map

func (*AcquireContext) GetAttachment

func (authCtx *AcquireContext) GetAttachment(key string) interface{}

GetAttachment 按照 key 获取某一个附件信息

func (*AcquireContext) GetAttachments

func (authCtx *AcquireContext) GetAttachments() map[string]interface{}

GetAttachments 获取本次请求的额外携带信息

func (*AcquireContext) GetMethod

func (authCtx *AcquireContext) GetMethod() string

GetMethod 获取本次请求涉及的操作函数

func (*AcquireContext) GetModule

func (authCtx *AcquireContext) GetModule() BzModule

GetModule 获取请求的模块

@receiver authCtx
@return BzModule

func (*AcquireContext) GetOperation

func (authCtx *AcquireContext) GetOperation() ResourceOperation

GetOperation 获取本次操作的类型

@receiver authCtx
@return ResourceOperation

func (*AcquireContext) GetRequestContext

func (authCtx *AcquireContext) GetRequestContext() context.Context

GetRequestContext 获取 context.Context

@receiver authCtx
@return context.Context

func (*AcquireContext) IsAccessResourceEmpty

func (authCtx *AcquireContext) IsAccessResourceEmpty() bool

IsAccessResourceEmpty 判断当前待访问的资源,是否为空

func (*AcquireContext) IsFromClient

func (authCtx *AcquireContext) IsFromClient() bool

IsFromClient 本次请求是否来自客户端

func (*AcquireContext) IsFromConsole

func (authCtx *AcquireContext) IsFromConsole() bool

func (*AcquireContext) SetAccessResources

func (authCtx *AcquireContext) SetAccessResources(accessRes map[apisecurity.ResourceType][]ResourceEntry)

SetAccessResources 设置本次请求的资源

@receiver authCtx
@param accessRes

func (*AcquireContext) SetAttachment

func (authCtx *AcquireContext) SetAttachment(key string, val interface{})

SetAttachment 设置附件

func (*AcquireContext) SetRequestContext

func (authCtx *AcquireContext) SetRequestContext(requestContext context.Context)

SetRequestContext 重新设置 context.Context

@receiver authCtx
@param requestContext

type Business

type Business struct {
	ID         string
	Name       string
	Token      string
	Owner      string
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
}

Business 业务结构体

type BzModule

type BzModule int16

BzModule 模块标识

const (
	// UnknowModule 未知模块
	UnknowModule BzModule = iota
	// CoreModule 核心模块
	CoreModule
	// DiscoverModule 服务模块
	DiscoverModule
	// ConfigModule 配置模块
	ConfigModule
	// AuthModule 鉴权模块
	AuthModule
	// MaintainModule 运维操作模块
	MaintainModule
	// BootstrapModule 初始化模块
	BootstrapModule
)

type Callee

type Callee struct {
	ModID    uint32
	CmdID    uint32
	SetID    string
	IP       uint32
	Port     uint32
	Weight   uint32
	Location *Location
}

Callee 被调信息,对应t_server+t_ip_config

type CircuitBreaker

type CircuitBreaker struct {
	ID         string
	Version    string
	Name       string
	Namespace  string
	Business   string
	Department string
	Comment    string
	Inbounds   string
	Outbounds  string
	Token      string
	Owner      string
	Revision   string
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
}

CircuitBreaker 熔断规则

type CircuitBreakerDetail

type CircuitBreakerDetail struct {
	Total               uint32
	CircuitBreakerInfos []*CircuitBreakerInfo
}

CircuitBreakerDetail 返回给控制台的熔断规则及服务数据

type CircuitBreakerInfo

type CircuitBreakerInfo struct {
	CircuitBreaker *CircuitBreaker
	Services       []*Service
}

CircuitBreakerInfo 熔断规则及绑定服务

type CircuitBreakerRelation

type CircuitBreakerRelation struct {
	ServiceID   string
	RuleID      string
	RuleVersion string
	Valid       bool
	CreateTime  time.Time
	ModifyTime  time.Time
}

CircuitBreakerRelation 熔断规则绑定关系

type CircuitBreakerRule added in v1.14.0

type CircuitBreakerRule struct {
	Proto        *apifault.CircuitBreakerRule
	ID           string
	Name         string
	Namespace    string
	Description  string
	Level        int
	SrcService   string
	SrcNamespace string
	DstService   string
	DstNamespace string
	DstMethod    string
	Rule         string
	Revision     string
	Enable       bool
	Valid        bool
	CreateTime   time.Time
	ModifyTime   time.Time
	EnableTime   time.Time
}

CircuitBreakerRule 熔断规则

type Client

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

Client 客户端上报信息表

func NewClient

func NewClient(req *apiservice.Client) *Client

func Store2Client

func Store2Client(is *ClientStore) *Client

Store2Instance store的数据转换为组合了api的数据结构

func (*Client) ModifyTime

func (c *Client) ModifyTime() time.Time

func (*Client) Proto

func (c *Client) Proto() *apiservice.Client

func (*Client) SetValid

func (c *Client) SetValid(v bool)

func (*Client) Valid

func (c *Client) Valid() bool

type ClientStatStore

type ClientStatStore struct {
	Target   string
	Port     uint32
	Protocol string
	Path     string
}

type ClientStore

type ClientStore struct {
	ID         string
	Host       string
	Type       string
	Version    string
	Region     string
	Zone       string
	Campus     string
	Stat       ClientStatStore
	Flag       int
	CreateTime int64
	ModifyTime int64
}

ClientStore 对应store层(database)的对象

type ConfigFile

type ConfigFile struct {
	Id         uint64
	Name       string
	Namespace  string
	Group      string
	Content    string
	Comment    string
	Format     string
	Flag       int
	CreateTime time.Time
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
	Valid      bool
}

ConfigFile 配置文件数据持久化对象

type ConfigFileGroup

type ConfigFileGroup struct {
	Id         uint64
	Name       string
	Namespace  string
	Comment    string
	CreateTime time.Time
	Owner      string
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
	Valid      bool
}

ConfigFileGroup 配置文件组数据持久化对象

type ConfigFileRelease

type ConfigFileRelease struct {
	Id         uint64
	Name       string
	Namespace  string
	Group      string
	FileName   string
	Content    string
	Comment    string
	Md5        string
	Version    uint64
	Flag       int
	CreateTime time.Time
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
	Valid      bool
}

ConfigFileRelease 配置文件发布数据持久化对象

type ConfigFileReleaseHistory

type ConfigFileReleaseHistory struct {
	Id         uint64
	Name       string
	Namespace  string
	Group      string
	FileName   string
	Format     string
	Tags       string
	Content    string
	Comment    string
	Md5        string
	Type       string
	Status     string
	CreateTime time.Time
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
	Valid      bool
}

ConfigFileReleaseHistory 配置文件发布历史记录数据持久化对象

type ConfigFileTag

type ConfigFileTag struct {
	Id         uint64
	Key        string
	Value      string
	Namespace  string
	Group      string
	FileName   string
	CreateTime time.Time
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
	Valid      bool
}

ConfigFileTag 配置文件标签数据持久化对象

type ConfigFileTemplate

type ConfigFileTemplate struct {
	Id         uint64
	Name       string
	Content    string
	Comment    string
	Format     string
	CreateTime time.Time
	CreateBy   string
	ModifyTime time.Time
	ModifyBy   string
}

ConfigFileTemplate config file template data object

type DiscoverEventConfig

type DiscoverEventConfig struct {
	QueueSize          int    `json:"queueSize"`
	OutputPath         string `json:"outputPath"`
	RotationMaxSize    int    `json:"rotationMaxSize"`
	RotationMaxAge     int    `json:"rotationMaxAge"`
	RotationMaxBackups int    `json:"rotationMaxBackups"`
}

DiscoverEventConfig 服务实例事件插件配置

func DefaultDiscoverEventConfig

func DefaultDiscoverEventConfig() *DiscoverEventConfig

DefaultDiscoverEventConfig 创建一个默认的服务事件插件配置

func (*DiscoverEventConfig) Validate

func (c *DiscoverEventConfig) Validate() error

Validate 检查配置是否正确配置

type EnhancedService

type EnhancedService struct {
	*Service
	TotalInstanceCount   uint32
	HealthyInstanceCount uint32
}

EnhancedService 服务增强数据

type ExpandInstanceStore

type ExpandInstanceStore struct {
	ServiceName       string
	Namespace         string
	ServiceToken      string
	ServicePlatformID string
	ServiceInstance   *InstanceStore
}

ExpandInstanceStore 包含服务名的store信息

type ExtendRateLimit

type ExtendRateLimit struct {
	ServiceName   string
	NamespaceName string
	RateLimit     *RateLimit
}

ExtendRateLimit 包含服务信息的限流规则

type ExtendRouterConfig added in v1.14.0

type ExtendRouterConfig struct {
	*RouterConfig
	// MetadataRouting 元数据路由配置
	MetadataRouting *apitraffic.MetadataRoutingConfig
	// RuleRouting 规则路由配置
	RuleRouting *apitraffic.RuleRoutingConfig
	// ExtendInfo 额外信息数据
	ExtendInfo map[string]string
}

ExtendRouterConfig 路由信息的扩展

func (*ExtendRouterConfig) ToApi added in v1.14.0

ToApi Turn to API object

type ExtendRoutingConfig

type ExtendRoutingConfig struct {
	ServiceName   string
	NamespaceName string
	Config        *RoutingConfig
}

ExtendRoutingConfig 路由配置的扩展结构体

type FaultDetectRule added in v1.14.0

type FaultDetectRule struct {
	Proto        *apifault.FaultDetectRule
	ID           string
	Name         string
	Namespace    string
	Description  string
	DstService   string
	DstNamespace string
	DstMethod    string
	Rule         string
	Revision     string
	Valid        bool
	CreateTime   time.Time
	ModifyTime   time.Time
}

FaultDetectRule 故障探测规则

type IPConfig

type IPConfig struct {
	IP     uint32
	AreaID uint32
	CityID uint32
	IdcID  uint32
	Valid  bool
	Flow   uint32
}

IPConfig IP的区域信息

type Instance

type Instance struct {
	Proto             *apiservice.Instance
	ServiceID         string
	ServicePlatformID string
	// Valid Whether it is deleted by logic
	Valid bool
	// ModifyTime Update time of instance
	ModifyTime time.Time
}

Instance 组合了api的Instance对象

func ExpandStore2Instance

func ExpandStore2Instance(es *ExpandInstanceStore) *Instance

ExpandStore2Instance 扩展store转换

func Store2Instance

func Store2Instance(is *InstanceStore) *Instance

Store2Instance store的数据转换为组合了api的数据结构

func (*Instance) Ctime

func (i *Instance) Ctime() string

Ctime get ctime

func (*Instance) EnableHealthCheck

func (i *Instance) EnableHealthCheck() bool

EnableHealthCheck get enables health check

func (*Instance) HealthCheck

func (i *Instance) HealthCheck() *apiservice.HealthCheck

HealthCheck get health check

func (*Instance) Healthy

func (i *Instance) Healthy() bool

Healthy get healthy

func (*Instance) Host

func (i *Instance) Host() string

Host get host

func (*Instance) ID

func (i *Instance) ID() string

ID get id

func (*Instance) Isolate

func (i *Instance) Isolate() bool

Isolate get isolate

func (*Instance) Location

func (i *Instance) Location() *apimodel.Location

Location gets location

func (*Instance) LogicSet

func (i *Instance) LogicSet() string

LogicSet get logic set

func (*Instance) MallocProto

func (i *Instance) MallocProto()

MallocProto malloc proto if proto is null

func (*Instance) Metadata

func (i *Instance) Metadata() map[string]string

Metadata get metadata

func (*Instance) Mtime

func (i *Instance) Mtime() string

Mtime get mtime

func (*Instance) Namespace

func (i *Instance) Namespace() string

Namespace get namespace

func (*Instance) Port

func (i *Instance) Port() uint32

Port get port

func (*Instance) Priority

func (i *Instance) Priority() uint32

Priority gets priority

func (*Instance) Protocol

func (i *Instance) Protocol() string

Protocol get protocol

func (*Instance) Revision

func (i *Instance) Revision() string

Revision get revision

func (*Instance) Service

func (i *Instance) Service() string

Service get service

func (*Instance) ServiceToken

func (i *Instance) ServiceToken() string

ServiceToken get service token

func (*Instance) Version

func (i *Instance) Version() string

Version get version

func (*Instance) VpcID

func (i *Instance) VpcID() string

VpcID get vpcid

func (*Instance) Weight

func (i *Instance) Weight() uint32

Weight get weight

type InstanceCount

type InstanceCount struct {
	// IsolateInstanceCount 隔离状态的实例
	IsolateInstanceCount uint32
	// HealthyInstanceCount 健康实例数
	HealthyInstanceCount uint32
	// TotalInstanceCount 总实例数
	TotalInstanceCount uint32
}

InstanceCount Service instance statistics

type InstanceEvent

type InstanceEvent struct {
	Id         string
	SvcId      string
	Namespace  string
	Service    string
	Instance   *apiservice.Instance
	EType      InstanceEventType
	CreateTime time.Time
	MetaData   map[string]string
}

InstanceEvent 服务实例事件

func (*InstanceEvent) InjectMetadata added in v1.13.3

func (i *InstanceEvent) InjectMetadata(ctx context.Context)

InjectMetadata 从context中获取metadata并注入到事件对象

func (*InstanceEvent) String added in v1.13.8

func (i *InstanceEvent) String() string

type InstanceEventType

type InstanceEventType string

InstanceEventType 探测事件类型

const (
	// EventDiscoverNone empty discover event
	EventDiscoverNone InstanceEventType = "EventDiscoverNone"
	// EventInstanceOnline instance becoming online
	EventInstanceOnline InstanceEventType = "InstanceOnline"
	// EventInstanceTurnUnHealth Instance becomes unhealthy
	EventInstanceTurnUnHealth InstanceEventType = "InstanceTurnUnHealth"
	// EventInstanceTurnHealth Instance becomes healthy
	EventInstanceTurnHealth InstanceEventType = "InstanceTurnHealth"
	// EventInstanceOpenIsolate Instance is in isolation
	EventInstanceOpenIsolate InstanceEventType = "InstanceOpenIsolate"
	// EventInstanceCloseIsolate Instance shutdown isolation state
	EventInstanceCloseIsolate InstanceEventType = "InstanceCloseIsolate"
	// EventInstanceOffline Instance offline
	EventInstanceOffline InstanceEventType = "InstanceOffline"
	// EventInstanceSendHeartbeat Instance send heartbeat package to server
	EventInstanceSendHeartbeat InstanceEventType = "InstanceSendHeartbeat"
	// EventInstanceUpdate Instance metadata and info update event
	EventInstanceUpdate InstanceEventType = "InstanceUpdate"
)

type InstanceStore

type InstanceStore struct {
	ID                string
	ServiceID         string
	Host              string
	VpcID             string
	Port              uint32
	Protocol          string
	Version           string
	HealthStatus      int
	Isolate           int
	Weight            uint32
	EnableHealthCheck int
	CheckType         int32
	TTL               uint32
	Priority          uint32
	Revision          string
	LogicSet          string
	Region            string
	Zone              string
	Campus            string
	Meta              map[string]string
	Flag              int
	CreateTime        int64
	ModifyTime        int64
}

InstanceStore 对应store层(database)的对象

type LeaderElection added in v1.14.0

type LeaderElection struct {
	ElectKey   string
	Host       string
	Ctime      int64
	CreateTime time.Time
	Mtime      int64
	ModifyTime time.Time
	Valid      bool
}

LeaderElection leader election info

type Location

type Location struct {
	Proto    *apimodel.Location
	RegionID uint32
	ZoneID   uint32
	CampusID uint32
	Valid    bool
}

Location cmdb信息,对应内存结构体

func Store2Location

func Store2Location(s *LocationStore) *Location

Store2Location 转成内存数据结构

type LocationStore

type LocationStore struct {
	IP         string
	Region     string
	Zone       string
	Campus     string
	RegionID   uint32
	ZoneID     uint32
	CampusID   uint32
	Flag       int
	ModifyTime int64
}

LocationStore 地域信息,对应数据库字段

type LocationView added in v1.14.0

type LocationView struct {
	IP       string
	Region   string
	Zone     string
	Campus   string
	RegionID uint32
	ZoneID   uint32
	CampusID uint32
}

LocationView cmdb信息,对应内存结构体

type ModifyStrategyDetail

type ModifyStrategyDetail struct {
	ID               string
	Name             string
	Action           string
	Comment          string
	AddPrincipals    []Principal
	RemovePrincipals []Principal
	AddResources     []StrategyResource
	RemoveResources  []StrategyResource
	ModifyTime       time.Time
}

ModifyStrategyDetail 修改鉴权策略详细

type ModifyUserGroup

type ModifyUserGroup struct {
	ID            string
	Owner         string
	Token         string
	TokenEnable   bool
	Comment       string
	AddUserIds    []string
	RemoveUserIds []string
}

ModifyUserGroup 用户组修改

type Namespace

type Namespace struct {
	Name       string
	Comment    string
	Token      string
	Owner      string
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
}

Namespace 命名空间结构体

type NamespaceServiceCount

type NamespaceServiceCount struct {
	// ServiceCount 服务数量
	ServiceCount uint32
	// InstanceCnt 实例健康数/实例总数
	InstanceCnt *InstanceCount
}

NamespaceServiceCount Namespace service data

type OperationType

type OperationType string

OperationType Operating type

const (
	// OCreate create
	OCreate OperationType = "Create"
	// ODelete delete
	ODelete OperationType = "Delete"
	// OUpdate update
	OUpdate OperationType = "Update"
	// OUpdateIsolate Update isolation state
	OUpdateIsolate OperationType = "UpdateIsolate"
	// OUpdateToken Update token
	OUpdateToken OperationType = "UpdateToken"
	// OUpdateGroup Update user-user group association relationship
	OUpdateGroup OperationType = "UpdateGroup"
	// OEnableRateLimit Update enable state
	OUpdateEnable OperationType = "UpdateEnable"
)

Define the type of operation containing

type Policy

type Policy struct {
	ModID uint32
	Div   uint32
	Mod   uint32
	Valid bool
	Flow  uint32
}

Policy 有状态规则路由策略信息

type Principal

type Principal struct {
	StrategyID    string
	PrincipalID   string
	PrincipalRole PrincipalType
}

Principal 策略相关人

type PrincipalType

type PrincipalType int
const (
	PrincipalUser  PrincipalType = 1
	PrincipalGroup PrincipalType = 2
)

func (PrincipalType) String

func (i PrincipalType) String() string

type PrometheusDiscoveryResponse

type PrometheusDiscoveryResponse struct {
	Code     uint32
	Response []PrometheusTarget
}

type PrometheusTarget

type PrometheusTarget struct {
	Targets []string          `json:"targets"`
	Labels  map[string]string `json:"labels"`
}

PrometheusTarget 用于对接 prometheus service discovery 的数据结构

type RateLimit

type RateLimit struct {
	Proto     *apitraffic.Rule
	ID        string
	ServiceID string
	Name      string
	Method    string
	// Labels for old compatible, will be removed later
	Labels     string
	Priority   uint32
	Rule       string
	Revision   string
	Disable    bool
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
	EnableTime time.Time
}

RateLimit 限流规则

func (*RateLimit) AdaptArgumentsAndLabels

func (r *RateLimit) AdaptArgumentsAndLabels() error

AdaptArgumentsAndLabels 对存量标签进行兼容,同时将argument适配成标签

func (*RateLimit) AdaptLabels

func (r *RateLimit) AdaptLabels() error

AdaptLabels 对存量标签进行兼容,对存量labels进行清空

func (*RateLimit) Labels2Arguments

func (r *RateLimit) Labels2Arguments() (map[string]*apimodel.MatchString, error)

Labels2Arguments 适配老的标签到新的参数列表

type RateLimitRevision

type RateLimitRevision struct {
	ServiceID    string
	LastRevision string
	ModifyTime   time.Time
}

RateLimitRevision 包含最新版本号的限流规则

type RecordEntry

type RecordEntry struct {
	ResourceType  Resource
	ResourceName  string
	Namespace     string
	Operator      string
	OperationType OperationType
	Detail        string
	Server        string
	HappenTime    time.Time
}

RecordEntry Operation records

func (*RecordEntry) String

func (r *RecordEntry) String() string

type Resource

type Resource string

Resource Operating resources

const (
	RNamespace          Resource = "Namespace"
	RService            Resource = "Service"
	RRouting            Resource = "Routing"
	RCircuitBreaker     Resource = "CircuitBreaker"
	RInstance           Resource = "Instance"
	RRateLimit          Resource = "RateLimit"
	RUser               Resource = "User"
	RUserGroup          Resource = "UserGroup"
	RUserGroupRelation  Resource = "UserGroupRelation"
	RAuthStrategy       Resource = "AuthStrategy"
	RConfigGroup        Resource = "ConfigGroup"
	RConfigFile         Resource = "ConfigFile"
	RConfigFileRelease  Resource = "ConfigFileRelease"
	RCircuitBreakerRule Resource = "CircuitBreakerRule"
	RFaultDetectRule    Resource = "FaultDetectRule"
)

Define the type of resource type

type ResourceEntry

type ResourceEntry struct {
	ID    string
	Owner string
}

ResourceEntry 资源最简单信息

type ResourceOperation

type ResourceOperation int16

ResourceOperation 资源操作

const (

	// Read 只读动作
	Read ResourceOperation = 10

	// Create 创建动作
	Create ResourceOperation = 20

	// Modify 修改动作
	Modify ResourceOperation = 30

	// Delete 删除动作
	Delete ResourceOperation = 40
)

type Route

type Route struct {
	IP    uint32
	ModID uint32
	CmdID uint32
	SetID string
	Valid bool
	Flow  uint32
}

Route 访问关系

type RouterConfig added in v1.14.0

type RouterConfig struct {
	// ID The unique id of the rules
	ID string `json:"id"`
	// namespace router config owner namespace
	Namespace string `json:"namespace"`
	// name router config name
	Name string `json:"name"`
	// policy Rules
	Policy string `json:"policy"`
	// config Specific routing rules content
	Config string `json:"config"`
	// enable Whether the routing rules are enabled
	Enable bool `json:"enable"`
	// priority Rules priority
	Priority uint32 `json:"priority"`
	// revision Edition information of routing rules
	Revision string `json:"revision"`
	// Description Simple description of rules
	Description string `json:"description"`
	// valid Whether the routing rules are valid and have not been deleted by logic
	Valid bool `json:"flag"`
	// createtime Rules creation time
	CreateTime time.Time `json:"ctime"`
	// modifytime Rules modify time
	ModifyTime time.Time `json:"mtime"`
	// enabletime The last time the rules enabled
	EnableTime time.Time `json:"etime"`
}

RouterConfig Routing rules

func (*RouterConfig) GetRoutingPolicy added in v1.14.0

func (r *RouterConfig) GetRoutingPolicy() apitraffic.RoutingPolicy

GetRoutingPolicy Query routing rules type

func (*RouterConfig) ParseRouteRuleFromAPI added in v1.14.0

func (r *RouterConfig) ParseRouteRuleFromAPI(routing *apitraffic.RouteRule) error

ParseRouteRuleFromAPI Convert an internal object from the API object

func (*RouterConfig) ToExpendRoutingConfig added in v1.14.0

func (r *RouterConfig) ToExpendRoutingConfig() (*ExtendRouterConfig, error)

ToExpendRoutingConfig Converted to an expansion object, serialize the corresponding PB Struct in advance

type RoutingConfig

type RoutingConfig struct {
	ID         string
	InBounds   string
	OutBounds  string
	Revision   string
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
}

* RoutingConfig 路由配置

type Section

type Section struct {
	ModID uint32
	From  uint32
	To    uint32
	Xid   uint32
	Valid bool
	Flow  uint32
}

Section 有状态规则路由分段信息

type Service

type Service struct {
	ID          string
	Name        string
	Namespace   string
	Business    string
	Ports       string
	Meta        map[string]string
	Comment     string
	Department  string
	CmdbMod1    string
	CmdbMod2    string
	CmdbMod3    string
	Token       string
	Owner       string
	Revision    string
	Reference   string
	ReferFilter string
	PlatformID  string
	Valid       bool
	CreateTime  time.Time
	ModifyTime  time.Time
	Mtime       int64
	Ctime       int64
}

Service 服务数据

func (*Service) IsAlias

func (s *Service) IsAlias() bool

IsAlias 便捷函数封装

type ServiceAlias

type ServiceAlias struct {
	ID             string
	Alias          string
	AliasNamespace string
	ServiceID      string
	Service        string
	Namespace      string
	Owner          string
	Comment        string
	CreateTime     time.Time
	ModifyTime     time.Time
}

ServiceAlias 服务别名结构体

type ServiceKey

type ServiceKey struct {
	Namespace string
	Name      string
}

ServiceKey 服务名

type ServiceWithCircuitBreaker

type ServiceWithCircuitBreaker struct {
	ServiceID      string
	CircuitBreaker *CircuitBreaker
	Valid          bool
	CreateTime     time.Time
	ModifyTime     time.Time
}

ServiceWithCircuitBreaker 与服务关系绑定的熔断规则

type ServiceWithCircuitBreakerRules added in v1.14.0

type ServiceWithCircuitBreakerRules struct {
	Service ServiceKey

	Revision string
	// contains filtered or unexported fields
}

ServiceWithCircuitBreakerRules 与服务关系绑定的熔断规则

func NewServiceWithCircuitBreakerRules added in v1.14.0

func NewServiceWithCircuitBreakerRules(svcKey ServiceKey) *ServiceWithCircuitBreakerRules

func (*ServiceWithCircuitBreakerRules) AddCircuitBreakerRule added in v1.14.0

func (s *ServiceWithCircuitBreakerRules) AddCircuitBreakerRule(rule *CircuitBreakerRule)

func (*ServiceWithCircuitBreakerRules) Clear added in v1.14.0

func (s *ServiceWithCircuitBreakerRules) Clear()

func (*ServiceWithCircuitBreakerRules) CountCircuitBreakerRules added in v1.14.0

func (s *ServiceWithCircuitBreakerRules) CountCircuitBreakerRules() int

func (*ServiceWithCircuitBreakerRules) DelCircuitBreakerRule added in v1.14.0

func (s *ServiceWithCircuitBreakerRules) DelCircuitBreakerRule(id string)

func (*ServiceWithCircuitBreakerRules) IterateCircuitBreakerRules added in v1.14.0

func (s *ServiceWithCircuitBreakerRules) IterateCircuitBreakerRules(callback func(*CircuitBreakerRule))

type ServiceWithFaultDetectRules added in v1.14.0

type ServiceWithFaultDetectRules struct {
	Service ServiceKey

	Revision string
	// contains filtered or unexported fields
}

ServiceWithFaultDetectRules 与服务关系绑定的探测规则

func NewServiceWithFaultDetectRules added in v1.14.0

func NewServiceWithFaultDetectRules(svcKey ServiceKey) *ServiceWithFaultDetectRules

func (*ServiceWithFaultDetectRules) AddFaultDetectRule added in v1.14.0

func (s *ServiceWithFaultDetectRules) AddFaultDetectRule(rule *FaultDetectRule)

func (*ServiceWithFaultDetectRules) Clear added in v1.14.0

func (s *ServiceWithFaultDetectRules) Clear()

func (*ServiceWithFaultDetectRules) CountFaultDetectRules added in v1.14.0

func (s *ServiceWithFaultDetectRules) CountFaultDetectRules() int

func (*ServiceWithFaultDetectRules) DelFaultDetectRule added in v1.14.0

func (s *ServiceWithFaultDetectRules) DelFaultDetectRule(id string)

func (*ServiceWithFaultDetectRules) IterateFaultDetectRules added in v1.14.0

func (s *ServiceWithFaultDetectRules) IterateFaultDetectRules(callback func(*FaultDetectRule))

type Sid

type Sid struct {
	ModID uint32
	CmdID uint32
}

Sid sid信息

type SidConfig

type SidConfig struct {
	ModID  uint32
	CmdID  uint32
	Name   string
	Policy uint32
}

SidConfig sid信息,对应t_sid表

type Strategy

type Strategy struct {
	ID         string
	Name       string
	Principal  string
	Action     string
	Comment    string
	Owner      string
	Default    bool
	Valid      bool
	CreateTime time.Time
	ModifyTime time.Time
}

Strategy 策略main信息

type StrategyDetail

type StrategyDetail struct {
	ID         string
	Name       string
	Action     string
	Comment    string
	Principals []Principal
	Default    bool
	Owner      string
	Resources  []StrategyResource
	Valid      bool
	Revision   string
	CreateTime time.Time
	ModifyTime time.Time
}

StrategyDetail 鉴权策略详细

type StrategyDetailCache

type StrategyDetailCache struct {
	*StrategyDetail
	UserPrincipal  map[string]Principal
	GroupPrincipal map[string]Principal
}

StrategyDetailCache 鉴权策略详细

type StrategyResource

type StrategyResource struct {
	StrategyID string
	ResType    int32
	ResID      string
}

StrategyResource 策略资源

type User

type User struct {
	ID          string
	Name        string
	Password    string
	Owner       string
	Source      string
	Mobile      string
	Email       string
	Type        UserRoleType
	Token       string
	TokenEnable bool
	Valid       bool
	Comment     string
	CreateTime  time.Time
	ModifyTime  time.Time
}

User 用户

type UserGroup

type UserGroup struct {
	ID          string
	Name        string
	Owner       string
	Token       string
	TokenEnable bool
	Valid       bool
	Comment     string
	CreateTime  time.Time
	ModifyTime  time.Time
}

UserGroup 用户组

type UserGroupDetail

type UserGroupDetail struct {
	*UserGroup

	// UserIds改为 map 的形式,加速查询
	UserIds map[string]struct{}
}

UserGroupDetail 用户组详细(带用户列表)

func (*UserGroupDetail) ToUserIdSlice

func (ugd *UserGroupDetail) ToUserIdSlice() []string

ToUserIdSlice 将用户ID Map 专为 slice

type UserGroupRelation

type UserGroupRelation struct {
	GroupID    string
	UserIds    []string
	CreateTime time.Time
	ModifyTime time.Time
}

UserGroupRelation 用户-用户组关联关系具体信息

type UserRoleType

type UserRoleType int

UserRoleType 用户角色类型

const (
	UnknownUserRole    UserRoleType = -1
	AdminUserRole      UserRoleType = 0
	OwnerUserRole      UserRoleType = 20
	SubAccountUserRole UserRoleType = 50
)

type WeightType

type WeightType uint32

WeightType 服务下实例的权重类型

const (
	// WEIGHTDYNAMIC 动态权重
	WEIGHTDYNAMIC WeightType = iota

	// WEIGHTSTATIC 静态权重
	WEIGHTSTATIC
)

Jump to

Keyboard shortcuts

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