violet

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 16 Imported by: 0

README

violet

Build GitHub release (latest by date)

MIT Licence GitHub code size

Quality Gate Status

Reliability Rating Bugs

Security Rating Vulnerabilities

Maintainability Rating Technical Debt Code Smells

Lines of Code Coverage

HTTP容错代理服务.

使用 resilience4go 包装代理请求.

支持:

  • 舱壁隔离
  • 限时
  • 限速
  • 熔断
  • 重试
  • 缓存
  • 故障恢复

配置样例

请参考: config_help.toml

数据平面

violet.NewDataPlane(*violet.Config)

  • 实现http.Handler接口, 按配置代理http请求
  • 支持配置热更新
  • 支持Prometheus监控指标收集

控制平面

violet.NewCtrlPlane(violet.DataPlane)

  • 实现http.Handler接口
    • /config: 响应返回当前配置
    • /metrics: 响应返回Prometheus指标数据
    • /circuitbreaker/disable: 停用指定Endpoint的熔断器, 使用url-query或post-form参数endpoint=xxx指定Endpoint
    • /circuitbreaker/force-open: 强制开启指定Endpoint的熔断器, 使用url-query或post-form参数endpoint=xxx指定Endpoint
    • /circuitbreaker/close: 关闭指定Endpoint的熔断器, 使用url-query或post-form参数endpoint=xxx指定Endpoint
    • /circuitbreaker/state: 查询指定Endpoint的熔断器的当前状态, 使用url-query或post-form参数endpoint=xxx指定Endpoint

Documentation

Index

Constants

View Source
const DumpTopic = proxy.DumpTopic

Variables

View Source
var (
	RegisterRspFailedPredicate = resilience.RegisterRspFailedPredicate
	RegisterRspCachePredicate  = resilience.RegisterRspCachePredicate
	RegisterFallbackFunction   = resilience.RegisterFallbackFunction
)

Functions

func CircuitBreakerStateHandler

func CircuitBreakerStateHandler(dataPlane DataPlane) http.Handler

func CloseCircuitBreakerHandler

func CloseCircuitBreakerHandler(dataPlane DataPlane) http.Handler

func ConfigHandler

func ConfigHandler(dataPlane DataPlane) http.Handler

func DisableCircuitBreakerHandler

func DisableCircuitBreakerHandler(dataPlane DataPlane) http.Handler

func ForceOpenCircuitBreakerHandler

func ForceOpenCircuitBreakerHandler(dataPlane DataPlane) http.Handler

func MetricsHandler

func MetricsHandler(dataPlane DataPlane) http.Handler

func NewCtrlPlane

func NewCtrlPlane(dataPlane DataPlane) http.Handler

Types

type BulkheadConfig

type BulkheadConfig = resilience.BulkheadConfig

type CacheConfig

type CacheConfig = resilience.CacheConfig

type CircuitBreakerConfig

type CircuitBreakerConfig = resilience.CircuitBreakerConfig

type Config

type Config struct {
	Endpoint []EndpointConfig

	Defaults Defaults
}

func FormatConfig

func FormatConfig(config *Config) *Config

func LoadConfig

func LoadConfig(data string) (*Config, error)

type DataPlane

type DataPlane interface {
	http.Handler
	GetConfig() *Config
	SetConfig(*Config)

	GetRegisterer() prometheus.Registerer
	GetGatherer() prometheus.Gatherer
	SetRegistry(*prometheus.Registry)

	DisableCircuitBreaker(string) error
	ForceOpenCircuitBreaker(string) error
	CloseCircuitBreaker(string) error
	CircuitBreakerState(string) string
}

func NewDataPlane

func NewDataPlane(config *Config) DataPlane

type Defaults

type Defaults struct {
	Resilience ResilienceConfig
}

type DumpMessage

type DumpMessage = proxy.DumpMessage

type DumpType

type DumpType = proxy.DumpType

type EndpointConfig

type EndpointConfig struct {
	Name string

	Location            string
	StripLocationPrefix string

	TargetURL string

	DumpTarget string
	DumpSource string

	Resilience ResilienceConfig
}

type FallbackConfig

type FallbackConfig = resilience.FallbackConfig

type MessageType

type MessageType = proxy.MessageType

type RateLimiterConfig

type RateLimiterConfig = resilience.RateLimiterConfig

type ResilienceConfig

type ResilienceConfig = resilience.Config

type RetryConfig

type RetryConfig = resilience.RetryConfig

type TimeLimiterConfig

type TimeLimiterConfig = resilience.TimeLimiterConfig

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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