database

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 13 Imported by: 48

Documentation

Index

Constants

View Source
const (
	CLUSTER            pubsubEvent = "_mirrorbits_cluster"
	FILE_UPDATE        pubsubEvent = "_mirrorbits_file_update"
	MIRROR_UPDATE      pubsubEvent = "_mirrorbits_mirror_update"
	MIRROR_FILE_UPDATE pubsubEvent = "_mirrorbits_mirror_file_update"

	PUBSUB_RECONNECTED pubsubEvent = "_mirrorbits_pubsub_reconnected"
)

Variables

View Source
var (
	ErrInvalidLockName = errors.New("invalid lock name")
	ErrAlreadyLocked   = errors.New("lock already acquired")
)
View Source
var (
	// ErrUnreachable is returned when the endpoint is not reachable
	ErrUnreachable = errors.New("redis endpoint unreachable")
	// ErrRedisUpgradeRequired is returned when the redis server is running an unsupported version
	ErrRedisUpgradeRequired = errors.New("unsupported Redis version")
)
View Source
var (
	ErrUnsupportedVersion = errors.New("unsupported database version, please upgrade mirrorbits")
)

Functions

func Publish

func Publish(r redis.Conn, event pubsubEvent, message string) error

Publish a message on the pubsub server

func RedisIsLoading

func RedisIsLoading(err error) bool

RedisIsLoading returns true if the error is of type LOADING

func SendPublish

func SendPublish(r redis.Conn, event pubsubEvent, message string) error

SendPublish add the message to a transaction

Types

type Lock

type Lock struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Lock) Held

func (l *Lock) Held() bool

func (*Lock) Release

func (l *Lock) Release()

type NetReadyError

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

func NewNetTemporaryError

func NewNetTemporaryError() NetReadyError

func (*NetReadyError) Temporary

func (n *NetReadyError) Temporary() bool

func (*NetReadyError) Timeout

func (n *NetReadyError) Timeout() bool

type NotReadyError

type NotReadyError struct{}

func (*NotReadyError) Close

func (e *NotReadyError) Close() error

func (*NotReadyError) Do

func (e *NotReadyError) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*NotReadyError) Err

func (e *NotReadyError) Err() error

func (*NotReadyError) Flush

func (e *NotReadyError) Flush() error

func (*NotReadyError) Receive

func (e *NotReadyError) Receive() (reply interface{}, err error)

func (*NotReadyError) Send

func (e *NotReadyError) Send(commandName string, args ...interface{}) error

type Pubsub

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

Pubsub is the internal structure of the publish/subscribe handler

func NewPubsub

func NewPubsub(r *Redis) *Pubsub

NewPubsub returns a new instance of the publish/subscribe handler

func (*Pubsub) Close

func (p *Pubsub) Close()

Close all the connections to the pubsub server

func (*Pubsub) SubscribeEvent

func (p *Pubsub) SubscribeEvent(event pubsubEvent, channel chan string)

SubscribeEvent allows subscription to a particular kind of events and receive a notification when an event is dispatched on the given channel.

type Redis

type Redis struct {
	Pubsub *Pubsub
	// contains filtered or unexported fields
}

Redis is the instance object of the redis database

func NewRedis

func NewRedis() *Redis

NewRedis returns a new instance of the redis database

func NewRedisCustomPool

func NewRedisCustomPool(pool redisPool) *Redis

NewRedisCustomPool returns a new instance of the redis database using a custom pool

func (*Redis) AcquireLock

func (r *Redis) AcquireLock(name string) (*Lock, error)

func (*Redis) CheckVersion

func (r *Redis) CheckVersion() error

CheckVersion checks if the redis server version is supported

func (*Redis) Close

func (r *Redis) Close()

Close closes all connections to the redis database

func (*Redis) Connect

func (r *Redis) Connect() (redis.Conn, error)

Connect initiates a new connection to the redis server

func (*Redis) ConnectPubsub

func (r *Redis) ConnectPubsub()

ConnectPubsub initiates the connection to the pubsub

func (*Redis) Failure

func (r *Redis) Failure() bool

Failure returns true if the connection is in a failure state

func (*Redis) Get

func (r *Redis) Get() redis.Conn

Get returns a redis connection from the pool

func (*Redis) GetDBFormatVersion

func (r *Redis) GetDBFormatVersion() (int, error)

GetDBFormatVersion return the current database format version

func (*Redis) GetListOfMirrors

func (r *Redis) GetListOfMirrors() (map[int]string, error)

func (*Redis) UnblockedGet

func (r *Redis) UnblockedGet() redis.Conn

UnblockedGet returns a redis connection from the pool even if the database checks and/or upgrade are not finished.

func (*Redis) Upgrade

func (r *Redis) Upgrade() error

Upgrade starts the upgrade of the database format

func (*Redis) UpgradeNeeded

func (r *Redis) UpgradeNeeded() (bool, error)

UpgradeNeeded returns true if a database upgrade is needed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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