v2.0.2 Latest Latest

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 18 Imported by: 1



Package qldbdriver is the Golang driver for working with Amazon Quantum Ledger Database.



This section is empty.


This section is empty.


This section is empty.


type BackoffStrategy

type BackoffStrategy interface {
	// Get the time to delay before retrying, using an exponential function on the retry attempt, and jitter.
	Delay(retryAttempt int) time.Duration

BackoffStrategy is an interface for implementing a delay before retrying the provided function with a new transaction.

type BufferedResult

type BufferedResult interface {
	Next() bool
	GetCurrentData() []byte
	GetConsumedIOs() *IOUsage
	GetTimingInformation() *TimingInformation

BufferedResult is a cursor over a result set from a QLDB statement that is valid outside the context of a transaction.

type DriverOptions

type DriverOptions struct {
	// The policy guiding retry attempts upon a recoverable error.
	// Default: MaxRetryLimit: 4, ExponentialBackoff: SleepBase: 10ms, SleepCap: 5000ms.
	RetryPolicy RetryPolicy
	// The maximum amount of concurrent transactions this driver will permit. Default: 50.
	MaxConcurrentTransactions int
	// The logger that the driver will use for any logging messages. Default: "log" package.
	Logger Logger
	// The verbosity level of the logs that the logger should receive. Default: qldbdriver.LogInfo.
	LoggerVerbosity LogLevel

DriverOptions can be used to configure the driver during construction.

type ExponentialBackoffStrategy

type ExponentialBackoffStrategy struct {
	// The time in milliseconds to use as the exponent base for the delay calculation.
	SleepBase time.Duration
	// The maximum delay time in milliseconds.
	SleepCap time.Duration

ExponentialBackoffStrategy exponentially increases the delay per retry attempt given a base and a cap.

This is the default strategy implementation.

func (ExponentialBackoffStrategy) Delay

func (s ExponentialBackoffStrategy) Delay(retryAttempt int) time.Duration

Delay gets the time to delay before retrying, using an exponential function on the retry attempt, and jitter.

type IOUsage

type IOUsage struct {
	// contains filtered or unexported fields

IOUsage contains metrics for the amount of IO requests that were consumed.

func (*IOUsage) GetReadIOs

func (ioUsage *IOUsage) GetReadIOs() *int64

GetReadIOs returns the number of read IO requests that were consumed for a statement execution.

type LogLevel

type LogLevel uint8

LogLevel represents the valid logging verbosity levels.

const (
	// LogOff is for logging nothing.
	LogOff LogLevel = iota
	// LogInfo is for logging informative events. This is the default logging level.
	// LogDebug is for logging information useful for closely tracing the operation of the QLDBDriver.

type Logger

type Logger interface {
	// Log the message using the built-in Golang logging package.
	Log(message string, verbosity LogLevel)

Logger is an interface for a QLDBDriver logger.

type QLDBDriver

type QLDBDriver struct {
	// contains filtered or unexported fields

QLDBDriver is used to execute statements against QLDB. Call constructor qldbdriver.New for a valid QLDBDriver.

func New

func New(ledgerName string, qldbSession *qldbsession.QLDBSession, fns ...func(*DriverOptions)) (*QLDBDriver, error)

New creates a QLBDDriver using the parameters and options, and verifies the configuration.

Note that qldbSession.Client.Config.MaxRetries will be set to 0. This property should not be modified. DriverOptions.RetryLimit is unrelated to this property, but should be used if it is desired to modify the amount of retires for statement executions.

func (*QLDBDriver) Execute

func (driver *QLDBDriver) Execute(ctx context.Context, fn func(txn Transaction) (interface{}, error)) (interface{}, error)

Execute a provided function within the context of a new QLDB transaction.

The provided function might be executed more than once and is not expected to run concurrently. It is recommended for it to be idempotent, so that it doesn't have unintended side effects in the case of retries.

func (*QLDBDriver) GetTableNames

func (driver *QLDBDriver) GetTableNames(ctx context.Context) ([]string, error)

GetTableNames returns a list of the names of active tables in the ledger.

func (*QLDBDriver) SetRetryPolicy

func (driver *QLDBDriver) SetRetryPolicy(rp RetryPolicy)

SetRetryPolicy sets the driver's retry policy for Execute.

func (*QLDBDriver) Shutdown

func (driver *QLDBDriver) Shutdown(ctx context.Context)

Shutdown the driver, cleaning up allocated resources.

type Result

type Result interface {
	Next(txn Transaction) bool
	GetCurrentData() []byte
	GetConsumedIOs() *IOUsage
	GetTimingInformation() *TimingInformation
	Err() error

Result is a cursor over a result set from a QLDB statement.

type RetryPolicy

type RetryPolicy struct {
	// The maximum amount of times to retry.
	MaxRetryLimit int
	// The strategy to use for delaying before the retry attempt.
	Backoff BackoffStrategy

RetryPolicy defines the policy to use to for retrying the provided function in the case of a non-fatal error.

type TimingInformation

type TimingInformation struct {
	// contains filtered or unexported fields

TimingInformation contains metrics for server-side processing time.

func (*TimingInformation) GetProcessingTimeMilliseconds

func (timingInfo *TimingInformation) GetProcessingTimeMilliseconds() *int64

GetProcessingTimeMilliseconds returns the server-side processing time in milliseconds for a statement execution.

type Transaction

type Transaction interface {
	// Execute a statement with any parameters within this transaction.
	Execute(statement string, parameters ...interface{}) (Result, error)
	// Buffer a Result into a BufferedResult to use outside the context of this transaction.
	BufferResult(res Result) (BufferedResult, error)
	// Abort the transaction, discarding any previous statement executions within this transaction.
	Abort() error
	// Return the automatically generated transaction ID.
	ID() string

Transaction represents an active QLDB transaction.

Jump to

Keyboard shortcuts

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