ardb

package
v1.1.0-alpha-5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLBACacheLimit defines the default cache limit
	DefaultLBACacheLimit = 20 * mebibyteAsBytes // 20 MiB

)

shared constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is a nbd.Backend implementation on top of ARDB

func (*Backend) Close

func (ab *Backend) Close(ctx context.Context) (err error)

Close implements nbd.Backend.Close

func (*Backend) Flush

func (ab *Backend) Flush(ctx context.Context) (err error)

Flush implements nbd.Backend.Flush

func (*Backend) Geometry

func (ab *Backend) Geometry(ctx context.Context) (nbd.Geometry, error)

Geometry implements nbd.Backend.Geometry

func (*Backend) GoBackground

func (ab *Backend) GoBackground(ctx context.Context)

GoBackground implements Backend.GoBackground and the actual work is delegated to the underlying storage

func (*Backend) HasFlush

func (ab *Backend) HasFlush(ctx context.Context) bool

HasFlush implements nbd.Backend.HasFlush Yes, we support flush

func (*Backend) HasFua

func (ab *Backend) HasFua(ctx context.Context) bool

HasFua implements nbd.Backend.HasFua Yes, we support fua

func (*Backend) ReadAt

func (ab *Backend) ReadAt(ctx context.Context, offset, length int64) (payload []byte, err error)

ReadAt implements nbd.Backend.ReadAt

func (*Backend) TrimAt

func (ab *Backend) TrimAt(ctx context.Context, offset, length int64) (int64, error)

TrimAt implements nbd.Backend.TrimAt

func (*Backend) WriteAt

func (ab *Backend) WriteAt(ctx context.Context, b []byte, offset int64) (bytesWritten int64, err error)

WriteAt implements nbd.Backend.WriteAt

func (*Backend) WriteZeroesAt

func (ab *Backend) WriteZeroesAt(ctx context.Context, offset, length int64) (bytesWritten int64, err error)

WriteZeroesAt implements nbd.Backend.WriteZeroesAt

type BackendFactory

type BackendFactory struct {
	// contains filtered or unexported fields
}

BackendFactory holds some variables that can not be passed in the exportconfig like the pool of ardbconnections I hate the factory pattern but I hate global variables even more

func NewBackendFactory

func NewBackendFactory(cfg BackendFactoryConfig) (*BackendFactory, error)

NewBackendFactory creates a new Backend Factory, which is used to create a Backend, without having to work with global variables.

func (*BackendFactory) NewBackend

func (f *BackendFactory) NewBackend(ctx context.Context, ec *nbd.ExportConfig) (backend nbd.Backend, err error)

NewBackend generates a new ardb backend

type BackendFactoryConfig

type BackendFactoryConfig struct {
	Pool                     *RedisPool
	ConfigHotReloader        config.HotReloader
	TLogRPCAddress           string
	RootARDBConnectionString string
	LBACacheLimit            int64 // min-capped to LBA.BytesPerShard
	ConfigPath               string
}

BackendFactoryConfig is used to create a new BackendFactory

func (*BackendFactoryConfig) Validate

func (cfg *BackendFactoryConfig) Validate() error

Validate all the parameters of this BackendFactoryConfig

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

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.

Jump to

Keyboard shortcuts

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