types

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventFieldTypeInt     = "int"
	EventFieldTypeUInt    = "uint"
	EventFieldTypeAddress = "address"
	EventFieldTypeBytes   = "bytes"
	EventFieldTypeBool    = "bool"
	EventFieldTypeString  = "string"
)

Defined event input types - these are currently align with EVM types but they technically define a pair/mapping of EVM type -> SQL type

View Source
const (
	PostgresDB = "postgres"
	SQLiteDB   = "sqlite"
)

supported databases

View Source
const (
	SQLLogTableName        = "_vent_log"
	SQLDictionaryTableName = "_vent_dictionary"
	SQLBlockTableName      = "_vent_block"
	SQLTxTableName         = "_vent_tx"
	SQLChainInfoTableName  = "_vent_chain"
)

SQL log & dictionary tables

View Source
const (
	// log
	SQLColumnLabelId          = "_id"
	SQLColumnLabelTimeStamp   = "_timestamp"
	SQLColumnLabelTableName   = "_tablename"
	SQLColumnLabelEventName   = "_eventname"
	SQLColumnLabelEventFilter = "_eventfilter"
	SQLColumnLabelHeight      = "_height"
	SQLColumnLabelTxHash      = "_txhash"
	SQLColumnLabelAction      = "_action"
	SQLColumnLabelDataRow     = "_datarow"
	SQLColumnLabelSqlStmt     = "_sqlstmt"
	SQLColumnLabelSqlValues   = "_sqlvalues"

	// dictionary
	SQLColumnLabelColumnName   = "_columnname"
	SQLColumnLabelColumnType   = "_columntype"
	SQLColumnLabelColumnLength = "_columnlength"
	SQLColumnLabelPrimaryKey   = "_primarykey"
	SQLColumnLabelColumnOrder  = "_columnorder"

	// chain info
	SQLColumnLabelBurrowVer = "_burrowversion"
	SQLColumnLabelChainID   = "_chainid"

	// context
	SQLColumnLabelIndex       = "_index"
	SQLColumnLabelEventType   = "_eventtype"
	SQLColumnLabelBlockHeader = "_blockheader"
	SQLColumnLabelTxType      = "_txtype"
	SQLColumnLabelEnvelope    = "_envelope"
	SQLColumnLabelEvents      = "_events"
	SQLColumnLabelResult      = "_result"
	SQLColumnLabelReceipt     = "_receipt"
	SQLColumnLabelException   = "_exception"
)

fixed sql column names in tables

View Source
const (
	// event related
	EventNameLabel = "eventName"
	EventTypeLabel = "eventType"

	// block related
	BlockHeightLabel = "height"
	BlockHeaderLabel = "blockHeader"

	// transaction related
	TxTxTypeLabel    = "txType"
	TxTxHashLabel    = "txHash"
	TxIndexLabel     = "index"
	TxEnvelopeLabel  = "envelope"
	TxEventsLabel    = "events"
	TxResultLabel    = "result"
	TxReceiptLabel   = "receipt"
	TxExceptionLabel = "exception"
)

labels for column mapping

Variables

This section is empty.

Functions

func EventSpecSchema

func EventSpecSchema() *jsonschema.Schema

Types

type DBAction

type DBAction string

DBAction generic type

const (
	ActionDelete      DBAction = "DELETE"
	ActionUpsert      DBAction = "UPSERT"
	ActionRead        DBAction = "READ"
	ActionCreateTable DBAction = "CREATE"
	ActionAlterTable  DBAction = "ALTER"
	ActionInitialize  DBAction = "_INITIALIZE_VENT"
)

type EventClass

type EventClass struct {
	// Destination table in DB
	TableName string
	// Burrow event filter query in query peg grammar
	Filter string
	// The name of a solidity event field that when present indicates that the rest of the event should be interpreted
	// as requesting a row deletion (rather than upsert) in the projection table.
	DeleteMarkerField string `json:",omitempty"`
	// EventFieldMapping from solidity event field name to EventFieldMapping descriptor
	FieldMappings []*EventFieldMapping
	// contains filtered or unexported fields
}

EventClass struct (table name where to persist filtered events and it structure)

func (*EventClass) GetFieldMapping

func (ec *EventClass) GetFieldMapping(fieldName string) *EventFieldMapping

func (*EventClass) GetFilter

func (ec *EventClass) GetFilter() string

func (*EventClass) Query

func (ec *EventClass) Query() (query.Query, error)

Get a (memoised) Query from the EventClass Filter string

func (*EventClass) Validate

func (ec *EventClass) Validate() error

Validate checks the structure of an EventClass

type EventData

type EventData struct {
	BlockHeight uint64
	Tables      map[string]EventDataTable
}

EventData contains data for each block of events already mapped to SQL columns & tables Tables map key is the table name

type EventDataRow

type EventDataRow struct {
	Action  DBAction
	RowData map[string]interface{}
	// The EventClass that caused this row to be emitted (if it was caused by an specific event)
	EventClass *EventClass
}

EventDataRow contains each SQL column name and a corresponding value to upsert map key is the column name and map value is the given column value if Action == 'delete' then the row has to be deleted

type EventDataTable

type EventDataTable []EventDataRow

EventDataTable is an array of rows

type EventFieldMapping

type EventFieldMapping struct {
	// EVM event field name to process
	Field string
	// EVM type of this field - used to derive SQL type
	Type string
	// Destination SQL column name to which to map this event field
	ColumnName string
	// Whether this event field should map to a primary key
	Primary bool `json:",omitempty"`
	// Whether to convert this event field from bytes32 to string
	BytesToString bool `json:",omitempty"`
	// Notification channels on which submit (via a trigger) a payload that contains this column's new value (upsert) or
	// old value (delete). The payload will contain all other values with the same channel set as a JSON object.
	Notify []string `json:",omitempty"`
}

EventFieldMapping struct (table column definition)

func (EventFieldMapping) Validate

func (evColumn EventFieldMapping) Validate() error

Validate checks the structure of an EventFieldMapping

type EventSpec

type EventSpec []*EventClass

EventSpec contains all event class specifications

type EventTables

type EventTables map[string]*SQLTable

EventTables contains SQL tables definition (-> the event name maps to SQL table)

type SQLCleanDBQuery

type SQLCleanDBQuery struct {
	SelectChainIDQry    string
	DeleteChainIDQry    string
	InsertChainIDQry    string
	SelectDictionaryQry string
	DeleteDictionaryQry string
	DeleteLogQry        string
}

SQLCleanDBQuery stores queries needed to clean the database

type SQLColumnType

type SQLColumnType int

SQLColumnType to store generic SQL column types

const (
	SQLColumnTypeBool SQLColumnType = iota
	SQLColumnTypeByteA
	SQLColumnTypeInt
	SQLColumnTypeSerial
	SQLColumnTypeText
	SQLColumnTypeVarchar
	SQLColumnTypeTimeStamp
	SQLColumnTypeNumeric
	SQLColumnTypeJSON
	SQLColumnTypeBigInt
)

generic SQL column types

func (SQLColumnType) IsNumeric

func (ct SQLColumnType) IsNumeric() bool

IsNumeric determines if an sqlColumnType is numeric

func (SQLColumnType) String

func (ct SQLColumnType) String() string

type SQLConnection

type SQLConnection struct {
	DBAdapter     string
	DBURL         string
	DBSchema      string
	Log           *logger.Logger
	ChainID       string
	BurrowVersion string
}

SQLConnection stores parameters to build a new db connection & initialize the database

type SQLErrorType

type SQLErrorType int

SQLErrorType stores generic SQL error types

const (
	SQLErrorTypeDuplicatedSchema SQLErrorType = iota
	SQLErrorTypeDuplicatedColumn
	SQLErrorTypeDuplicatedTable
	SQLErrorTypeInvalidType
	SQLErrorTypeUndefinedTable
	SQLErrorTypeUndefinedColumn
	SQLErrorTypeGeneric
)

generic SQL error types

type SQLTable

type SQLTable struct {
	Name    string
	Columns []*SQLTableColumn
	// Map of channel name -> columns to be sent as payload on that channel
	NotifyChannels map[string][]string
	// contains filtered or unexported fields
}

SQLTable contains the structure of a SQL table,

func (*SQLTable) GetColumn

func (table *SQLTable) GetColumn(columnName string) *SQLTableColumn

type SQLTableColumn

type SQLTableColumn struct {
	Name    string
	Type    SQLColumnType
	Primary bool
	Length  int
}

SQLTableColumn contains the definition of a SQL table column, the Order is given to be able to sort the columns to be created

func (*SQLTableColumn) Equals

func (col *SQLTableColumn) Equals(otherCol *SQLTableColumn) bool

func (*SQLTableColumn) String

func (col *SQLTableColumn) String() string

type UpsertDeleteQuery

type UpsertDeleteQuery struct {
	Query    string
	Values   string
	Pointers []interface{}
}

UpsertDeleteQuery contains query and values to upsert or delete row data

Jump to

Keyboard shortcuts

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