Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateUUID() string
- type Base
- type BaseFactoryFunc
- type Change
- type ChangeFactoryFunc
- type CreateOption
- type Database
- type FileDatabase
- func (db *FileDatabase) Apply(change Change, payloads ...Payload) error
- func (db *FileDatabase) ChangesCount() int
- func (db *FileDatabase) Close() error
- func (db *FileDatabase) Header() Header
- func (db *FileDatabase) OpenPayload(id string) (io.ReadCloser, error)
- func (db *FileDatabase) State() State
- type FileDeck
- func (d *FileDeck) Close() error
- func (d *FileDeck) Create(path string, opts ...CreateOption) error
- func (d *FileDeck) Delete(path string) error
- func (d *FileDeck) Len() int
- func (d *FileDeck) ReadHeader(path string) (Header, error)
- func (d *FileDeck) WithOpen(path string, opts []OpenOption, fn func(*FileDatabase) error) error
- type Header
- func (h Header) Get(key string) string
- func (h Header) GetBytes(key string, defaultValue []byte) []byte
- func (h Header) GetUInt64(key string, defaultValue uint64) uint64
- func (h Header) Has(key string) bool
- func (h Header) Set(key, value string)
- func (h Header) SetBytes(key string, value []byte)
- func (h Header) SetUInt64(key string, value uint64)
- func (h Header) WriteTo(w io.Writer) (int64, error)
- type KeyFunc
- type Model
- func (m *Model) CreateDatabase(w io.Writer, opts ...CreateOption) (*Database, error)
- func (m *Model) CreateFileDatabase(path string, opts ...CreateOption) (*FileDatabase, error)
- func (m *Model) NewFileDeck(openDatabaseLimit int) (*FileDeck, error)
- func (m *Model) OpenDatabase(rw io.ReadWriter, opts ...OpenOption) (*Database, error)
- func (m *Model) OpenFileDatabase(path string, opts ...OpenOption) (*FileDatabase, error)
- func (m *Model) ReadFileDatabaseHeader(path string) (Header, error)
- func (m *Model) SpliceDatabase(w io.Writer, r io.Reader, opts ...SpliceOption) ([]string, error)
- func (m *Model) SpliceFileDatabase(path string, opts ...SpliceOption) error
- type OpenOption
- type Payload
- type PayloadContainer
- type SpliceOption
- type State
- type StateFactoryFunc
Constants ¶
View Source
const ( FileNameDatabase = "db" FileNameNewDatabase = "db.new" FilePrefixPayload = "payload-" HeaderNonce = "Nonce" )
Variables ¶
View Source
var ( ErrDatabaseMissing = errors.New("database missing") ErrDatabaseExists = errors.New("database exists") )
View Source
var ( ErrPayloadIDAlreadyExists = errors.New("payload id already exists") ErrPayloadMissing = errors.New("payload missing") )
View Source
var (
ErrUnknownType = errors.New("unknown type")
)
Functions ¶
func GenerateUUID ¶
func GenerateUUID() string
Types ¶
type BaseFactoryFunc ¶
func PrototypeBaseFactory ¶
func PrototypeBaseFactory(prototype Base) BaseFactoryFunc
type ChangeFactoryFunc ¶
func PrototypeChangeFactory ¶
func PrototypeChangeFactory(prototypes ...Change) ChangeFactoryFunc
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 WithHeader ¶
func WithHeader(value Header) CreateOption
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) ChangesCount ¶
type FileDatabase ¶
type FileDatabase struct {
// contains filtered or unexported fields
}
func (*FileDatabase) Apply ¶
func (db *FileDatabase) Apply(change Change, payloads ...Payload) error
func (*FileDatabase) ChangesCount ¶
func (db *FileDatabase) ChangesCount() int
func (*FileDatabase) Close ¶
func (db *FileDatabase) Close() error
func (*FileDatabase) Header ¶
func (db *FileDatabase) Header() Header
func (*FileDatabase) OpenPayload ¶
func (db *FileDatabase) OpenPayload(id string) (io.ReadCloser, error)
func (*FileDatabase) State ¶
func (db *FileDatabase) State() State
type FileDeck ¶
type FileDeck struct {
// contains filtered or unexported fields
}
func (*FileDeck) WithOpen ¶
func (d *FileDeck) WithOpen(path string, opts []OpenOption, fn func(*FileDatabase) error) error
type Header ¶
type Header textproto.MIMEHeader
type KeyFunc ¶
func StaticKeyFunc ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModel ¶
func NewModel(bf BaseFactoryFunc, sf StateFactoryFunc, cf ChangeFactoryFunc) *Model
func (*Model) CreateDatabase ¶
func (*Model) CreateFileDatabase ¶
func (m *Model) CreateFileDatabase(path string, opts ...CreateOption) (*FileDatabase, error)
func (*Model) OpenDatabase ¶
func (m *Model) OpenDatabase(rw io.ReadWriter, opts ...OpenOption) (*Database, error)
func (*Model) OpenFileDatabase ¶
func (m *Model) OpenFileDatabase(path string, opts ...OpenOption) (*FileDatabase, error)
func (*Model) ReadFileDatabaseHeader ¶
func (*Model) SpliceDatabase ¶
func (*Model) SpliceFileDatabase ¶
func (m *Model) SpliceFileDatabase(path string, opts ...SpliceOption) error
type OpenOption ¶
type OpenOption func(*openOptions)
func WithOpenKey ¶
func WithOpenKey(value []byte) OpenOption
func WithOpenKeyFunc ¶
func WithOpenKeyFunc(value KeyFunc) OpenOption
type PayloadContainer ¶
type PayloadContainer interface {
PayloadIDs() []string
}
type SpliceOption ¶
type SpliceOption func(*spliceOptions)
func WithConsumeChanges ¶
func WithConsumeChanges(value int) 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
Source Files ¶
Click to show internal directories.
Click to hide internal directories.