storage

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MPL-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CRUDExecutor

type CRUDExecutor interface {
	Query(ctx context.Context, query string, args ...any) (QueryResult, *schema.Diagnostics)

	Exec(ctx context.Context, query string, args ...any) *schema.Diagnostics

	Insert(ctx context.Context, t *schema.Table, rowSet *schema.Rows) *schema.Diagnostics
}

type Closeable

type Closeable interface {
	Close() *schema.Diagnostics
}

type ColumnValueConvertorFactory

type ColumnValueConvertorFactory interface {
	NewColumnValueConvertor() schema.ColumnValueConvertor
}

type CreateStorageOptions

type CreateStorageOptions interface {
	ToJsonString() (string, error)
	FromJsonString(jsonString string) error
}

CreateStorageOptions Different storage media may have different options that can be passed when creating a database

type KeyValueExecutor added in v0.0.13

type KeyValueExecutor interface {
	SetKey(ctx context.Context, key, value string) *schema.Diagnostics

	GetValue(ctx context.Context, key string) (string, *schema.Diagnostics)

	DeleteKey(ctx context.Context, key string) *schema.Diagnostics

	ListKey(ctx context.Context) (*schema.Rows, *schema.Diagnostics)
}

type Lock added in v0.0.15

type Lock interface {
	Lock(ctx context.Context, lockId, ownerId string) error
	UnLock(ctx context.Context, lockId, ownerId string) error
}

type NamespaceAdmin

type NamespaceAdmin interface {
	NamespaceList(ctx context.Context) ([]string, *schema.Diagnostics)
	NamespaceCreate(ctx context.Context, namespace string) *schema.Diagnostics
	NamespaceDrop(ctx context.Context, namespace string) *schema.Diagnostics
}

type QueryResult

type QueryResult interface {

	// Next Attempts to switch to the next result and returns whether the switch was successful
	Next() bool

	// Decode the current ROW as an item, which should be the address of a struct
	Decode(item any) *schema.Diagnostics

	// Values Returns the value of each column of the current ROW for use when there is no structure
	Values() ([]any, *schema.Diagnostics)

	// ValuesMap Returns the value of each column in the current ROW, with the column name as key and the column value as value
	ValuesMap() (map[string]any, *schema.Diagnostics)

	// ReadRows Returns the result set as a RowSet
	// @params rowLimit: Read the specified number of rows. If the number of rows is limited to a negative number, all reads at once are unrestricted
	ReadRows(rowLimit int) (*schema.Rows, *schema.Diagnostics)

	// GetColumnNames Gets the names of all the columns queried
	GetColumnNames() []string

	// Closeable The query result can be disabled. Most storage media need to shut down resources after reading the query result
	Closeable

	// GetRawQueryResult Original query results are allowed, but are not recommended
	GetRawQueryResult() any
}

QueryResult Represents the result of a query

type Storage

type Storage interface {

	// NamespaceAdmin Be able to manage namespaces, where tables are stored
	NamespaceAdmin

	// TableAdmin Be able to manage tables for the underlying storage
	TableAdmin

	// CRUDExecutor You can perform operations such as adding, deleting, modifying and querying on storage media
	CRUDExecutor

	// TransactionExecutor Transactional operations can be performed on storage media
	TransactionExecutor

	// Closeable Storage media can be turned off
	Closeable

	// ColumnValueConvertorFactory This storage medium can convert incoming data to its own storage medium's corresponding type
	ColumnValueConvertorFactory

	// GetStorageConnection Allows the connection to a specific Storage to be exposed upward, which is used if you want to work directly with the underlying Storage
	GetStorageConnection() any

	UseClientMeta

	KeyValueExecutor

	Lock

	TimeProvider
}

Storage Represents a storage medium, which may be implemented in many different ways

type TableAdmin

type TableAdmin interface {
	TableCreate(ctx context.Context, table *schema.Table) *schema.Diagnostics

	TablesCreate(ctx context.Context, tables []*schema.Table) *schema.Diagnostics

	TableDrop(ctx context.Context, table *schema.Table) *schema.Diagnostics

	TablesDrop(ctx context.Context, tables []*schema.Table) *schema.Diagnostics

	TableList(ctx context.Context, namespace string) ([]*schema.Table, *schema.Diagnostics)
}

type TimeProvider added in v0.0.20

type TimeProvider interface {

	// GetTime In a distributed system, use a uniform date
	GetTime(ctx context.Context) (time.Time, error)
}

TimeProvider Acquired time

type TransactionExecutor

type TransactionExecutor interface {
	Begin(ctx context.Context) (TransactionExecutor, *schema.Diagnostics)
	Rollback(ctx context.Context) *schema.Diagnostics
	Commit(ctx context.Context) *schema.Diagnostics
}

type UseClientMeta

type UseClientMeta interface {
	SetClientMeta(clientMeta *schema.ClientMeta)
}

Directories

Path Synopsis
database_storage

Jump to

Keyboard shortcuts

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