Documentation ¶
Index ¶
- func ConfigureCircuitBreaker(setting *CircuitSetting)
- func NewGoRedisClusterConnectionPool(urls []string, opt *RedisConnectionPoolOptions) (*goredis.ClusterClient, error)
- func NewGoRedisConnectionPool(url string, opt *RedisConnectionPoolOptions) (*goredis.Client, error)
- func NewHTTPConnection(opt *HTTPConnectionOptions) *http.Client
- func NewRedigoRedisConnectionPool(url string, opt *RedisConnectionPoolOptions) (*redigo.Pool, error)
- func UnaryClientInterceptor(opts *GRPCUnaryInterceptorOptions) grpc.UnaryClientInterceptor
- type CircuitSetting
- type GRPCUnaryInterceptorOptions
- type HTTPConnectionOptions
- type RedisConnectionPoolOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureCircuitBreaker ¶ added in v1.2.0
func ConfigureCircuitBreaker(setting *CircuitSetting)
ConfigureCircuitBreaker is used to set the default value for any method hystrix will copy this value as the setting when setting for a command is not found
func NewGoRedisClusterConnectionPool ¶
func NewGoRedisClusterConnectionPool(urls []string, opt *RedisConnectionPoolOptions) (*goredis.ClusterClient, error)
NewGoRedisClusterConnectionPool uses goredis library to establish the redis cluster connection pool
func NewGoRedisConnectionPool ¶
func NewGoRedisConnectionPool(url string, opt *RedisConnectionPoolOptions) (*goredis.Client, error)
NewGoRedisConnectionPool uses goredis library to establish the redis connection pool
func NewHTTPConnection ¶
func NewHTTPConnection(opt *HTTPConnectionOptions) *http.Client
NewHTTPConnection new http client
func NewRedigoRedisConnectionPool ¶
func NewRedigoRedisConnectionPool(url string, opt *RedisConnectionPoolOptions) (*redigo.Pool, error)
NewRedigoRedisConnectionPool uses redigo library to establish the redis connection pool
func UnaryClientInterceptor ¶ added in v1.2.0
func UnaryClientInterceptor(opts *GRPCUnaryInterceptorOptions) grpc.UnaryClientInterceptor
Types ¶
type CircuitSetting ¶ added in v1.2.0
type CircuitSetting struct { // Timeout is how long to wait for command to complete, in milliseconds Timeout int `json:"timeout"` // MaxConcurrentRequests is how many commands of the same type can run at the same time MaxConcurrentRequests int `json:"max_concurrent_requests"` // RequestVolumeThreshold is the minimum number of requests needed before a circuit can be tripped due to health RequestVolumeThreshold int `json:"request_volume_threshold"` // SleepWindow is how long, in milliseconds, to wait after a circuit opens before testing for recovery SleepWindow int `json:"sleep_window"` // ErrorPercentThreshold causes circuits to open once the rolling measure of errors exceeds this percent of requests ErrorPercentThreshold int `json:"error_percent_threshold"` }
CircuitSetting is used to tune circuit settings at runtime
type GRPCUnaryInterceptorOptions ¶ added in v1.2.0
type GRPCUnaryInterceptorOptions struct { // UseCircuitBreaker flag if the connection will implement a circuit breaker UseCircuitBreaker bool // RetryCount retry the operation if found error. // When set to <= 1, then it means no retry RetryCount int // RetryInterval next interval for retry. RetryInterval time.Duration // Timeout value, will return context deadline exceeded when the operation exceeds the duration Timeout time.Duration // Flag if the connection is being pooled. Differences will be impacted in appending metadata to the context IsPooled bool }
GRPCUnaryInterceptorOptions wrapper options for the grpc connection
type HTTPConnectionOptions ¶
type HTTPConnectionOptions struct { TLSHandshakeTimeout time.Duration TLSInsecureSkipVerify bool Timeout time.Duration }
HTTPConnectionOptions options for the http connection
type RedisConnectionPoolOptions ¶
type RedisConnectionPoolOptions struct { // Dial timeout for establishing new connections. // Default is 5 seconds. Only for go-redis. DialTimeout time.Duration // Timeout for socket reads. If reached, commands will fail // with a timeout instead of blocking. Use value -1 for no timeout and 0 for default. // Default is 3 seconds. Only for go-redis. ReadTimeout time.Duration // Timeout for socket writes. If reached, commands will fail // with a timeout instead of blocking. // Default is ReadTimeout. Only for go-redis. WriteTimeout time.Duration // Number of idle connections in the pool. IdleCount int // Maximum number of connections allocated by the pool at a given time. // When zero, there is no limit on the number of connections in the pool. PoolSize int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // Close connections older than this duration. If the value is zero, then // the pool does not close connections based on age. MaxConnLifetime time.Duration }
RedisConnectionPoolOptions options for the redis connection