datasync

package
v0.0.0-...-cddd04e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyncDisabled = errors.New("data sharing is disabled on this instance")
)

Functions

func DecodeSyncObj

func DecodeSyncObj(obj interface{}, receiver interface{}) error

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func RegisteredSources

func RegisteredSources() ([]string, error)

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type Request

type Request struct {
	Table        string
	Date         time.Time
	MaxSkipCount int
	MaxTakeCount int
}

type Result

type Result struct {
	Success    bool        `json:"success"`
	Message    string      `json:"message,omitempty"`
	Records    interface{} `json:"records,omitempty"`
	TotalCount int64       `json:"total_count,omitempty"`
}

func Retrieve

func Retrieve(ctx context.Context, tableName string, last string, skip, take int) (*Result, error)

type Store

type Store interface {
	TableNames() []string
	LastEntry(ctx context.Context, tableName string, receiver interface{}) error

	LastExchangeEntryID() (id int64)
	SaveExchangeFromSync(ctx context.Context, exchange interface{}) error
	LastExchangeTickEntryTime() (time time.Time)
	SaveExchangeTickFromSync(ctx context.Context, tick interface{}) error

	StoreMempoolFromSync(ctx context.Context, mempoolDto interface{}) error
	SaveBlockFromSync(ctx context.Context, block interface{}) error
	SaveVoteFromSync(ctx context.Context, vote interface{}) error
	UpdatePropagationData(ctx context.Context) error

	AddPowDataFromSync(ctx context.Context, data interface{}) error

	AddVspSourceFromSync(ctx context.Context, vspDto interface{}) error
	AddVspTicksFromSync(ctx context.Context, tick VSPTickSyncDto) error
}

type SyncCoordinator

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

func NewCoordinator

func NewCoordinator(isEnabled bool, period int) *SyncCoordinator

func (*SyncCoordinator) AddSource

func (s *SyncCoordinator) AddSource(url string, store Store, database string)

func (*SyncCoordinator) AddSyncer

func (s *SyncCoordinator) AddSyncer(tableName string, syncer Syncer)

func (*SyncCoordinator) StartSyncing

func (s *SyncCoordinator) StartSyncing(ctx context.Context)

func (*SyncCoordinator) Syncer

func (s *SyncCoordinator) Syncer(tableName string) (Syncer, bool)

type Syncer

type Syncer struct {
	LastEntry func(ctx context.Context, db Store) (string, error)
	Collect   func(ctx context.Context, url string) (*Result, error)
	Retrieve  func(ctx context.Context, last string, skip, take int) (*Result, error)
	Append    func(ctx context.Context, db Store, data interface{})
}

type VSPTickSyncDto

type VSPTickSyncDto struct {
	ID               int       `json:"id"`
	VSPID            int       `json:"vspid"`
	VSP              string    `json:"vsp"`
	Immature         int       `json:"immature"`
	Live             int       `json:"live"`
	Voted            int       `json:"voted"`
	Missed           int       `json:"missed"`
	PoolFees         float64   `json:"pool_fees"`
	ProportionLive   float64   `json:"proportion_live"`
	ProportionMissed float64   `json:"proportion_missed"`
	UserCount        int       `json:"user_count"`
	UsersActive      int       `json:"users_active"`
	Time             time.Time `json:"time"`
}

Jump to

Keyboard shortcuts

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