Documentation ¶
Index ¶
- Variables
- func ConfigureCircuitBreaker(setting *CircuitSetting)
- func InitTraceProvider(token, collectorURL, serviceName, environment string, traceRatio float64) *sdktrace.TracerProvider
- func InitializeCockroachConn(databaseDSN string, opt *CockroachDBConnectionOptions)
- func InitializeMySQLConn(databaseDSN string, opt *MySQLConnectionOptions) (conn *gorm.DB, healthCheckStopFunc func(), err error)
- func NewElasticsearchClient(url string, httpClient *http.Client, opt *ElasticsearchConnectionOptions) (*elastic.Client, error)
- 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 NewUnaryGRPCConnection(target string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
- func RegisterHealthCheckService(registrar grpc.ServiceRegistrar, customHandler grpc_health_v1.HealthServer)
- func UnaryClientInterceptor(opts *GRPCUnaryInterceptorOptions) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts *GRPCUnaryInterceptorOptions, redisClient *redis.Client) grpc.UnaryServerInterceptor
- type CircuitSetting
- type CockroachDBConnectionOptions
- type ESErrorLogger
- type ESInfoLogger
- type ESTraceLogger
- type ElasticsearchConnectionOptions
- type GRPCRateLimiter
- type GRPCUnaryInterceptorOptions
- type GormCustomLogger
- func (g *GormCustomLogger) Error(_ context.Context, message string, values ...interface{})
- func (g *GormCustomLogger) Info(_ context.Context, message string, values ...interface{})
- func (g *GormCustomLogger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
- func (g *GormCustomLogger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error)
- func (g *GormCustomLogger) Warn(_ context.Context, message string, values ...interface{})
- type HTTPConnectionOptions
- type HealthCheckService
- type MySQLConnectionOptions
- type Option
- type RecoveryHandlerFunc
- type RedisConnectionPoolOptions
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ( // CockroachDB represents gorm DB CockroachDB *gorm.DB // StopTickerCh signal for closing ticker channel StopTickerCh chan bool )
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 InitTraceProvider ¶ added in v1.8.0
func InitTraceProvider(token, collectorURL, serviceName, environment string, traceRatio float64) *sdktrace.TracerProvider
InitTraceProvider configures an OpenTelemetry exporter and trace provider
func InitializeCockroachConn ¶ added in v1.8.0
func InitializeCockroachConn(databaseDSN string, opt *CockroachDBConnectionOptions)
InitializeCockroachConn :nodoc:
func InitializeMySQLConn ¶ added in v1.18.0
func InitializeMySQLConn(databaseDSN string, opt *MySQLConnectionOptions) (conn *gorm.DB, healthCheckStopFunc func(), err error)
InitializeMySQLConn :nodoc:
func NewElasticsearchClient ¶ added in v1.8.0
func NewElasticsearchClient(url string, httpClient *http.Client, opt *ElasticsearchConnectionOptions) (*elastic.Client, error)
NewElasticsearchClient :nodoc:
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 NewUnaryGRPCConnection ¶ added in v1.7.0
func NewUnaryGRPCConnection(target string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
NewUnaryGRPCConnection establish a new grpc connection
func RegisterHealthCheckService ¶ added in v1.15.0
func RegisterHealthCheckService(registrar grpc.ServiceRegistrar, customHandler grpc_health_v1.HealthServer)
RegisterHealthCheckService init health check service
func UnaryClientInterceptor ¶ added in v1.2.0
func UnaryClientInterceptor(opts *GRPCUnaryInterceptorOptions) grpc.UnaryClientInterceptor
UnaryClientInterceptor wrapper with circuit breaker, retry, timeout, open telemetry, and metadata logging
func UnaryServerInterceptor ¶ added in v1.8.0
func UnaryServerInterceptor(opts *GRPCUnaryInterceptorOptions, redisClient *redis.Client) grpc.UnaryServerInterceptor
UnaryServerInterceptor wrapper with open telemetry
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 CockroachDBConnectionOptions ¶ added in v1.8.0
type CockroachDBConnectionOptions struct { PingInterval time.Duration RetryAttempts int MaxIdleConns int MaxOpenConns int ConnMaxLifetime time.Duration LogLevel string UseOpenTelemetry bool PingTimeout time.Duration }
CockroachDBConnectionOptions options for the CockroachDB connection
type ESErrorLogger ¶ added in v1.8.0
type ESErrorLogger struct{}
ESErrorLogger :nodoc:
func (*ESErrorLogger) Printf ¶ added in v1.8.0
func (*ESErrorLogger) Printf(format string, values ...interface{})
Printf :nodoc:
type ESInfoLogger ¶ added in v1.8.0
type ESInfoLogger struct{}
ESInfoLogger :nodoc:
func (*ESInfoLogger) Printf ¶ added in v1.8.0
func (*ESInfoLogger) Printf(format string, values ...interface{})
Printf :nodoc:
type ESTraceLogger ¶ added in v1.8.0
type ESTraceLogger struct{}
ESTraceLogger :nodoc:
func (*ESTraceLogger) Printf ¶ added in v1.8.0
func (*ESTraceLogger) Printf(format string, values ...interface{})
Printf :nodoc:
type ElasticsearchConnectionOptions ¶ added in v1.8.0
type ElasticsearchConnectionOptions struct { TLSHandshakeTimeout time.Duration TLSInsecureSkipVerify bool MaxIdleConnections int MaxConnsPerHost int SetSniff bool SetHealthcheck bool UseOpenTelemetry bool }
ElasticsearchConnectionOptions options for the Elasticsearch connection
type GRPCRateLimiter ¶ added in v1.14.0
type GRPCRateLimiter struct { Limit int64 Period time.Duration ExcludedIPs []string ExcludedUserAgents []string }
GRPCRateLimiter wrapper for the gRPC rate limiter
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 // UseOpenTelemetry flag if the connection will implement open telemetry UseOpenTelemetry bool // RateLimiter flag if the connection will implement rate limiter RateLimiter *GRPCRateLimiter RecoveryHandlerFunc RecoveryHandlerFunc }
GRPCUnaryInterceptorOptions wrapper options for the grpc connection
type GormCustomLogger ¶ added in v1.8.0
type GormCustomLogger struct {
gormLogger.Config
}
GormCustomLogger override gorm logger
func NewGormCustomLogger ¶ added in v1.8.0
func NewGormCustomLogger() *GormCustomLogger
NewGormCustomLogger :nodoc:
func (*GormCustomLogger) Error ¶ added in v1.8.0
func (g *GormCustomLogger) Error(_ context.Context, message string, values ...interface{})
Error :nodoc:
func (*GormCustomLogger) Info ¶ added in v1.8.0
func (g *GormCustomLogger) Info(_ context.Context, message string, values ...interface{})
Info :nodoc:
func (*GormCustomLogger) LogMode ¶ added in v1.8.0
func (g *GormCustomLogger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
LogMode :nodoc:
type HTTPConnectionOptions ¶
type HTTPConnectionOptions struct { TLSHandshakeTimeout time.Duration TLSInsecureSkipVerify bool Timeout time.Duration UseOpenTelemetry bool EnableKeepAlives bool }
HTTPConnectionOptions options for the http connection
type HealthCheckService ¶ added in v1.15.0
type HealthCheckService struct{}
HealthCheckService handler for health check rpc
func (HealthCheckService) Check ¶ added in v1.15.0
func (s HealthCheckService) Check(_ context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check :nodoc:
func (HealthCheckService) Watch ¶ added in v1.15.0
func (s HealthCheckService) Watch(_ *grpc_health_v1.HealthCheckRequest, server grpc_health_v1.Health_WatchServer) error
Watch :nodoc:
type MySQLConnectionOptions ¶ added in v1.18.0
type MySQLConnectionOptions struct { PingInterval time.Duration RetryAttempts int MaxIdleConns int MaxOpenConns int ConnMaxLifetime time.Duration LogLevel string UseOpenTelemetry bool PingTimeout time.Duration ReconnectCallback func(db *gorm.DB) // func will provide new *gorm.DB if current connection is broken and re-creation of new connection is succeeded. }
MySQLConnectionOptions options for the CockroachDB connection
type Option ¶ added in v1.8.0
type Option func(t *Transport)
Option signature for specifying options, e.g. WithRoundTripper.
func WithRoundTripper ¶ added in v1.8.0
func WithRoundTripper(rt http.RoundTripper) Option
WithRoundTripper specifies the http.RoundTripper to call next after this transport. If it is nil (default), the transport will use http.DefaultTransport.
type RecoveryHandlerFunc ¶ added in v1.13.0
RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`. The context can be used to extract request scoped metadata and context values.
type RedisConnectionPoolOptions ¶
type RedisConnectionPoolOptions struct { // Dial timeout for establishing new connections. // Default is 5 seconds. Only for go-redis. DialTimeout time.Duration // Enables read-only commands on slave nodes. ReadOnly bool // 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
type Transport ¶ added in v1.8.0
type Transport struct {
// contains filtered or unexported fields
}
Transport for tracing HTTP operations.
func NewTransport ¶ added in v1.8.0
NewTransport specifies a transport that will trace HTTP and report back via OpenTracing.