settings

package
v0.111.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_test_settings_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ExampleSettings

type ExampleSettings struct {
	ExampleInt int32            `protobuf:"varint,1,opt,name=example_int,json=exampleInt,proto3" json:"example_int,omitempty"`
	ExampleStr string           `protobuf:"bytes,2,opt,name=example_str,json=exampleStr,proto3" json:"example_str,omitempty"`
	ExampleMap map[string]int32 `` /* 180-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*ExampleSettings) Descriptor deprecated

func (*ExampleSettings) Descriptor() ([]byte, []int)

Deprecated: Use ExampleSettings.ProtoReflect.Descriptor instead.

func (*ExampleSettings) GetExampleInt

func (x *ExampleSettings) GetExampleInt() int32

func (*ExampleSettings) GetExampleMap

func (x *ExampleSettings) GetExampleMap() map[string]int32

func (*ExampleSettings) GetExampleStr

func (x *ExampleSettings) GetExampleStr() string

func (*ExampleSettings) ProtoMessage

func (*ExampleSettings) ProtoMessage()

func (*ExampleSettings) ProtoReflect

func (x *ExampleSettings) ProtoReflect() protoreflect.Message

func (*ExampleSettings) Reset

func (x *ExampleSettings) Reset()

func (*ExampleSettings) String

func (x *ExampleSettings) String() string

type Manager

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

Manager is a key-value store for Graveler repository-level settings. Each setting is stored under a key, and can be any proto.Message. Fetched settings are cached using cache.Cache with a default expiry time of 1 second. Hence, the store is eventually consistent.

func NewManager

func NewManager(refManager graveler.RefManager, store kv.Store, options ...ManagerOption) *Manager

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message) (proto.Message, error)

Get fetches the setting under the given repository and key, and returns the result. The result is eventually consistent: it is not guaranteed to be the most up-to-date setting. The cache expiry period is 1 second. The settingTemplate parameter is used to determine the returned type. The returned checksum represents the version of the setting, and can be used in SaveIf to perform an atomic update.

func (*Manager) GetLatest

func (m *Manager) GetLatest(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message) (proto.Message, string, error)

GetLatest returns the latest setting under the given repository and key, without using the cache. The returned checksum represents the version of the setting, and can be passed to SaveIf for conditional updates.

func (*Manager) Save

func (m *Manager) Save(ctx context.Context, repository *graveler.RepositoryRecord, key string, setting proto.Message) error

Save persists the given setting under the given repository and key. Overrides settings key in KV Store

func (*Manager) SaveIf added in v0.111.0

func (m *Manager) SaveIf(ctx context.Context, repository *graveler.RepositoryRecord, key string, setting proto.Message, lastKnownChecksum string) error

SaveIf persists the given setting under the given repository and key. Overrides settings key in KV Store. The setting is persisted only if the current version of the setting matches the given checksum.

func (*Manager) Update added in v0.70.1

func (m *Manager) Update(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message, update updateFunc) error

Update atomically gets a setting, performs the update function, and persists the setting to the store. The settingTemplate parameter is used to determine the type passed to the update function.

func (*Manager) WithCache added in v0.70.1

func (m *Manager) WithCache(cache cache.Cache)

type ManagerOption

type ManagerOption func(m *Manager)

func WithCache

func WithCache(cache cache.Cache) ManagerOption

Jump to

Keyboard shortcuts

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