Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeDBOperationsToJson(ops []DBOperation) ([]byte, error)
- func IsErrNotFound(err error) bool
- func SetOpMeta(op DBOperation) error
- func SetOpMetas(ops []DBOperation) error
- func TypeName(t Type) string
- type AlwaysFailForTestingOp
- type CachedDBTransactionLogIO
- type CreateNodeOp
- type DB
- func (db *DB) ApplyTransaction(tx DBTransaction) (TxID, error)
- func (db *DB) Fsck() ([]string, []error)
- func (db *DB) GetStats() DBServiceStats
- func (db *DB) LockNode(id ID) (NodeLock, error)
- func (db *DB) QueryNode(id ID, tryLock bool) (NodeView, NodeLock, error)
- func (db *DB) QueryRecentTransactions() ([]DBTransaction, error)
- func (db *DB) RestoreVersion(version TxID) error
- func (db *DB) Sync() error
- func (db *DB) TriggerSync() <-chan error
- func (db *DB) UnlockNode(nlock NodeLock) error
- type DBFscker
- type DBHandler
- type DBOperation
- type DBService
- func (srv *DBService) ApplyTransaction(tx DBTransaction) (txid TxID, err error)
- func (srv *DBService) Fsck() (foundblobpaths []string, errs []error)
- func (srv *DBService) GetStats() (stats DBServiceStats)
- func (*DBService) ImplName() string
- func (srv *DBService) LockNode(id ID) (nlock NodeLock, err error)
- func (srv *DBService) QueryNode(id ID, tryLock bool) (v NodeView, nlock NodeLock, err error)
- func (srv *DBService) QueryRecentTransactions() (txs []DBTransaction, err error)
- func (srv *DBService) Quit()
- func (srv *DBService) Sync() (err error)
- func (srv *DBService) TriggerSync() (errC <-chan error)
- func (srv *DBService) UnlockNode(nlock NodeLock) (err error)
- type DBServiceStats
- type DBServiceStatsProvider
- type DBState
- type DBStateSnapshotIO
- type DBTransaction
- type DBTransactionLogIO
- type DirNode
- type DirNodeView
- type Errno
- type FileChunk
- type FileNode
- type FileNodeView
- type GobEncodable
- type HardLinkOp
- type ID
- type INode
- type INodeCommon
- type InitializeFileSystemOp
- type NodeLock
- type NodeView
- type OpMeta
- type QueryRecentTransactionsProvider
- type RemoveOp
- type RenameOp
- type SimpleDBStateSnapshotIO
- type SimpleDBTransactionLogIO
- type Ticket
- type TriggerSyncer
- type TxID
- type Type
- type UnresolvedDBTransaction
- type UpdateChunksOp
- type UpdateGidOp
- type UpdateModifiedTOp
- type UpdatePermModeOp
- type UpdateSizeOp
- type UpdateUidOp
Constants ¶
View Source
const ( FileNodeT = iota DirNodeT )
View Source
const (
AllocateNewNodeID = 0
)
View Source
const NoTicket = Ticket(0)
Variables ¶
View Source
var ( ErrLockInvalid = errors.New("Invalid lock given.") ErrLockTaken = errors.New("Lock is already acquired by someone else.") )
Functions ¶
func EncodeDBOperationsToJson ¶
func EncodeDBOperationsToJson(ops []DBOperation) ([]byte, error)
func IsErrNotFound ¶
func SetOpMeta ¶
func SetOpMeta(op DBOperation) error
func SetOpMetas ¶
func SetOpMetas(ops []DBOperation) error
Types ¶
type AlwaysFailForTestingOp ¶
type AlwaysFailForTestingOp struct {
OpMeta `json:",inline"`
}
func (*AlwaysFailForTestingOp) Apply ¶
func (op *AlwaysFailForTestingOp) Apply(s *DBState) error
type CachedDBTransactionLogIO ¶
type CachedDBTransactionLogIO struct {
// contains filtered or unexported fields
}
func NewCachedDBTransactionLogIO ¶
func NewCachedDBTransactionLogIO(be DBTransactionLogIO) *CachedDBTransactionLogIO
func (*CachedDBTransactionLogIO) AppendTransaction ¶
func (txio *CachedDBTransactionLogIO) AppendTransaction(tx DBTransaction) error
func (*CachedDBTransactionLogIO) QueryCachedTransactions ¶
func (txio *CachedDBTransactionLogIO) QueryCachedTransactions(minID TxID) ([]DBTransaction, error)
func (*CachedDBTransactionLogIO) QueryTransactions ¶
func (txio *CachedDBTransactionLogIO) QueryTransactions(minID TxID) ([]DBTransaction, error)
type CreateNodeOp ¶
type CreateNodeOp struct { OpMeta `json:",inline"` NodeLock `json:"nodelock"` OrigPath string `json:"origpath"` Type `json:"type"` ParentID ID `json:"parent_id"` // only valid for DirNodeT Uid uint32 `json:"uid"` Gid uint32 `json:"gid"` PermMode uint16 `json:"perm_mode"` ModifiedT time.Time `json:"modified_t"` }
func (*CreateNodeOp) Apply ¶
func (op *CreateNodeOp) Apply(s *DBState) error
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewDB ¶
func NewDB(snapshotIO DBStateSnapshotIO, txLogIO DBTransactionLogIO, readOnly bool) (*DB, error)
func NewEmptyDB ¶
func NewEmptyDB(snapshotIO DBStateSnapshotIO, txLogIO DBTransactionLogIO) (*DB, error)
func (*DB) ApplyTransaction ¶
func (db *DB) ApplyTransaction(tx DBTransaction) (TxID, error)
func (*DB) GetStats ¶
func (db *DB) GetStats() DBServiceStats
func (*DB) QueryRecentTransactions ¶
func (db *DB) QueryRecentTransactions() ([]DBTransaction, error)
func (*DB) RestoreVersion ¶
func (*DB) TriggerSync ¶
func (*DB) UnlockNode ¶
type DBHandler ¶
type DBHandler interface { // ApplyTransaction applies DBTransaction to db.state, and returns applied transaction's TxID. If it fails to apply the transaction, it rollbacks intermediate state and returns error. ApplyTransaction(tx DBTransaction) (TxID, error) // QueryNode returns read-only snapshot of INode id, with a lock if specified QueryNode(id ID, tryLock bool) (NodeView, NodeLock, error) // FIXME: this should actually take NodeLock for renew ticket operation LockNode(id ID) (NodeLock, error) UnlockNode(nlock NodeLock) error }
type DBOperation ¶
func DecodeDBOperationsFromJson ¶
func DecodeDBOperationsFromJson(jsonb []byte) ([]DBOperation, error)
func ResolveDBOperations ¶
func ResolveDBOperations(msgs []*json.RawMessage) ([]DBOperation, error)
type DBService ¶
type DBService struct {
// contains filtered or unexported fields
}
DBService serializes requests to DBHandler
func NewDBService ¶
func (*DBService) ApplyTransaction ¶
func (srv *DBService) ApplyTransaction(tx DBTransaction) (txid TxID, err error)
func (*DBService) GetStats ¶
func (srv *DBService) GetStats() (stats DBServiceStats)
func (*DBService) QueryRecentTransactions ¶
func (srv *DBService) QueryRecentTransactions() (txs []DBTransaction, err error)
func (*DBService) TriggerSync ¶
func (*DBService) UnlockNode ¶
type DBServiceStats ¶
type DBServiceStatsProvider ¶
type DBServiceStatsProvider interface {
GetStats() DBServiceStats
}
type DBState ¶
type DBState struct {
// contains filtered or unexported fields
}
func NewDBState ¶
func NewDBState() *DBState
type DBStateSnapshotIO ¶
type DBTransaction ¶
type DBTransaction struct { TxID `json:"txid"` Ops []DBOperation `json:"ops"` }
func ResolveDBTransaction ¶
func ResolveDBTransaction(utx UnresolvedDBTransaction) (DBTransaction, error)
func (DBTransaction) String ¶
func (tx DBTransaction) String() string
type DBTransactionLogIO ¶
type DBTransactionLogIO interface { AppendTransaction(tx DBTransaction) error QueryTransactions(minID TxID) ([]DBTransaction, error) }
type DirNodeView ¶
type DirNodeView struct { INodeCommon `json:",inline"` ParentID ID `json:"parent_id"` Entries map[string]ID `json:"entries"` }
func (DirNodeView) GetType ¶
func (v DirNodeView) GetType() Type
type FileNode ¶
type FileNode struct { INodeCommon Size int64 Chunks []FileChunk }
type FileNodeView ¶
type FileNodeView struct { INodeCommon `json:",inline"` Size int64 `json:"size"` Chunks []FileChunk `json:"chunks"` }
func (FileNodeView) GetType ¶
func (v FileNodeView) GetType() Type
type GobEncodable ¶
type HardLinkOp ¶
type HardLinkOp struct { OpMeta `json:",inline"` NodeLock `json:"nodelock"` Name string `json:"name"` TargetID ID `json:"targetid"` }
func (*HardLinkOp) Apply ¶
func (op *HardLinkOp) Apply(s *DBState) error
type INodeCommon ¶
type INodeCommon struct { ID `json:"id"` // OrigPath contains filepath passed to first create and does not necessary follow "rename" operations. // To be used for recovery/debug purposes only OrigPath string `json:"orig_path"` Uid uint32 `json:"uid"` Gid uint32 `json:"gid"` PermMode uint16 `json:"perm_mode"` ModifiedT time.Time `json:"modified_t"` }
func (INodeCommon) GetGid ¶
func (n INodeCommon) GetGid() uint32
func (INodeCommon) GetID ¶
func (n INodeCommon) GetID() ID
func (INodeCommon) GetModifiedT ¶
func (n INodeCommon) GetModifiedT() time.Time
func (INodeCommon) GetOrigPath ¶
func (n INodeCommon) GetOrigPath() string
func (INodeCommon) GetPermMode ¶
func (n INodeCommon) GetPermMode() uint16
func (INodeCommon) GetUid ¶
func (n INodeCommon) GetUid() uint32
type InitializeFileSystemOp ¶
type InitializeFileSystemOp struct {
OpMeta `json:",inline"`
}
func (*InitializeFileSystemOp) Apply ¶
func (op *InitializeFileSystemOp) Apply(s *DBState) error
type QueryRecentTransactionsProvider ¶
type QueryRecentTransactionsProvider interface {
QueryRecentTransactions() ([]DBTransaction, error)
}
type RemoveOp ¶
type RenameOp ¶
type SimpleDBStateSnapshotIO ¶
func NewSimpleDBStateSnapshotIO ¶
func NewSimpleDBStateSnapshotIO() *SimpleDBStateSnapshotIO
func (*SimpleDBStateSnapshotIO) ImplName ¶
func (*SimpleDBStateSnapshotIO) ImplName() string
func (*SimpleDBStateSnapshotIO) RestoreSnapshot ¶
func (io *SimpleDBStateSnapshotIO) RestoreSnapshot() (*DBState, error)
func (*SimpleDBStateSnapshotIO) SaveSnapshot ¶
func (io *SimpleDBStateSnapshotIO) SaveSnapshot(s *DBState) <-chan error
type SimpleDBTransactionLogIO ¶
type SimpleDBTransactionLogIO struct {
// contains filtered or unexported fields
}
func NewSimpleDBTransactionLogIO ¶
func NewSimpleDBTransactionLogIO() *SimpleDBTransactionLogIO
func (*SimpleDBTransactionLogIO) AppendTransaction ¶
func (io *SimpleDBTransactionLogIO) AppendTransaction(tx DBTransaction) error
func (*SimpleDBTransactionLogIO) QueryTransactions ¶
func (io *SimpleDBTransactionLogIO) QueryTransactions(minID TxID) ([]DBTransaction, error)
func (*SimpleDBTransactionLogIO) SetReadOnly ¶
func (io *SimpleDBTransactionLogIO) SetReadOnly(b bool)
type TriggerSyncer ¶
type TriggerSyncer interface {
TriggerSync() <-chan error
}
type UnresolvedDBTransaction ¶
type UnresolvedDBTransaction struct { TxID `json:"txid"` Ops []*json.RawMessage }
type UpdateChunksOp ¶
type UpdateChunksOp struct { OpMeta `json:",inline"` NodeLock `json:"nodelock"` Chunks []FileChunk `json:"chunks"` }
func (*UpdateChunksOp) Apply ¶
func (op *UpdateChunksOp) Apply(s *DBState) error
type UpdateGidOp ¶
func (*UpdateGidOp) Apply ¶
func (op *UpdateGidOp) Apply(s *DBState) error
type UpdateModifiedTOp ¶
type UpdateModifiedTOp struct { OpMeta `json:",inline"` ID `json:"id"` ModifiedT time.Time `json:"modified_t"` }
func (*UpdateModifiedTOp) Apply ¶
func (op *UpdateModifiedTOp) Apply(s *DBState) error
type UpdatePermModeOp ¶
type UpdatePermModeOp struct { OpMeta `json:",inline"` ID `json:"id"` PermMode uint16 `json:"perm_mode"` }
func (*UpdatePermModeOp) Apply ¶
func (op *UpdatePermModeOp) Apply(s *DBState) error
type UpdateSizeOp ¶
type UpdateSizeOp struct { OpMeta `json:",inline"` NodeLock `json:"nodelock"` Size int64 `json:"size"` }
func (*UpdateSizeOp) Apply ¶
func (op *UpdateSizeOp) Apply(s *DBState) error
type UpdateUidOp ¶
func (*UpdateUidOp) Apply ¶
func (op *UpdateUidOp) Apply(s *DBState) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.