Documentation

Overview

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

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    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 struct {
      	// contains filtered or unexported fields
      }

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

        func (*BufferedResult) GetCurrentData

        func (result *BufferedResult) GetCurrentData() []byte

          GetCurrentData returns the current row of data in Ion format. Use ion.Unmarshal or other Ion library methods to handle parsing. See https://github.com/amzn/ion-go for more information.

          func (*BufferedResult) Next

          func (result *BufferedResult) Next() bool

            Next advances to the next row of data in the current result set. Returns true if there was another row of data to advance. Returns false if there is no more data. After a successful call to Next, call GetCurrentData to retrieve the current row of data.

            type Cursor

            type Cursor interface {
            	Next(txn Transaction) bool
            	Err() error
            	GetCurrentData() []byte
            }

            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 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.
                    	LogInfo
                    	// LogDebug is for logging information useful for closely tracing the operation of the QLDBDriver.
                    	LogDebug
                    )

                    type Logger

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

                      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 struct {
                                  	// contains filtered or unexported fields
                                  }

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

                                    func (*Result) Err

                                    func (result *Result) Err() error

                                      Err returns an error if a previous call to Next has failed. The returned error will be nil if the previous call to Next succeeded.

                                      func (*Result) GetCurrentData

                                      func (result *Result) GetCurrentData() []byte

                                        GetCurrentData returns the current row of data in Ion format. Use ion.Unmarshal or other Ion library methods to handle parsing. See https://github.com/amzn/ion-go for more information.

                                        func (*Result) Next

                                        func (result *Result) Next(txn Transaction) bool

                                          Next advances to the next row of data in the current result set. Returns true if there was another row of data to advance. Returns false if there is no more data or if an error occurred. After a successful call to Next, call GetCurrentData to retrieve the current row of data. After an unsuccessful call to Next, check Err to see if Next returned false because an error happened or because there is no more data.

                                          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 Transaction

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

                                              Transaction represents an active QLDB transaction.