connect

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 7 Imported by: 3

README

go-connect

standard connector for 3rd party services. ex: redis, db, etc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Types

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

Jump to

Keyboard shortcuts

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