ardb

package
v1.1.0-alpha-8 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: Apache-2.0 Imports: 9 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

View Source
var (
	// ErrServerMarkedInvalid is returned in case a server is not valid,
	// and has been marked as such.
	ErrServerMarkedInvalid = errors.New("ardb server marked invalid")
	// ErrTemplateClusterNotSpecified is returned in case a
	// template server is not specified for a vdisk,
	// while a server for it is reuqired.
	ErrTemplateClusterNotSpecified = errors.New("template cluster not configured for vdisk")
)

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 MapErrorToBroadcastStatus

func MapErrorToBroadcastStatus(err error) (log.MessageStatus, bool)

MapErrorToBroadcastStatus tries to map the given error, returned by a `Connection` operation to a broadcast's message status.

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.

func RedisInt64s

func RedisInt64s(reply interface{}, err error) ([]int64, error)

RedisInt64s is a helper that converts an array command reply to a []int64. If err is not equal to nil, then RedisInt64s returns the error. RedisInt64s returns an error if an array item is not an integer.

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 Connection

type Connection interface {
	redis.Conn

	// ConnectionConfig returns the configuration used to
	// configure this connection.
	ConnectionConfig() config.StorageServerConfig
}

Connection defines the interface expected for any ARDB connection.

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 Connection, 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 Connection, err error)
	// MarkTemplateConnectionInvalid marks the server for a given index invalid,
	// which is to be used as a hint that a connection for that server no longer has to be returned,
	// until the connection issue has been resolved.
	MarkTemplateConnectionInvalid(index int64)
}

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 Connection, 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