file

package
v2.0.0-...-5024b2a Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileNameMeta    = "meta"
	FileNameBase    = "base"
	FileNameLog     = "log"
	FileNameNewMeta = "meta.new"
	FileNameNewBase = "base.new"
	FileNameNewLog  = "log.new"

	FilePrefixPayload = "payload-"
)
View Source
const (
	MetaHeaderCryptSettings = "Crypt-Settings"

	DefaultCryptSettings = "$argon2id$v=19$m=65536,t=2,p=4$"
)
View Source
const (
	MetaFieldNonce = "Nonce"
)

Variables

View Source
var (
	ErrMissing    = errors.New("missing")
	ErrExisting   = errors.New("existing")
	ErrInvalidKey = errors.New("invalid key")
)
View Source
var (
	ErrPayloadIDAlreadyExists = errors.New("payload id already exists")
	ErrPayloadMissing         = errors.New("payload missing")
)

Functions

func ReadLogLen

func ReadLogLen(path string) (int, error)

func SpliceDatabase

func SpliceDatabase[
	B tapedb.Base,
	S tapedb.State,
	F tapedb.Factory[B, S],
](f F, path string, opts ...SpliceOption) error

func WriteMeta

func WriteMeta(w io.Writer, meta Meta) error

func WriteMetaFile

func WriteMetaFile(path string, meta Meta) error

Types

type CreateOption

type CreateOption func(*createOptions)

func WithCreateKey

func WithCreateKey(value []byte) CreateOption

func WithCreateKeyFunc

func WithCreateKeyFunc(value KeyFunc) CreateOption

func WithDirectoryMode

func WithDirectoryMode(value fs.FileMode) CreateOption

func WithFileMode

func WithFileMode(value fs.FileMode) CreateOption

func WithMeta

func WithMeta(value Meta) CreateOption

type Database

type Database[B tapedb.Base, S tapedb.State] struct {
	// contains filtered or unexported fields
}

func CreateDatabase

func CreateDatabase[
	B tapedb.Base,
	S tapedb.State,
	F tapedb.Factory[B, S],
](
	f F,
	path string,
	opts ...CreateOption,
) (*Database[B, S], error)

func OpenDatabase

func OpenDatabase[
	B tapedb.Base,
	S tapedb.State,
	F tapedb.Factory[B, S],
](
	f F,
	path string,
	opts ...OpenOption,
) (*Database[B, S], error)

func (*Database[B, S]) Apply

func (db *Database[B, S]) Apply(change tapedb.Change, payloads ...Payload) error

func (*Database[B, S]) Base

func (db *Database[B, S]) Base() B

func (*Database[B, S]) Close

func (db *Database[B, S]) Close() error

func (*Database[B, S]) Key

func (db *Database[B, S]) Key() []byte

func (*Database[B, S]) LogLen

func (db *Database[B, S]) LogLen() int

func (*Database[B, S]) Meta

func (db *Database[B, S]) Meta() Meta

func (*Database[B, S]) OpenPayload

func (db *Database[B, S]) OpenPayload(id string) (io.ReadCloser, error)

func (*Database[B, S]) SetMeta

func (db *Database[B, S]) SetMeta(meta Meta) error

func (*Database[B, S]) StatPayload

func (db *Database[B, S]) StatPayload(id string) (fs.FileInfo, error)

func (*Database[B, S]) State

func (db *Database[B, S]) State() S

type Deck

type Deck[
	B tapedb.Base,
	S tapedb.State,
	F tapedb.Factory[B, S],
] struct {
	// contains filtered or unexported fields
}

func NewDeck

func NewDeck[
	B tapedb.Base,
	S tapedb.State,
	F tapedb.Factory[B, S],
](openDatabaseLimit int) (*Deck[B, S, F], error)

func (*Deck[B, S, F]) Close

func (d *Deck[B, S, F]) Close() error

func (*Deck[B, S, F]) Create

func (d *Deck[B, S, F]) Create(f F, path string, opts ...CreateOption) error

func (*Deck[B, S, F]) Delete

func (d *Deck[B, S, F]) Delete(path string) error

func (*Deck[B, S, F]) Len

func (d *Deck[B, S, F]) Len() int

func (*Deck[B, S, F]) LogLen

func (d *Deck[B, S, F]) LogLen(path string) (int, error)

func (*Deck[B, S, F]) Meta

func (d *Deck[B, S, F]) Meta(path string) (Meta, error)

func (*Deck[B, S, F]) Open

func (d *Deck[B, S, F]) Open(f F, path string, opts []OpenOption) (*Database[B, S], func(), error)

func (*Deck[B, S, F]) SetMeta

func (d *Deck[B, S, F]) SetMeta(path string, meta Meta) error

func (*Deck[B, S, F]) Splice

func (d *Deck[B, S, F]) Splice(f F, path string, opts ...SpliceOption) error

func (*Deck[B, S, F]) WithOpen

func (d *Deck[B, S, F]) WithOpen(f F, path string, opts []OpenOption, fn func(*Database[B, S]) error) error

type KeyFunc

type KeyFunc func(Meta) ([]byte, error)

func DeriveKeyFrom

func DeriveKeyFrom(password, defaultCryptSettings string) KeyFunc

func StaticKeyFunc

func StaticKeyFunc(value []byte) KeyFunc

type Meta

type Meta textproto.MIMEHeader

func ReadMeta

func ReadMeta(r io.Reader) (Meta, error)

func ReadMetaFile

func ReadMetaFile(path string) (Meta, error)

func (Meta) Get

func (m Meta) Get(key string) string

func (Meta) GetBytes

func (m Meta) GetBytes(key string, defaultValue []byte) []byte

func (Meta) GetUInt64

func (m Meta) GetUInt64(key string, defaultValue uint64) uint64

func (Meta) Has

func (m Meta) Has(key string) bool

func (Meta) Set

func (m Meta) Set(key, value string)

func (Meta) SetBytes

func (m Meta) SetBytes(key string, value []byte)

func (Meta) SetUInt64

func (m Meta) SetUInt64(key string, value uint64)

func (Meta) WriteTo

func (m Meta) WriteTo(w io.Writer) (int64, error)

type OpenOption

type OpenOption func(*openOptions)

func WithOpenKey

func WithOpenKey(value []byte) OpenOption

func WithOpenKeyFunc

func WithOpenKeyFunc(value KeyFunc) OpenOption

type Payload

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

func NewPayload

func NewPayload(id string, r io.Reader) Payload

func (*Payload) ID

func (p *Payload) ID() string

type PayloadContainer

type PayloadContainer interface {
	PayloadIDs() []string
}

type RebaseChangeSelectFunc

type RebaseChangeSelectFunc func(tapedb.Change, int) (bool, error)

func CountRebaseChangeSelectFunc

func CountRebaseChangeSelectFunc(count int) RebaseChangeSelectFunc

func StaticRebaseChangeSelectFunc

func StaticRebaseChangeSelectFunc(value bool) RebaseChangeSelectFunc

type SpliceOption

type SpliceOption func(*spliceOptions)

func WithRebaseChangeCount

func WithRebaseChangeCount(value int) SpliceOption

func WithRebaseChangeSelectFunc

func WithRebaseChangeSelectFunc(value RebaseChangeSelectFunc) SpliceOption

func WithSourceKey

func WithSourceKey(value []byte) SpliceOption

func WithSourceKeyFunc

func WithSourceKeyFunc(value KeyFunc) SpliceOption

func WithTargetKey

func WithTargetKey(value []byte) SpliceOption

func WithTargetKeyFunc

func WithTargetKeyFunc(value KeyFunc) SpliceOption

Jump to

Keyboard shortcuts

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