plugin

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RatelimitStr = map[RatelimitType]string{
	IPRatelimit:       "ip-limit",
	APIRatelimit:      "api-limit",
	ServiceRatelimit:  "service-limit",
	InstanceRatelimit: "instance-limit",
}

RatelimitStr rate limit string map

Functions

func RegisterPlugin

func RegisterPlugin(name string, plugin Plugin)

RegisterPlugin 注册插件

func SetPluginConfig

func SetPluginConfig(c *Config)

SetPluginConfig 设置插件配置

func TestCleanCryptoPlugin added in v1.18.0

func TestCleanCryptoPlugin()

Types

type AddCheckRequest

type AddCheckRequest struct {
	Instances []string
	LocalHost string
}

AddCheckRequest add check request

type BatchQueryRequest added in v1.18.0

type BatchQueryRequest struct {
	Requests []*QueryRequest
}

BatchQueryRequest batch query heartbeat request

type BatchQueryResponse added in v1.18.0

type BatchQueryResponse struct {
	Responses []*QueryResponse
}

BatchQueryResponse batch query heartbeat response

type CMDB

type CMDB interface {
	Plugin

	// GetLocation 在CMDB中没有找到Host,返回error为nil,location为nil
	// 插件内部出现错误,返回error不为nil,忽略location
	GetLocation(host string) (*model.Location, error)

	// Range 提供一个Range接口,遍历所有的数据
	// 遍历失败,通过Range返回值error可以额捕获
	// 参数为一个回调函数
	// 返回值:bool,是否继续遍历
	// 返回值:error,回调函数处理结果,error不为nil,则停止遍历过程,并且通过Range返回error
	Range(handler func(host string, location *model.Location) (bool, error)) error

	// Size 获取当前CMDB存储的entry个数
	Size() int32
}

CMDB CMDB插件接口

func GetCMDB

func GetCMDB() CMDB

GetCMDB 获取CMDB插件

type CheckRequest

type CheckRequest struct {
	QueryRequest
	ExpireDurationSec uint32
	CurTimeSec        func() int64
}

CheckRequest check heartbeat request

type CheckResponse

type CheckResponse struct {
	Healthy              bool
	LastHeartbeatTimeSec int64
	StayUnchanged        bool
	Regular              bool
}

CheckResponse check heartbeat response

type CompositeHistory added in v1.14.0

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

func (*CompositeHistory) Destroy added in v1.14.0

func (c *CompositeHistory) Destroy() error

func (*CompositeHistory) Initialize added in v1.14.0

func (c *CompositeHistory) Initialize(config *ConfigEntry) error

func (*CompositeHistory) Name added in v1.14.0

func (c *CompositeHistory) Name() string

func (*CompositeHistory) Record added in v1.14.0

func (c *CompositeHistory) Record(entry *model.RecordEntry)

type Config

type Config struct {
	CMDB                 ConfigEntry      `yaml:"cmdb"`
	RateLimit            ConfigEntry      `yaml:"ratelimit"`
	History              PluginChanConfig `yaml:"history"`
	Statis               PluginChanConfig `yaml:"statis"`
	DiscoverStatis       ConfigEntry      `yaml:"discoverStatis"`
	ParsePassword        ConfigEntry      `yaml:"parsePassword"`
	Whitelist            ConfigEntry      `yaml:"whitelist"`
	MeshResourceValidate ConfigEntry      `yaml:"meshResourceValidate"`
	DiscoverEvent        PluginChanConfig `yaml:"discoverEvent"`
	Crypto               PluginChanConfig `yaml:"crypto"`
}

Config 插件配置

type ConfigEntry

type ConfigEntry struct {
	Name   string                 `yaml:"name"`
	Option map[string]interface{} `yaml:"option"`
}

ConfigEntry 单个插件配置

type Crypto added in v1.17.2

type Crypto interface {
	Plugin
	GenerateKey() ([]byte, error)
	Encrypt(plaintext string, key []byte) (cryptotext string, err error)
	Decrypt(cryptotext string, key []byte) (string, error)
}

Crypto Crypto interface

type CryptoManager added in v1.17.2

type CryptoManager interface {
	Name() string
	Initialize() error
	Destroy() error
	GetCryptoAlgoNames() []string
	GetCrypto(algo string) (Crypto, error)
}

CryptoManager crypto algorithm manager

func GetCryptoManager added in v1.17.2

func GetCryptoManager() CryptoManager

GetCrypto get the crypto plugin

type DiscoverChannel

type DiscoverChannel interface {
	Plugin
	// PublishEvent Release a service event
	PublishEvent(event model.InstanceEvent)
}

DiscoverChannel is used to receive discover events from the agent

func GetDiscoverEvent

func GetDiscoverEvent() DiscoverChannel

GetDiscoverEvent Get service discovery event plug -in

type HealthCheckType

type HealthCheckType int32

HealthCheckType health check type

const (
	HealthCheckerHeartbeat HealthCheckType = iota + 1
)

type HealthChecker

type HealthChecker interface {
	Plugin
	// Type for health check plugin, only one same type plugin is allowed
	Type() HealthCheckType
	// Report process heartbeat info report
	Report(ctx context.Context, request *ReportRequest) error
	// Check process the instance check
	Check(request *CheckRequest) (*CheckResponse, error)
	// Query queries the heartbeat time
	Query(ctx context.Context, request *QueryRequest) (*QueryResponse, error)
	// BatchQuery batch queries the heartbeat time
	BatchQuery(ctx context.Context, request *BatchQueryRequest) (*BatchQueryResponse, error)
	// Suspend health checker for entire expired duration manually
	Suspend()
	// SuspendTimeSec get the suspend time in seconds
	SuspendTimeSec() int64
	// Delete delete the id
	Delete(ctx context.Context, id string) error
	// DebugHandlers return debug handlers
	DebugHandlers() []model.DebugHandler
}

HealthChecker health checker plugin interface

func GetHealthChecker

func GetHealthChecker(name string, cfg *ConfigEntry) HealthChecker

GetHealthChecker get the health checker by name

type History

type History interface {
	Plugin
	Record(entry *model.RecordEntry)
}

History 历史记录插件

func GetHistory

func GetHistory() History

GetHistory Get the historical record plugin

type ParsePassword

type ParsePassword interface {
	Plugin
	ParsePassword(cipher string) (string, error)
}

ParsePassword Password plug -in

func GetParsePassword

func GetParsePassword() ParsePassword

GetParsePassword Get the parsing password plug -in

type Plugin

type Plugin interface {
	Name() string
	Initialize(c *ConfigEntry) error
	Destroy() error
}

Plugin 通用插件接口

type PluginChanConfig added in v1.14.0

type PluginChanConfig struct {
	Name    string                 `yaml:"name"`
	Option  map[string]interface{} `yaml:"option"`
	Entries []ConfigEntry          `yaml:"entries"`
}

PluginChanConfig 插件执行链配置

type QueryRequest

type QueryRequest struct {
	InstanceId string
	Host       string
	Port       uint32
	Healthy    bool
}

QueryRequest query heartbeat request

type QueryResponse

type QueryResponse struct {
	Server           string
	Exists           bool
	LastHeartbeatSec int64
	Count            int64
}

QueryResponse query heartbeat response

type Ratelimit

type Ratelimit interface {
	Plugin

	// Allow Whether to allow access, true: allow, FALSE: not allowing Todo
	// - Parameter ratingype is the type of current limits, and the ID is the key that limits the current
	// - If RateType is Ratelimitip, the ID is IP, RateType is Ratelimitservice, and the ID is
	//  IP_NAMESPACE_SERVICE or IP_SERVICEID
	Allow(typ RatelimitType, key string) bool
}

Ratelimit Ratelimit plugin interface

func GetRatelimit

func GetRatelimit() Ratelimit

GetRatelimit Get the Ratelimit plugin

type RatelimitType

type RatelimitType int

RatelimitType rate limit type

const (
	// IPRatelimit Based on IP flow control
	IPRatelimit RatelimitType = iota + 1

	// APIRatelimit Based on interface-level flow control
	APIRatelimit

	// ServiceRatelimit Based on Service flow control
	ServiceRatelimit

	// InstanceRatelimit Based on Instance flow control
	InstanceRatelimit
)

type ReportRequest

type ReportRequest struct {
	QueryRequest
	LocalHost  string
	CurTimeSec int64
	Count      int64
}

ReportRequest report heartbeat request

type Statis

type Statis interface {
	Plugin
	// ReportCallMetrics report call metrics info
	ReportCallMetrics(metric metrics.CallMetric)
	// ReportDiscoveryMetrics report discovery metrics
	ReportDiscoveryMetrics(metric ...metrics.DiscoveryMetric)
	// ReportConfigMetrics report config_center metrics
	ReportConfigMetrics(metric ...metrics.ConfigMetrics)
	// ReportDiscoverCall report discover service times
	ReportDiscoverCall(metric metrics.ClientDiscoverMetric)
}

Statis Statistical plugin interface

func GetStatis

func GetStatis() Statis

GetStatis Get statistical plugin

type Whitelist

type Whitelist interface {
	Plugin

	Contain(entry interface{}) bool
}

Whitelist White list interface

func GetWhitelist

func GetWhitelist() Whitelist

GetWhitelist Get the whitelist plugin

Directories

Path Synopsis
cmdb
crypto
aes
discoverevent
healthchecker
history
ratelimit
statis

Jump to

Keyboard shortcuts

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