model

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: 9 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 (

	// 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 (
	// PrincipalNames principal name map
	PrincipalNames = map[PrincipalType]string{
		PrincipalUser:  "user",
		PrincipalGroup: "group",
	}
)

ResourceTypeMap resource type map

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 []*v1.MatchArgument) map[string]*v1.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 StatusBoolToInt

func StatusBoolToInt(value bool) int

StatusBoolToInt 状态bool转int

func Store2ClientStat

func Store2ClientStat(clientStatStore *ClientStatStore) *api.StatInfo

func WithAccessResources

func WithAccessResources(accessResources map[api.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[api.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[api.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 Client

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

*

  • Client 客户端上报信息表

func NewClient

func NewClient(req *api.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() *api.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 ExtendRoutingConfig

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

ExtendRoutingConfig 路由配置的扩展结构体

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             *api.Instance
	ServiceID         string
	ServicePlatformID string
	// Valid Whether it is deleted by logic
	Valid bool
	// ModifyTime Update time of instance
	ModifyTime time.Time
	// FirstRegis Whether the label instance is the first registration
	FirstRegis bool
}

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() *api.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() *api.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 {
	// HealthyInstanceCount 健康实例数
	HealthyInstanceCount uint32
	// TotalInstanceCount 总实例数
	TotalInstanceCount uint32
}

InstanceCount Service instance statistics

type InstanceEvent

type InstanceEvent struct {
	Id         string
	Namespace  string
	Service    string
	Instance   *v1.Instance
	EType      InstanceEventType
	CreateTime time.Time
}

InstanceEvent 服务实例事件

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"
)

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 Location

type Location struct {
	Proto    *v1.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 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 操作类型

const (
	// OCreate 新建
	OCreate OperationType = "Create"

	// ODelete 删除
	ODelete OperationType = "Delete"

	// OUpdate 更新
	OUpdate OperationType = "Update"

	// OUpdateIsolate 更新隔离状态
	OUpdateIsolate OperationType = "UpdateIsolate"

	// OGetToken 查看token
	OGetToken OperationType = "GetToken"

	// OUpdateToken 更新token
	OUpdateToken OperationType = "UpdateToken"

	// OUpdateGroup 更新用户-用户组关联关系
	OUpdateGroup OperationType = "UpdateGroup"
)

定义包含的操作类型

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     *v1.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]*v1.MatchString, error)

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

type RateLimitRevision

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

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

type RecordEntry

type RecordEntry struct {
	ResourceType  Resource
	OperationType OperationType
	Namespace     string
	Service       string
	MeshID        string
	MeshName      string
	Context       string
	Operator      string
	Revision      string
	Username      string
	UserGroup     string
	StrategyName  string
	CreateTime    time.Time
}

RecordEntry 操作记录entry

func (*RecordEntry) String

func (r *RecordEntry) String() string

type Resource

type Resource string

Resource 操作资源

const (
	RNamespace         Resource = "Namespace"
	RService           Resource = "Service"
	RRouting           Resource = "Routing"
	RRoutingV2         Resource = "RoutingV2"
	RInstance          Resource = "Instance"
	RRateLimit         Resource = "RateLimit"
	RMeshResource      Resource = "MeshResource"
	RMesh              Resource = "Mesh"
	RMeshService       Resource = "MeshService"
	RFluxRateLimit     Resource = "FluxRateLimit"
	RUser              Resource = "User"
	RUserGroup         Resource = "UserGroup"
	RUserGroupRelation Resource = "UserGroupRelation"
	RAuthStrategy      Resource = "AuthStrategy"
	RConfigGroup       Resource = "ConfigGroup"
	RConfigFile        Resource = "ConfigFile"
)

定义包含的资源类型

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 ResourceType

type ResourceType int

ResourceType 资源类型

const (
	// MeshType 网格类型资源
	MeshType ResourceType = iota
	// ServiceType 北极星服务类型资源
	ServiceType
)

func GetResourceType

func GetResourceType(r Resource) ResourceType

GetResourceType 获取资源的大类型

type Route

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

Route 访问关系

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 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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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