clients

package
v0.0.0-...-f1afc9c Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNATSOptions = &NATSOptions{
	URL:           nats.DefaultURL,
	Name:          "my-nats-client",
	MaxReconnect:  10,
	ReconnectWait: 2 * time.Second,
}

Functions

func NewConsulClient

func NewConsulClient(addr string) (*api.Client, error)

func NewNATSClient

func NewNATSClient(opts *NATSOptions, logger *zap.Logger) (*nats.Conn, error)

func NewPostgresClient

func NewPostgresClient(ctx context.Context, url string, options *PostgresOptions) (*pgxpool.Pool, error)

func NewRedisClient

func NewRedisClient(url string, options *RedisOptions) (*redis.Client, error)

func NewRedisClusterClient

func NewRedisClusterClient(opts *RedisClusterOptions) (*redis.ClusterClient, error)

Types

type NATSOptions

type NATSOptions struct {
	URL           string
	Name          string
	MaxReconnect  int
	ReconnectWait time.Duration
}

func (*NATSOptions) WithMaxReconnect

func (o *NATSOptions) WithMaxReconnect(max int) *NATSOptions

func (*NATSOptions) WithName

func (o *NATSOptions) WithName(name string) *NATSOptions

func (*NATSOptions) WithReconnectWait

func (o *NATSOptions) WithReconnectWait(reconnect time.Duration) *NATSOptions

func (*NATSOptions) WithURL

func (o *NATSOptions) WithURL(urls string) *NATSOptions

type PostgresOptions

type PostgresOptions struct {
	*pgxpool.Config
	// contains filtered or unexported fields
}

func NewPostgresOptions

func NewPostgresOptions(url string) *PostgresOptions

func (*PostgresOptions) WithConnMaxLifetime

func (o *PostgresOptions) WithConnMaxLifetime(time time.Duration) *PostgresOptions

func (*PostgresOptions) WithConnectTimeout

func (o *PostgresOptions) WithConnectTimeout(time time.Duration) *PostgresOptions

func (*PostgresOptions) WithDatabase

func (o *PostgresOptions) WithDatabase(database string) *PostgresOptions

func (*PostgresOptions) WithDialFunc

func (o *PostgresOptions) WithDialFunc(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *PostgresOptions

func (*PostgresOptions) WithHealthCheckPeriod

func (o *PostgresOptions) WithHealthCheckPeriod(time time.Duration) *PostgresOptions

func (*PostgresOptions) WithHost

func (o *PostgresOptions) WithHost(host string) *PostgresOptions

func (*PostgresOptions) WithMaxCons

func (o *PostgresOptions) WithMaxCons(amount int32) *PostgresOptions

func (*PostgresOptions) WithMinCons

func (o *PostgresOptions) WithMinCons(amount int32) *PostgresOptions

func (*PostgresOptions) WithPassword

func (o *PostgresOptions) WithPassword(password string) *PostgresOptions

func (*PostgresOptions) WithTracerProvider

func (o *PostgresOptions) WithTracerProvider(provider trace.TracerProvider) *PostgresOptions

func (*PostgresOptions) WithUsername

func (o *PostgresOptions) WithUsername(username string) *PostgresOptions

type RedisClusterOptions

type RedisClusterOptions struct {
	*redis.ClusterOptions
	// contains filtered or unexported fields
}

func NewRedisClusterOptions

func NewRedisClusterOptions(addrs []string) *RedisClusterOptions

func (*RedisClusterOptions) WithAddrs

func (o *RedisClusterOptions) WithAddrs(addrs []string) *RedisClusterOptions

func (*RedisClusterOptions) WithBackoffTimeouts

func (o *RedisClusterOptions) WithBackoffTimeouts(min, max time.Duration) *RedisClusterOptions

func (*RedisClusterOptions) WithDialTimeout

func (o *RedisClusterOptions) WithDialTimeout(dialTimeout time.Duration) *RedisClusterOptions

func (*RedisClusterOptions) WithMaxRedirects

func (o *RedisClusterOptions) WithMaxRedirects(maxRedirects int) *RedisClusterOptions

func (*RedisClusterOptions) WithMaxRetries

func (o *RedisClusterOptions) WithMaxRetries(maxRetries int) *RedisClusterOptions

func (*RedisClusterOptions) WithMinIdleConns

func (o *RedisClusterOptions) WithMinIdleConns(minIdleConns int) *RedisClusterOptions

func (*RedisClusterOptions) WithPoolSize

func (o *RedisClusterOptions) WithPoolSize(poolSize int) *RedisClusterOptions

func (*RedisClusterOptions) WithPoolTimeout

func (o *RedisClusterOptions) WithPoolTimeout(timeout time.Duration) *RedisClusterOptions

func (*RedisClusterOptions) WithReadOnlyFlag

func (o *RedisClusterOptions) WithReadOnlyFlag(readOnly bool) *RedisClusterOptions

func (*RedisClusterOptions) WithReadTimeout

func (o *RedisClusterOptions) WithReadTimeout(timeout time.Duration) *RedisClusterOptions

func (*RedisClusterOptions) WithRouteRandomly

func (o *RedisClusterOptions) WithRouteRandomly(randomly bool) *RedisClusterOptions

func (*RedisClusterOptions) WithRouterByLatency

func (o *RedisClusterOptions) WithRouterByLatency(routerByLatency bool) *RedisClusterOptions

func (*RedisClusterOptions) WithTraceProvider

func (o *RedisClusterOptions) WithTraceProvider(provider trace.TracerProvider) *RedisClusterOptions

func (*RedisClusterOptions) WithWriteTimeout

func (o *RedisClusterOptions) WithWriteTimeout(timeout time.Duration) *RedisClusterOptions

type RedisOptions

type RedisOptions struct {
	*redis.Options
	// contains filtered or unexported fields
}

func NewRedisOptions

func NewRedisOptions(url string) *RedisOptions

func (*RedisOptions) WithAddr

func (o *RedisOptions) WithAddr(addr string) *RedisOptions

func (*RedisOptions) WithConnMaxIdleTimeout

func (o *RedisOptions) WithConnMaxIdleTimeout(timeout time.Duration) *RedisOptions

func (*RedisOptions) WithDealer

func (o *RedisOptions) WithDealer(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *RedisOptions

func (*RedisOptions) WithDialTimeout

func (o *RedisOptions) WithDialTimeout(timeout time.Duration) *RedisOptions

func (*RedisOptions) WithLimiter

func (o *RedisOptions) WithLimiter(limiter redis.Limiter) *RedisOptions

func (*RedisOptions) WithMaxActiveConns

func (o *RedisOptions) WithMaxActiveConns(maxActiveConns int) *RedisOptions

func (*RedisOptions) WithMaxRetries

func (o *RedisOptions) WithMaxRetries(maxRetries int) *RedisOptions

func (*RedisOptions) WithMaxRetryBackoff

func (o *RedisOptions) WithMaxRetryBackoff(time time.Duration) *RedisOptions

func (*RedisOptions) WithMinRetryBackoff

func (o *RedisOptions) WithMinRetryBackoff(time time.Duration) *RedisOptions

func (*RedisOptions) WithOnConnect

func (o *RedisOptions) WithOnConnect(fn func(ctx context.Context, conn *redis.Conn) error) *RedisOptions

func (*RedisOptions) WithPassword

func (o *RedisOptions) WithPassword(pw string) *RedisOptions

func (*RedisOptions) WithPoolSize

func (o *RedisOptions) WithPoolSize(poolSize int) *RedisOptions

func (*RedisOptions) WithReadTimeout

func (o *RedisOptions) WithReadTimeout(timeout time.Duration) *RedisOptions

func (*RedisOptions) WithTLSConfig

func (o *RedisOptions) WithTLSConfig(tlsConfig *tls.Config) *RedisOptions

func (*RedisOptions) WithTraceProvider

func (o *RedisOptions) WithTraceProvider(provider trace.TracerProvider) *RedisOptions

func (*RedisOptions) WithUsername

func (o *RedisOptions) WithUsername(username string) *RedisOptions

func (*RedisOptions) WithWriteTimeout

func (o *RedisOptions) WithWriteTimeout(timeout time.Duration) *RedisOptions

Jump to

Keyboard shortcuts

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