db

package
v0.0.0-...-f9144f1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoInterfaceSelect

func DoInterfaceSelect[T any](
	ctx context.Context,
	d *YdbConnector,
	queryBuilder queries.ReadTableQuery,
	readLambda InterfaceFromResultSet[T],
) ([]T, error)

func DoStructSelect

func DoStructSelect[T any](
	ctx context.Context,
	d *YdbConnector,
	queryBuilder queries.ReadTableQuery,
	readLambda StructFromResultSet[T],
) ([]*T, error)

func Int64OrZero

func Int64OrZero(number *int64) int64

func ReadBackupFromResultSet

func ReadBackupFromResultSet(res result.Result) (*types.Backup, error)

func ReadBackupScheduleFromResultSet

func ReadBackupScheduleFromResultSet(res result.Result, withRPOInfo bool) (*types.BackupSchedule, error)

func ReadOperationFromResultSet

func ReadOperationFromResultSet(res result.Result) (types.Operation, error)

func StringOrDefault

func StringOrDefault(str *string, def string) string

func StringOrEmpty

func StringOrEmpty(str *string) string

Types

type DBConnector

type DBConnector interface {
	GetTableClient() table.Client
	SelectBackups(ctx context.Context, queryBuilder queries.ReadTableQuery) (
		[]*types.Backup, error,
	)
	SelectOperations(ctx context.Context, queryBuilder queries.ReadTableQuery) (
		[]types.Operation, error,
	)

	SelectBackupSchedules(ctx context.Context, queryBuilder queries.ReadTableQuery) ([]*types.BackupSchedule, error)
	SelectBackupSchedulesWithRPOInfo(ctx context.Context, queryBuilder queries.ReadTableQuery) (
		[]*types.BackupSchedule, error,
	)
	ActiveOperations(context.Context) ([]types.Operation, error)
	UpdateOperation(context.Context, types.Operation) error
	CreateOperation(context.Context, types.Operation) (string, error)
	CreateBackup(context.Context, types.Backup) (string, error)
	UpdateBackup(context context.Context, id string, backupState string) error
	ExecuteUpsert(ctx context.Context, queryBuilder queries.WriteTableQuery) error
	Close(context.Context)
}

type InterfaceFromResultSet

type InterfaceFromResultSet[T any] func(result result.Result) (T, error)

type MockDBConnector

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

func NewMockDBConnector

func NewMockDBConnector(options ...Option) *MockDBConnector

func (*MockDBConnector) ActiveOperations

func (c *MockDBConnector) ActiveOperations(_ context.Context) (
	[]types.Operation, error,
)

func (*MockDBConnector) Close

func (c *MockDBConnector) Close(_ context.Context)

func (*MockDBConnector) CreateBackup

func (c *MockDBConnector) CreateBackup(_ context.Context, backup types.Backup) (string, error)

func (*MockDBConnector) CreateOperation

func (c *MockDBConnector) CreateOperation(
	_ context.Context, op types.Operation,
) (string, error)

func (*MockDBConnector) ExecuteUpsert

func (c *MockDBConnector) ExecuteUpsert(_ context.Context, queryBuilder queries.WriteTableQuery) error

func (*MockDBConnector) GetBackup

func (c *MockDBConnector) GetBackup(
	_ context.Context, backupID string,
) (types.Backup, error)

func (*MockDBConnector) GetOperation

func (c *MockDBConnector) GetOperation(
	_ context.Context, operationID string,
) (types.Operation, error)

func (*MockDBConnector) GetSchedule

func (c *MockDBConnector) GetSchedule(
	_ context.Context, scheduleID string,
) (types.BackupSchedule, error)

func (*MockDBConnector) GetTableClient

func (c *MockDBConnector) GetTableClient() table.Client

func (*MockDBConnector) SelectBackupSchedules

func (c *MockDBConnector) SelectBackupSchedules(
	_ context.Context, _ queries.ReadTableQuery,
) ([]*types.BackupSchedule, error)

func (*MockDBConnector) SelectBackupSchedulesWithRPOInfo

func (c *MockDBConnector) SelectBackupSchedulesWithRPOInfo(
	_ context.Context, _ queries.ReadTableQuery,
) ([]*types.BackupSchedule, error)

func (*MockDBConnector) SelectBackups

func (c *MockDBConnector) SelectBackups(
	_ context.Context, _ queries.ReadTableQuery,
) ([]*types.Backup, error)

func (*MockDBConnector) SelectBackupsByStatus

func (c *MockDBConnector) SelectBackupsByStatus(
	_ context.Context, _ string,
) ([]*types.Backup, error)

func (*MockDBConnector) SelectOperations

func (c *MockDBConnector) SelectOperations(
	_ context.Context, _ queries.ReadTableQuery,
) ([]types.Operation, error)

func (*MockDBConnector) UpdateBackup

func (c *MockDBConnector) UpdateBackup(
	_ context.Context, id string, backupStatus string,
) error

func (*MockDBConnector) UpdateOperation

func (c *MockDBConnector) UpdateOperation(
	_ context.Context, op types.Operation,
) error

type Option

type Option func(*MockDBConnector)

func WithBackupSchedules

func WithBackupSchedules(backupSchedules map[string]types.BackupSchedule) Option

func WithBackups

func WithBackups(backups map[string]types.Backup) Option

func WithOperations

func WithOperations(operations map[string]types.Operation) Option

type StructFromResultSet

type StructFromResultSet[T any] func(result result.Result) (*T, error)

type YdbConnector

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

func NewYdbConnector

func NewYdbConnector(ctx context.Context, config config.YDBConnectionConfig) (*YdbConnector, error)

func (*YdbConnector) ActiveOperations

func (d *YdbConnector) ActiveOperations(ctx context.Context) (
	[]types.Operation, error,
)

func (*YdbConnector) Close

func (d *YdbConnector) Close(ctx context.Context)

func (*YdbConnector) CreateBackup

func (d *YdbConnector) CreateBackup(
	ctx context.Context, backup types.Backup,
) (string, error)

func (*YdbConnector) CreateOperation

func (d *YdbConnector) CreateOperation(
	ctx context.Context, operation types.Operation,
) (string, error)

func (*YdbConnector) ExecuteUpsert

func (d *YdbConnector) ExecuteUpsert(ctx context.Context, queryBuilder queries.WriteTableQuery) error

func (*YdbConnector) GetTableClient

func (d *YdbConnector) GetTableClient() table.Client

func (*YdbConnector) SelectBackupSchedules

func (d *YdbConnector) SelectBackupSchedules(
	ctx context.Context, queryBuilder queries.ReadTableQuery,
) ([]*types.BackupSchedule, error)

func (*YdbConnector) SelectBackupSchedulesWithRPOInfo

func (d *YdbConnector) SelectBackupSchedulesWithRPOInfo(
	ctx context.Context, queryBuilder queries.ReadTableQuery,
) ([]*types.BackupSchedule, error)

func (*YdbConnector) SelectBackups

func (d *YdbConnector) SelectBackups(
	ctx context.Context, queryBuilder queries.ReadTableQuery,
) ([]*types.Backup, error)

func (*YdbConnector) SelectOperations

func (d *YdbConnector) SelectOperations(
	ctx context.Context, queryBuilder queries.ReadTableQuery,
) ([]types.Operation, error)

func (*YdbConnector) UpdateBackup

func (d *YdbConnector) UpdateBackup(
	ctx context.Context, id string, backupStatus string,
) error

func (*YdbConnector) UpdateOperation

func (d *YdbConnector) UpdateOperation(
	ctx context.Context, operation types.Operation,
) error

Directories

Path Synopsis
yql

Jump to

Keyboard shortcuts

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