compatibility

package
v0.1.0-beta6-bridge-tmp Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompatibilityCheck

type CompatibilityCheck[T comptypes.CompatibilityComparer[T]] struct {
	RequireStorageContentCompatibility bool
	RuntimeDataGetter                  RuntimeDataGetterFunc[T]
	Storage                            CompatibilityDataStorager[T]
	Logger                             common.Logger
}

CompatibilityCheck is the object that checks the compatibility between the runtime data and the data stored in the storage. It's the implementation of the CompatibilityChecker interface

func NewCompatibilityCheck

func NewCompatibilityCheck[T comptypes.CompatibilityComparer[T]](
	requireStorageContentCompatibility bool,
	runtimeDataGetter RuntimeDataGetterFunc[T],
	storage CompatibilityDataStorager[T]) *CompatibilityCheck[T]

NewCompatibilityCheck creates a new CompatibilityCheck object

func (*CompatibilityCheck[T]) Check

func (s *CompatibilityCheck[T]) Check(ctx context.Context, tx db.Querier) error

Check checks the compatibility between the runtime data and the data stored in the storage

type CompatibilityChecker

type CompatibilityChecker interface {
	Check(ctx context.Context, tx db.Querier) error
}

CompatibilityChecker is the interface that defines the methods to check the compatibility the object CompatibilityCheck[T] implements this interface

type CompatibilityDataStorager

type CompatibilityDataStorager[T any] interface {
	// GetCompatibilityData returns the compatibility data from the storage:
	// true -> if data is stored / false -> if data is not stored yet
	// T -> the data stored
	// error -> if there is an error
	GetCompatibilityData(ctx context.Context, tx db.Querier) (bool, T, error)
	// SetCompatibilityData stores the compatibility data in the storage
	// error -> if there is an error
	SetCompatibilityData(ctx context.Context, tx db.Querier, data T) error
}

CompatibilityDataStorager is the interface that defines the methods to interact with the storage

type KeyValueStorager

type KeyValueStorager interface {
	// InsertValue inserts the value of the key in the storage
	InsertValue(tx db.Querier, owner, key, value string) error
	// GetValue returns the value of the key from the storage
	GetValue(tx db.Querier, owner, key string) (string, error)
}

KeyValueStorager is the interface that defines the methods to interact with the storage as a key/value

type KeyValueToCompatibilityStorage

type KeyValueToCompatibilityStorage[T any] struct {
	KVStorage KeyValueStorager
	OwnerName string
}

KeyValueToCompatibilityStorage is the object that implements the CompatibilityDataStorager interface using a KeyValueStorager object

func NewKeyValueToCompatibilityStorage

func NewKeyValueToCompatibilityStorage[T any](kvStorage KeyValueStorager,
	ownerName string) *KeyValueToCompatibilityStorage[T]

NewKeyValueToCompatibilityStorage creates a new KeyValueToCompatibilityStorage object

func (*KeyValueToCompatibilityStorage[T]) GetCompatibilityData

func (s *KeyValueToCompatibilityStorage[T]) GetCompatibilityData(ctx context.Context,
	tx db.Querier) (bool, T, error)

GetCompatibilityData returns the compatibility data from the storage: true -> if data is stored / false -> if data is not stored yet T -> the data stored error -> if there is an error

func (*KeyValueToCompatibilityStorage[T]) SetCompatibilityData

func (s *KeyValueToCompatibilityStorage[T]) SetCompatibilityData(ctx context.Context, tx db.Querier, data T) error

SetCompatibilityData stores the compatibility data in the storage error -> if there is an error

type RuntimeDataGetterFunc

type RuntimeDataGetterFunc[T comptypes.CompatibilityComparer[T]] func(ctx context.Context) (T, error)

RuntimeDataGetterFunc is a function that returns the runtime data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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