db

package
v0.0.0-...-bd35244 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migrations migrate.MigrationSource = &migrate.AssetMigrationSource{
	Asset:    Asset,
	AssetDir: AssetDir,
	Dir:      "migrations",
}

Migrations represents all of the schema migration

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Database

type Database interface {
	GetLastCursorValue() (cursor *string, err error)

	InsertReceivedPayment(payment *ReceivedPayment) error
	UpdateReceivedPayment(payment *ReceivedPayment) error
	GetReceivedPaymentByID(id int64) (*ReceivedPayment, error)
	GetReceivedPaymentByOperationID(operationID string) (*ReceivedPayment, error)
	GetReceivedPayments(page, limit uint64) ([]*ReceivedPayment, error)

	InsertSentTransaction(transaction *SentTransaction) error
	UpdateSentTransaction(transaction *SentTransaction) error
	GetSentTransactionByPaymentID(paymentID string) (*SentTransaction, error)
	GetSentTransactions(page, limit uint64) ([]*SentTransaction, error)
}

type PostgresDatabase

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

func (*PostgresDatabase) GetDB

func (d *PostgresDatabase) GetDB() *sql.DB

func (*PostgresDatabase) GetLastCursorValue

func (d *PostgresDatabase) GetLastCursorValue() (cursor *string, err error)

GetLastCursorValue returns last cursor value from a DB

func (*PostgresDatabase) GetReceivedPaymentByID

func (d *PostgresDatabase) GetReceivedPaymentByID(id int64) (*ReceivedPayment, error)

GetReceivedPaymentByID returns received payment by id

func (*PostgresDatabase) GetReceivedPaymentByOperationID

func (d *PostgresDatabase) GetReceivedPaymentByOperationID(operationID string) (*ReceivedPayment, error)

GetReceivedPaymentByOperationID returns received payment by operation_id

func (*PostgresDatabase) GetReceivedPayments

func (d *PostgresDatabase) GetReceivedPayments(page, limit uint64) ([]*ReceivedPayment, error)

GetReceivedPayments returns received payments

func (*PostgresDatabase) GetSentTransactionByHash

func (d *PostgresDatabase) GetSentTransactionByHash(hash string) (*SentTransaction, error)

GetSentTransactionByHash returns sent transaction searching by hash

func (*PostgresDatabase) GetSentTransactionByPaymentID

func (d *PostgresDatabase) GetSentTransactionByPaymentID(paymentID string) (*SentTransaction, error)

GetSentTransactionByPaymentID returns sent transaction searching by payment ID

func (*PostgresDatabase) GetSentTransactions

func (d *PostgresDatabase) GetSentTransactions(page, limit uint64) ([]*SentTransaction, error)

GetSentTransactions returns received payments

func (*PostgresDatabase) InsertReceivedPayment

func (d *PostgresDatabase) InsertReceivedPayment(payment *ReceivedPayment) error

InsertReceivedPayment inserts a new payment into DB. After successful insert ID field on `payment` will updated to ID of a new row.

func (*PostgresDatabase) InsertSentTransaction

func (d *PostgresDatabase) InsertSentTransaction(transaction *SentTransaction) error

InsertSentTransaction inserts anew transaction into DB. After successful insert ID field on `transaction` will updated to ID of a new row.

func (*PostgresDatabase) Open

func (d *PostgresDatabase) Open(dsn string) error

func (*PostgresDatabase) UpdateReceivedPayment

func (d *PostgresDatabase) UpdateReceivedPayment(payment *ReceivedPayment) error

func (*PostgresDatabase) UpdateSentTransaction

func (d *PostgresDatabase) UpdateSentTransaction(transaction *SentTransaction) error

type ReceivedPayment

type ReceivedPayment struct {
	ID            int64     `db:"id" json:"id"`
	OperationID   string    `db:"operation_id" json:"operation_id"`
	ProcessedAt   time.Time `db:"processed_at" json:"processed_at"`
	PagingToken   string    `db:"paging_token" json:"paging_token"`
	Status        string    `db:"status" json:"status"`
	TransactionID string    `db:"transaction_id" json:"transaction_id"`
}

ReceivedPayment represents payment received by the gateway server

type SentTransaction

type SentTransaction struct {
	ID            int64                 `db:"id" json:"id"`
	PaymentID     sql.NullString        `db:"payment_id" json:"payment_id"`
	TransactionID string                `db:"transaction_id" json:"transaction_id"`
	Status        SentTransactionStatus `db:"status" json:"status"` // sending/success/failure
	Source        string                `db:"source" json:"source"`
	SubmittedAt   time.Time             `db:"submitted_at" json:"submitted_at"`
	SucceededAt   *time.Time            `db:"succeeded_at" json:"succeeded_at"`
	Ledger        *int32                `db:"ledger" json:"ledger"`
	EnvelopeXdr   string                `db:"envelope_xdr" json:"envelope_xdr"`
	ResultXdr     *string               `db:"result_xdr" json:"result_xdr"`
}

SentTransaction represents transaction sent by the gateway server

type SentTransactionStatus

type SentTransactionStatus string

SentTransactionStatus type represents sent transaction status

const (
	// SentTransactionStatusSending is a status indicating that transaction is sending
	SentTransactionStatusSending SentTransactionStatus = "sending"
	// SentTransactionStatusSuccess is a status indicating that transaction has been successfully sent
	SentTransactionStatusSuccess SentTransactionStatus = "success"
	// SentTransactionStatusFailure is a status indicating that there has been an error while sending a transaction
	SentTransactionStatusFailure SentTransactionStatus = "failure"
)

func (*SentTransactionStatus) Scan

func (s *SentTransactionStatus) Scan(src interface{}) error

Scan implements database/sql.Scanner interface

func (SentTransactionStatus) Value

func (status SentTransactionStatus) Value() (driver.Value, error)

Value implements driver.Valuer

Jump to

Keyboard shortcuts

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