storage

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Configuration{
	DirPath: "data",
}
View Source
var DefaultMultiStorageConfig = func() *MultiStorageConfiguration {
	return &MultiStorageConfiguration{
		DirPath: []string{"data"},
	}
}

Functions

func StorePolicies

func StorePolicies(policies models.TreePolicies, path string) error

Types

type Configuration

type Configuration struct {
	DirPath string `json:"dir_path"`
}

type Constructor added in v1.3.0

type Constructor func(config *Configuration) Storage

type DryStorage added in v1.3.0

type DryStorage struct {
	DelegatedWriter WriterFunc
}

func InitDryStorage added in v1.3.0

func InitDryStorage(out string, constr Constructor) (*DryStorage, error)

func (*DryStorage) Read added in v1.3.0

func (*DryStorage) Write added in v1.3.0

type FileNameProvider

type FileNameProvider[T any] func(id string, it T) string

type MultiStorage

type MultiStorage struct {
	Storages []Storage
	Config   *MultiStorageConfiguration
}

func InitMultiStorage

func InitMultiStorage(config *MultiStorageConfiguration, constr Constructor) (*MultiStorage, error)

func (*MultiStorage) Read

Read data from all storages and merge them

func (*MultiStorage) String added in v1.1.0

func (m *MultiStorage) String() string

func (*MultiStorage) Write added in v1.1.0

Write for simplicity stores data in first storage only, it is responsibility of the user to move entities to other storages

type MultiStorageConfiguration

type MultiStorageConfiguration struct {
	DirPath []string `json:"dir_path"`
}

type ReadFileOpt

type ReadFileOpt func(opts *ReadFileOpts)

type ReadFileOpts

type ReadFileOpts struct {
}

type ServerStorage added in v1.3.0

type ServerStorage struct {
	Config *Configuration
}

func (*ServerStorage) Read added in v1.3.0

func (*ServerStorage) String added in v1.3.0

func (s *ServerStorage) String() string

func (*ServerStorage) Write added in v1.3.0

type Storage

type Storage interface {
	Write(ctx context.Context, data models.Rfc7396PatchOperation, opts ...api.SourceOpt) error
	Read(ctx context.Context, opts ...api.SourceOpt) (models.Rfc7396PatchOperation, error)
}

func InitServerStorage added in v1.3.0

func InitServerStorage(config *Configuration) Storage

func InitTenantStorage added in v1.3.0

func InitTenantStorage(config *Configuration) Storage

type TenantStorage added in v1.3.0

type TenantStorage struct {
	Config        *Configuration
	ServerStorage Storage
}

func (*TenantStorage) Read added in v1.3.0

func (*TenantStorage) Write added in v1.3.0

type WithID

type WithID[T any] struct {
	ID string `json:"id"`
	// nolint
	Other T `json:",inline,squash"`
}

func NewWithID

func NewWithID[T any](id string, data T) *WithID[T]

type Writer

type Writer[T any] func(name string, it T) error

func RawWriter

func RawWriter(dirPath string) (Writer[[]byte], error)

func YAMLWriter

func YAMLWriter[T any](dirPath string) (Writer[T], error)

type WriterFunc added in v1.3.0

type WriterFunc func(ctx context.Context, data models.Rfc7396PatchOperation, opts ...api.SourceOpt) error

Jump to

Keyboard shortcuts

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