Documentation ¶
Index ¶
- Variables
- func LatestVersion(sm Steps) uint64
- func Migrate(s storage.IndexStore, group string, sm Steps) error
- func ValidateVersions(sm Steps) error
- func Version(s storage.Reader, group string) (uint64, error)
- func WithItemDeleteFn(fn ItemDeleteFn) option
- func WithItemUpdaterFn(fn ItemUpdateFn) option
- type ItemDeleteFn
- type ItemUpdateFn
- type StepFn
- type Steps
- type StorageVersionItem
Constants ¶
This section is empty.
Variables ¶
var ErrItemIDShouldntChange = errors.New("item.ID shouldn't be changing after update")
Functions ¶
func LatestVersion ¶
LatestVersion returns latest version from supplied migration steps.
func Migrate ¶
func Migrate(s storage.IndexStore, group string, sm Steps) error
Migrate migrates the storage to the latest version. The steps are separated by groups so different lists of steps can run individually, for example, two groups of migrations that run before and after the storer is initialized.
func ValidateVersions ¶
ValidateVersions checks versions if they are in order n (where n min version value), n+1, n+2, n+3... (all values are increasing orders)
func WithItemDeleteFn ¶
func WithItemDeleteFn(fn ItemDeleteFn) option
WithItemDeleteFn return option with ItemDeleteFn set.
func WithItemUpdaterFn ¶
func WithItemUpdaterFn(fn ItemUpdateFn) option
WithItemUpdaterFn return option with ItemUpdateFn set.
Types ¶
type ItemDeleteFn ¶
ItemDeleteFn is callback function called in migration step to check if Item should be removed in this step.
type ItemUpdateFn ¶
ItemUpdateFn is callback function called in migration step to check if Item should be updated in this step.
type StepFn ¶
type StepFn func() error
StepFn is a function that migrates the storage to the next version
func NewStepOnIndex ¶
func NewStepOnIndex(s storage.BatchStore, query storage.Query, opts ...option) StepFn
NewStepOnIndex creates new migration step with update and/or delete operation. Migration will iterate on all elements selected by query and delete or update items based on supplied callback functions.
func NewStepsChain ¶
NewStepsChain returns new StepFn which combines all supplied StepFn into single StepFn.
type StorageVersionItem ¶
func (*StorageVersionItem) Clone ¶
func (s *StorageVersionItem) Clone() storage.Item
Clone implements the storage.Item interface.
func (*StorageVersionItem) ID ¶
func (s *StorageVersionItem) ID() string
ID implements the storage.Item interface.
func (*StorageVersionItem) Marshal ¶
func (s *StorageVersionItem) Marshal() ([]byte, error)
Marshal implements the storage.Item interface.
func (StorageVersionItem) Namespace ¶
func (s StorageVersionItem) Namespace() string
Namespace implements the storage.Item interface.
func (StorageVersionItem) String ¶
func (s StorageVersionItem) String() string
Clone implements the storage.Item interface.
func (*StorageVersionItem) Unmarshal ¶
func (s *StorageVersionItem) Unmarshal(bytes []byte) error
Unmarshal implements the storage.Item interface.