locker

package
v0.9.29 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NodeLockMgr  = NewNodeLocker()
	FileLockMgr  = NewFileLocker()
	IndexLockMgr = NewIndexLocker()
)

Functions

This section is empty.

Types

type FileLocker

type FileLocker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFileLocker

func NewFileLocker() *FileLocker

FileLocker prevents a node file from being downloaded while locked

func (*FileLocker) Add

func (f *FileLocker) Add(id string) *LockInfo

func (*FileLocker) Error

func (f *FileLocker) Error(id string, err error)

func (*FileLocker) Get

func (f *FileLocker) Get(id string) *LockInfo

func (*FileLocker) GetAll

func (f *FileLocker) GetAll() map[string]*LockInfo

func (*FileLocker) Remove

func (f *FileLocker) Remove(id string)

func (*FileLocker) RemoveOld

func (f *FileLocker) RemoveOld(hours int)

type IndexLocker

type IndexLocker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewIndexLocker

func NewIndexLocker() *IndexLocker

IndexLocker prevents a node file from being downloaded using the locked index

func (*IndexLocker) Add

func (i *IndexLocker) Add(id string, name string) *LockInfo

func (*IndexLocker) Error

func (i *IndexLocker) Error(id string, name string, err error)

func (*IndexLocker) Get

func (i *IndexLocker) Get(id string, name string) *LockInfo

func (*IndexLocker) GetAll

func (i *IndexLocker) GetAll() map[string]map[string]*LockInfo

func (*IndexLocker) Remove

func (i *IndexLocker) Remove(id string, name string)

func (*IndexLocker) RemoveOld

func (i *IndexLocker) RemoveOld(hours int)

type LockInfo

type LockInfo struct {
	CreatedOn time.Time `bson:"-" json:"created_on"`
	Error     string    `bson:"-" json:"error"`
}

func NewLockInfo

func NewLockInfo() *LockInfo

type NodeLock

type NodeLock struct {
	Id       string    `bson:"-" json:"id"`
	IsLocked bool      `bson:"-" json:"locked"`
	Updated  time.Time `bson:"-" json:"updated_on"`
	// contains filtered or unexported fields
}

func NewNodeLock

func NewNodeLock(id string) (n *NodeLock)

type NodeLocker

type NodeLocker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewNodeLocker

func NewNodeLocker() *NodeLocker

NodeLocker prevents a process from loading node from mongo while another process is update the same node

func (*NodeLocker) Add

func (l *NodeLocker) Add(id string)

func (*NodeLocker) GetAll

func (l *NodeLocker) GetAll() (nodes []*NodeLock)

func (*NodeLocker) GetLocked

func (l *NodeLocker) GetLocked() (nodes []*NodeLock)

func (*NodeLocker) LockNode

func (l *NodeLocker) LockNode(id string) (err error)

func (*NodeLocker) Remove

func (l *NodeLocker) Remove(id string)

func (*NodeLocker) RemoveOld

func (l *NodeLocker) RemoveOld(hours int)

func (*NodeLocker) UnlockNode

func (l *NodeLocker) UnlockNode(id string)

Jump to

Keyboard shortcuts

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