istorage

package
v0.0.0-...-3a40b8b Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxSafeNameLength = 48 - 5 // max Cassandra keypsace name len - 5 symbols for prefix

)

Variables

View Source
var (
	ErrStorageAlreadyExists = errors.New("storage already exists")
	ErrStorageDoesNotExist  = errors.New("storage does not exist")
	ErrNoSafeAppName        = errors.New("no safe app name")
)
View Source
var (
	SysMetaSafeName = SafeAppName{/* contains filtered or unexported fields */}
)

Functions

func TechnologyCompatibilityKit

func TechnologyCompatibilityKit(t *testing.T, storageFactory IAppStorageFactory)

TechnologyCompatibilityKit test suit

func TechnologyCompatibilityKit_Storage

func TechnologyCompatibilityKit_Storage(t *testing.T, storage IAppStorage)

need to test e.g. istoragecache

Types

type AppStorageDesc

type AppStorageDesc struct {
	SafeName SafeAppName
	Status   AppStorageStatus
	Error    string `json:",omitempty"`
}

type AppStorageStatus

type AppStorageStatus int
const (
	AppStorageStatus_Pending AppStorageStatus = iota
	AppStorageStatus_Done
)

type BatchItem

type BatchItem struct {
	PKey  []byte
	CCols []byte
	Value []byte
}

type GetBatchItem

type GetBatchItem struct {
	CCols []byte
	Ok    bool
	Data  *[]byte
}

type IAppStorage

type IAppStorage interface {
	// cCols - clustering columns
	// len(cCols) may be 0 (nil or empty array)
	// Clustering columns MUST be filled from left to right
	// Example: PRIMARY KEY(wsid, qname_id, id)
	//   Clusterting columns: qname_id, id
	//   qname_id bytes must be written first, then id bytes
	// @ConcurrentAccess
	Put(pKey []byte, cCols []byte, value []byte) (err error)

	PutBatch(items []BatchItem) (err error)

	// len(cCols) may be 0, in this case the record which was written with zero len(cCols) will be returned
	// ok == false means that viewrecord does not exist
	// @ConcurrentAccess
	Get(pKey []byte, cCols []byte, data *[]byte) (ok bool, err error)

	// get and appends result to items[i].Data
	// items[i].Ok==false means record is not found
	// items[i].Ok & Data are undefined in case of error
	GetBatch(pKey []byte, items []GetBatchItem) (err error)

	// startCCols can be empty (nil or zero len), in this case reads from start of partition.
	// finishCCols can be empty (nil or zero len) too. In this case reads to the end of partition
	// @ConcurrentAccess
	Read(ctx context.Context, pKey []byte, startCCols, finishCCols []byte, cb ReadCallback) (err error)
}

type IAppStorageFactory

type IAppStorageFactory interface {
	// returns IAppStorage for an existing storage
	// returns ErrStorageNotFound
	AppStorage(appName SafeAppName) (storage IAppStorage, err error)

	// creates new storage
	// returns ErrStorageExistsAlready
	Init(appName SafeAppName) error
}

implemented by a certain driver

type IAppStorageProvider

type IAppStorageProvider interface {
	// converts AppQname to string and calls internal IAppStorageFactory.AppStorage
	// storage for a brand new app is queried and failed to create the storage for it -> storage init error is persisted and returned until admin is handle with that incident
	// could return ErrStorageNotFound, ErrStorageExistsAlready
	AppStorage(appName istructs.AppQName) (structs IAppStorage, err error)
}

Same as IAppStructsProvider, called per request or frequently inside services implemented in istorageimpl

type IStorageDelaySetter

type IStorageDelaySetter interface {
	SetTestDelayGet(time.Duration)
	SetTestDelayPut(time.Duration)
}

used in tests only

type ReadCallback

type ReadCallback func(ccols []byte, viewRecord []byte) (err error)

ccols and viewRecord are temporary internal values, must NOT be changed

type SafeAppName

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

func NewSafeAppName

func NewSafeAppName(appQName istructs.AppQName, uniqueFunc func(name string) (bool, error)) (san SafeAppName, err error)

func NewTestSafeName

func NewTestSafeName(appName string) SafeAppName

TODO: remove it

func (SafeAppName) MarshalJSON

func (san SafeAppName) MarshalJSON() ([]byte, error)

nolint

func (SafeAppName) MarshalText

func (san SafeAppName) MarshalText() (text []byte, err error)

need to marshal map[SafeAppName]any nolint

func (SafeAppName) String

func (san SafeAppName) String() string

func (*SafeAppName) UnmarshalJSON

func (san *SafeAppName) UnmarshalJSON(text []byte) (err error)

func (*SafeAppName) UnmarshalText

func (san *SafeAppName) UnmarshalText(text []byte) error

need to unmarshal map[SafeAppName]any golang json looks on UnmarshalText presence only on unmarshal map[SafeAppName]any. UnmarshalJSON() will be used anyway but no UnmarshalText -> fail to unmarshal map[SafeAppName]any see https://github.com/golang/go/issues/29732

Directories

Path Synopsis
nolint
nolint

Jump to

Keyboard shortcuts

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