persistence

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfirmationFilters = &ffapi.QueryFields{
	"sequence":    &ffapi.Int64Field{},
	"id":          &ffapi.UUIDField{},
	"transaction": &ffapi.StringField{},
	"blocknumber": &ffapi.Int64Field{},
	"blockhash":   &ffapi.StringField{},
	"parenthash":  &ffapi.StringField{},
}
View Source
var EventStreamFilters = &ffapi.QueryFields{
	"sequence":            &ffapi.Int64Field{},
	"id":                  &ffapi.UUIDField{},
	"name":                &ffapi.StringField{},
	"created":             &ffapi.TimeField{},
	"updated":             &ffapi.TimeField{},
	"suspended":           &ffapi.BoolField{},
	"type":                &ffapi.StringField{},
	"errorhandling":       &ffapi.StringField{},
	"batchsize":           &ffapi.Int64Field{},
	"batchtimeout":        &ffapi.Int64Field{},
	"retrytimeout":        &ffapi.Int64Field{},
	"blockedretrytimeout": &ffapi.Int64Field{},
	"webhook":             &ffapi.JSONField{},
	"websocket":           &ffapi.JSONField{},
}
View Source
var ListenerFilters = &ffapi.QueryFields{
	"sequence":  &ffapi.Int64Field{},
	"id":        &ffapi.UUIDField{},
	"name":      &ffapi.StringField{},
	"created":   &ffapi.TimeField{},
	"updated":   &ffapi.TimeField{},
	"streamid":  &ffapi.UUIDField{},
	"filters":   &ffapi.JSONField{},
	"options":   &ffapi.JSONField{},
	"signature": &ffapi.StringField{},
	"fromblock": &ffapi.StringField{},
}
View Source
var ReceiptFilters = &ffapi.QueryFields{
	"sequence":         &ffapi.Int64Field{},
	"transaction":      &ffapi.StringField{},
	"created":          &ffapi.TimeField{},
	"updated":          &ffapi.TimeField{},
	"blocknumber":      &ffapi.Int64Field{},
	"transactionindex": &ffapi.BigIntField{},
	"blockhash":        &ffapi.StringField{},
	"success":          &ffapi.BoolField{},
	"protocolid":       &ffapi.StringField{},
	"extrainfo":        &ffapi.JSONField{},
	"contractlocation": &ffapi.JSONField{},
}
View Source
var TXHistoryFilters = &ffapi.QueryFields{
	"sequence":       &ffapi.Int64Field{},
	"id":             &ffapi.UUIDField{},
	"transaction":    &ffapi.StringField{},
	"time":           &ffapi.TimeField{},
	"lastoccurrence": &ffapi.TimeField{},
	"substatus":      &ffapi.StringField{},
	"action":         &ffapi.StringField{},
	"occurrences":    &ffapi.Int64Field{},
	"lasterror":      &ffapi.JSONField{},
	"lasterrortime":  &ffapi.TimeField{},
	"lastinfo":       &ffapi.JSONField{},
}
View Source
var TransactionFilters = &ffapi.QueryFields{
	"sequence":        &ffapi.Int64Field{},
	"id":              &ffapi.StringField{},
	"created":         &ffapi.TimeField{},
	"updated":         &ffapi.TimeField{},
	"status":          &ffapi.StringField{},
	"deleterequested": &ffapi.TimeField{},
	"from":            &ffapi.StringField{},
	"to":              &ffapi.StringField{},
	"nonce":           &ffapi.BigIntField{},
	"gas":             &ffapi.BigIntField{},
	"value":           &ffapi.BigIntField{},
	"gasprice":        &ffapi.JSONField{},
	"transactiondata": &ffapi.StringField{},
	"transactionhash": &ffapi.StringField{},
	"policyinfo":      &ffapi.JSONField{},
	"firstsubmit":     &ffapi.TimeField{},
	"lastsubmit":      &ffapi.TimeField{},
	"errormessage":    &ffapi.StringField{},
}

Functions

func JSONOrString added in v1.3.0

func JSONOrString(value *fftypes.JSONAny) *fftypes.JSONAny

Takes a string that might be valid JSON, and returns valid JSON that is either: a) The original JSON if it is valid b) An escaped string

Types

type CheckpointPersistence added in v1.3.0

type CheckpointPersistence interface {
	WriteCheckpoint(ctx context.Context, checkpoint *apitypes.EventStreamCheckpoint) error
	GetCheckpoint(ctx context.Context, streamID *fftypes.UUID) (*apitypes.EventStreamCheckpoint, error)
	DeleteCheckpoint(ctx context.Context, streamID *fftypes.UUID) error
}

type EventStreamPersistence added in v1.2.4

type EventStreamPersistence interface {
	ListStreamsByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir SortDirection) ([]*apitypes.EventStream, error) // reverse insertion order
	GetStream(ctx context.Context, streamID *fftypes.UUID) (*apitypes.EventStream, error)
	WriteStream(ctx context.Context, spec *apitypes.EventStream) error
	DeleteStream(ctx context.Context, streamID *fftypes.UUID) error
}

type ListenerPersistence added in v1.2.4

type ListenerPersistence interface {
	ListListenersByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir SortDirection) ([]*apitypes.Listener, error) // reverse insertion
	ListStreamListenersByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir SortDirection, streamID *fftypes.UUID) ([]*apitypes.Listener, error)
	GetListener(ctx context.Context, listenerID *fftypes.UUID) (*apitypes.Listener, error)
	WriteListener(ctx context.Context, spec *apitypes.Listener) error
	DeleteListener(ctx context.Context, listenerID *fftypes.UUID) error
}

type NextNonceCallback added in v1.3.0

type NextNonceCallback func(ctx context.Context, signer string) (uint64, error)

type Persistence

type Persistence interface {
	EventStreamPersistence
	CheckpointPersistence
	ListenerPersistence
	TransactionPersistence
	TransactionHistoryPersistence

	RichQuery() RichQuery      // panics if not supported
	Close(ctx context.Context) // close function is controlled by the manager
}

Persistence interface contains all the functions a persistence instance needs to implement. Sub set of functions are grouped into sub interfaces to provide a clear view of what persistent functions will be made available for each sub components to use after the persistent instance is initialized by the manager.

type RichQuery added in v1.3.0

type RichQuery interface {
	ListStreams(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.EventStream, *ffapi.FilterResult, error)
	ListListeners(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.Listener, *ffapi.FilterResult, error)
	ListTransactions(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.ManagedTX, *ffapi.FilterResult, error)
	ListTransactionConfirmations(ctx context.Context, txID string, filter ffapi.AndFilter) ([]*apitypes.ConfirmationRecord, *ffapi.FilterResult, error)
	ListTransactionHistory(ctx context.Context, txID string, filter ffapi.AndFilter) ([]*apitypes.TXHistoryRecord, *ffapi.FilterResult, error)
	ListStreamListeners(ctx context.Context, streamID *fftypes.UUID, filter ffapi.AndFilter) ([]*apitypes.Listener, *ffapi.FilterResult, error)

	NewStreamFilter(ctx context.Context) ffapi.FilterBuilder
	NewListenerFilter(ctx context.Context) ffapi.FilterBuilder
	NewTransactionFilter(ctx context.Context) ffapi.FilterBuilder
	NewConfirmationFilter(ctx context.Context) ffapi.FilterBuilder
	NewTxHistoryFilter(ctx context.Context) ffapi.FilterBuilder
}

type SortDirection

type SortDirection int
const (
	SortDirectionAscending SortDirection = iota
	SortDirectionDescending
)

type TransactionHistoryPersistence added in v1.3.0

type TransactionHistoryPersistence interface {
	AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, err *fftypes.JSONAny) error
}

type TransactionPersistence added in v1.2.4

type TransactionPersistence interface {
	ListTransactionsByCreateTime(ctx context.Context, after *apitypes.ManagedTX, limit int, dir SortDirection) ([]*apitypes.ManagedTX, error)         // reverse create time order
	ListTransactionsByNonce(ctx context.Context, signer string, after *fftypes.FFBigInt, limit int, dir SortDirection) ([]*apitypes.ManagedTX, error) // reverse nonce order within signer
	ListTransactionsPending(ctx context.Context, afterSequenceID string, limit int, dir SortDirection) ([]*apitypes.ManagedTX, error)                 // reverse insertion order, only those in pending state
	GetTransactionByID(ctx context.Context, txID string) (*apitypes.ManagedTX, error)
	GetTransactionByIDWithStatus(ctx context.Context, txID string, history bool) (*apitypes.TXWithStatus, error)
	GetTransactionByNonce(ctx context.Context, signer string, nonce *fftypes.FFBigInt) (*apitypes.ManagedTX, error)
	InsertTransactionPreAssignedNonce(ctx context.Context, tx *apitypes.ManagedTX) error
	InsertTransactionWithNextNonce(ctx context.Context, tx *apitypes.ManagedTX, lookupNextNonce NextNonceCallback) error
	UpdateTransaction(ctx context.Context, txID string, updates *apitypes.TXUpdates) error
	DeleteTransaction(ctx context.Context, txID string) error

	GetTransactionReceipt(ctx context.Context, txID string) (receipt *ffcapi.TransactionReceiptResponse, err error)
	SetTransactionReceipt(ctx context.Context, txID string, receipt *ffcapi.TransactionReceiptResponse) error

	GetTransactionConfirmations(ctx context.Context, txID string) ([]*apitypes.Confirmation, error)
	AddTransactionConfirmations(ctx context.Context, txID string, clearExisting bool, confirmations ...*apitypes.Confirmation) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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