db_buffer

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSyncPeriod = 30 * time.Second

Variables

This section is empty.

Functions

func ParallelCopyTxsToDB

func ParallelCopyTxsToDB(transactions interface{}, tableName string) error

Types

type Buffer

type Buffer struct {
	SyncComplete chan SyncResult
	// contains filtered or unexported fields
}

func NewDBBuffer

func NewDBBuffer(db *gorm.DB, cfg Config) *Buffer

func (*Buffer) ClearBuffer

func (b *Buffer) ClearBuffer(dataType string)

func (*Buffer) GetBufferSize

func (b *Buffer) GetBufferSize(dataType string) int

func (*Buffer) GetData

func (b *Buffer) GetData(dataType string) (map[string]interface{}, error)

func (*Buffer) InsertData

func (b *Buffer) InsertData(key string, height int64, data interface{}, notify bool) error

InsertData inserts 'data' into the buffer under the key 'key' if notify is set to true, the condition 'SyncBlockThreshold' will be tested for that specific key

func (*Buffer) SetSyncFunc

func (b *Buffer) SetSyncFunc(cb SyncCB)

SetSyncFunc sets the syncing callback function

func (*Buffer) Start

func (b *Buffer) Start()

Start starts listening for syncing triggering events

func (*Buffer) Stop

func (b *Buffer) Stop()

Stop stops listening for syncing triggering events

type BufferMetrics

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

type Config

type Config struct {
	SyncTimePeriod     time.Duration
	SyncBlockThreshold uint
}

type SyncCB

type SyncCB func() SyncResult

type SyncResult

type SyncResult struct {
	Id            string
	SyncedHeights *[]uint64 // Synced heights
	Error         error     // Error in db insertion process
}

Jump to

Keyboard shortcuts

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