metadata

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 7 Imported by: 0

README

metadata

type Metadata
type Metadata struct {
	KeeperType   string                   `json:"type"`
	Created      time.Time                `json:"created,omitempty"`
	LastOpened   time.Time                `json:"last_opened,omitempty"`
	KnownStores  []string                 `json:"stores,omitempty"`
	Backups      map[string]models.Backup `json:"backups,omitempty"`
	Extra        map[string]interface{}   `json:"extra,omitempty"`
	DefStoreOpts any                      `json:"default_store_opts,omitempty"`
}

Metadata is a struct that holds the metadata for a [Keeper]'s DB. This is critical for migrating data between [Keeper]s. The only absolute requirement is that the [Type] field is set.

func NewMeta
func NewMeta(keeperType string) *Metadata
func NewMetaFile
func NewMetaFile(keeperType, path string) (*Metadata, error)
func OpenMetaFile
func OpenMetaFile(path string) (*Metadata, error)
func (*Metadata) AddStore
func (m *Metadata) AddStore(name string)
func (*Metadata) Close
func (m *Metadata) Close() error

Close calls [Sync] and then closes the metadata writer, if it is an io.Closer.

func (*Metadata) Ping
func (m *Metadata) Ping()
func (*Metadata) RemoveStore
func (m *Metadata) RemoveStore(name string)
func (*Metadata) Sync
func (m *Metadata) Sync() error

Sync writes the metadata to the designated [io.Writer]. If there is no writer, it will create "meta.json" at m.path.

func (*Metadata) Timestamp
func (m *Metadata) Timestamp() time.Time
func (*Metadata) Type
func (m *Metadata) Type() string
func (*Metadata) WithBackups
func (m *Metadata) WithBackups(backups ...models.Backup) *Metadata
func (*Metadata) WithCreated
func (m *Metadata) WithCreated(created time.Time) *Metadata
func (*Metadata) WithDefaultStoreOpts
func (m *Metadata) WithDefaultStoreOpts(opts any) *Metadata
func (*Metadata) WithExtra
func (m *Metadata) WithExtra(extra map[string]interface{}) *Metadata
func (*Metadata) WithLastOpened
func (m *Metadata) WithLastOpened(lastOpened time.Time) *Metadata
func (*Metadata) WithStores
func (m *Metadata) WithStores(stores ...string) *Metadata
func (*Metadata) WithWriter
func (m *Metadata) WithWriter(w io.WriteSeeker) *Metadata

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotCanonicalMetadata = errors.New("metadata is of a different type, cannot cast")

Functions

func IsCanonicalMetadata added in v0.4.2

func IsCanonicalMetadata(m models.Metadata) bool

Types

type KeeperType added in v0.4.2

type KeeperType string

type Metadata

type Metadata struct {
	KeeperType   string                 `json:"type"`
	Created      time.Time              `json:"created,omitempty"`
	LastOpened   time.Time              `json:"last_opened,omitempty"`
	KnownStores  []string               `json:"stores,omitempty"`
	Backups      map[string]any         `json:"backups,omitempty"`
	Extra        map[string]interface{} `json:"extra,omitempty"`
	DefStoreOpts any                    `json:"default_store_opts,omitempty"`
	// contains filtered or unexported fields
}

Metadata is a struct that holds the metadata for a [Keeper]'s DB. This is critical for migrating data between [Keeper]s. The only absolute requirement is that the [Type] field is set.

func CastToMetadata added in v0.4.2

func CastToMetadata(m models.Metadata) (*Metadata, error)

func LoadMeta added in v0.4.2

func LoadMeta(data []byte) (*Metadata, error)

func NewMeta

func NewMeta(keeperType KeeperType) *Metadata

func NewMetaFile

func NewMetaFile(keeperType, path string) (*Metadata, error)

func OpenMetaFile

func OpenMetaFile(path string) (*Metadata, error)

func (*Metadata) AddStore

func (m *Metadata) AddStore(name string)

func (*Metadata) Close

func (m *Metadata) Close() error

Close calls [Sync] and then closes the metadata writer, if it is an io.Closer.

func (*Metadata) Ping

func (m *Metadata) Ping()

func (*Metadata) RemoveStore

func (m *Metadata) RemoveStore(name string)

func (*Metadata) Sync

func (m *Metadata) Sync() error

Sync writes the metadata to the designated io.Writer. If there is no writer, it will create "meta.json" at m.path.

func (*Metadata) Timestamp

func (m *Metadata) Timestamp() time.Time

func (*Metadata) Type

func (m *Metadata) Type() string

func (*Metadata) WithBackups

func (m *Metadata) WithBackups(backups ...models.Backup) *Metadata

func (*Metadata) WithCreated

func (m *Metadata) WithCreated(created time.Time) *Metadata

func (*Metadata) WithDefaultStoreOpts added in v0.4.2

func (m *Metadata) WithDefaultStoreOpts(opts any) *Metadata

func (*Metadata) WithExtra added in v0.4.2

func (m *Metadata) WithExtra(extra map[string]interface{}) *Metadata

func (*Metadata) WithLastOpened

func (m *Metadata) WithLastOpened(lastOpened time.Time) *Metadata

func (*Metadata) WithStores

func (m *Metadata) WithStores(stores ...string) *Metadata

func (*Metadata) WithWriter

func (m *Metadata) WithWriter(w io.WriteSeeker) *Metadata

type Placeholder added in v0.4.2

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

func NewPlaceholder added in v0.4.2

func NewPlaceholder(name string) Placeholder

func (Placeholder) Timestamp added in v0.4.2

func (d Placeholder) Timestamp() time.Time

func (Placeholder) Type added in v0.4.2

func (d Placeholder) Type() string

Jump to

Keyboard shortcuts

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