ardb

package
v1.1.0-alpha-7 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: Apache-2.0 Imports: 7 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// DefaultLBACacheLimit defines the default cache limit
	DefaultLBACacheLimit = 20 * MebibyteAsBytes // 20 MiB
	// constants used to convert between MiB/GiB and bytes
	GibibyteAsBytes int64 = 1024 * 1024 * 1024
	MebibyteAsBytes int64 = 1024 * 1024
)

shared constants

Variables

This section is empty.

Functions

func GetConnection

func GetConnection(cfg config.StorageServerConfig) (redis.Conn, error)

GetConnection gets an ardb connection given a storage server config

func GetConnections

func GetConnections(cfgs ...config.StorageServerConfig) (conns []redis.Conn, err error)

GetConnections gets multiple ardb connections given storage server configs

func RedisBytes

func RedisBytes(reply interface{}, replyErr error) (content []byte, err error)

RedisBytes is a utility function used by BlockStorage implementations, where we don't want to trigger an error for non-existent (or nil) content.

Types

type ConnProvider

type ConnProvider interface {
	DataConnProvider
	MetadataConnProvider

	Close() error
}

ConnProvider defines the interface to get ARDB connections to (meta)data storage servers.

func DynamicProvider

func DynamicProvider(ctx context.Context, vdiskID string, source config.Source, pool *RedisPool) (ConnProvider, error)

DynamicProvider creates a provider which always has the most up to date config it can know about.

func StaticProvider

func StaticProvider(cfg config.NBDStorageConfig, pool *RedisPool) (ConnProvider, error)

StaticProvider creates a Static Provider using the given NBD Config.

type DataConnProvider

type DataConnProvider interface {
	// DataConnection gets an ardb (data) connection based on the given modulo index,
	// which depends on the available servers in the cluster used by the provider.
	DataConnection(index int64) (conn redis.Conn, err error)
	// TemplateConnection gets an ardb (template data) connection based on the given modulo index,
	// which depends on the available servers in the cluster used by the provider.
	TemplateConnection(index int64) (conn redis.Conn, err error)
}

DataConnProvider defines the interface to get an ARDB data connection, based on a given index, used by the arbd storage backends

type DialFunc

type DialFunc func(connectionString string, database int) (redis.Conn, error)

DialFunc creates a redis.Conn (if possible), based on a given connectionString and database.

type MetadataConnProvider

type MetadataConnProvider interface {
	// MetaConnection gets an ardb (metadata) connection
	// the the metadata storage server of the cluster used by the provider.
	MetadataConnection() (conn redis.Conn, err error)
}

MetadataConnProvider defines the interface to get an ARDB metadata connection.

type RedisPool

type RedisPool struct {
	Dial DialFunc
	// contains filtered or unexported fields
}

RedisPool maintains a collection of redis.Pool's per connection's database. The application calls the Get method to get a database connection from the pool and the connection's Close method to return the connection's resources to the pool.

The normal redigo.Pool is not adequate since it only maintains connections for a single server.

func NewRedisPool

func NewRedisPool(dial DialFunc) (p *RedisPool)

NewRedisPool creates a new pool for multiple redis servers, if no dialFunc is given, a default one will be used instead, which established a tcp connection for the given connection info.

func (*RedisPool) Close

func (p *RedisPool) Close()

Close releases the resources used by the pool.

func (*RedisPool) Get

func (p *RedisPool) Get(connectionString string, database int) redis.Conn

Get gets a connection. The application must close the returned connection. This method always returns a valid connection so that applications can defer error handling to the first use of the connection. If there is an error getting an underlying connection, then the connection Err, Do, Send, Flush and Receive methods return that error.

type RedisPoolFactory

type RedisPoolFactory func() *RedisPool

RedisPoolFactory defines a factory, to be used to create a new redis pool

func NewRedisPoolFactory

func NewRedisPoolFactory(dial DialFunc) RedisPoolFactory

NewRedisPoolFactory creates a new redis pool factory, using the given dial func

Directories

Path Synopsis
lba

Jump to

Keyboard shortcuts

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