reflector

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadMetric added in v0.0.6

type DownloadMetric struct {
	StartTime  int    `json:"startTime,omitempty"`
	Downloaded string `json:"downloaded"`
	Compressed string `json:"compressed"`
}

type MonitorConfig added in v0.0.4

type MonitorConfig struct {
	PollInterval               time.Duration
	Path                       string
	WALCheckpointThresholdSize int64
}

type MonitorOps added in v0.0.4

type MonitorOps func(config *WALMonitor)

MonitorOps configuration functions that customize the monitor

type Reflector

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

Reflector represents a fully materialized reflector, which polls an upstream database's ledger table for DML statements and applies them to a local SQLite database (LDB).

func ReflectorFromConfig

func ReflectorFromConfig(config ReflectorConfig) (*Reflector, error)

ReflectorFromConfig instantiates a Reflector instance using the configuration specified by a ReflectorConfig instance

func (*Reflector) Close

func (r *Reflector) Close() error

func (*Reflector) Start

func (r *Reflector) Start(ctx context.Context) error

func (*Reflector) Stop

func (r *Reflector) Stop()

type ReflectorConfig

type ReflectorConfig struct {
	LDBPath          string
	ChangelogPath    string
	ChangelogSize    int
	Upstream         UpstreamConfig
	BootstrapURL     string
	LedgerHealth     ledger.HealthConfig
	IsSupervisor     bool
	LDBWriteCallback ldbwriter.LDBWriteCallback // optional
	BootstrapRegion  string                     // optional
	// How often to poll the WAL stats
	WALPollInterval time.Duration // optional
	// Performs a checkpoint after the WAL file exceeds this size in bytes
	WALCheckpointThresholdSize int // optional
	// What type of checkpoint to perform
	WALCheckpointType ldbwriter.CheckpointType // optional
	DoMonitorWAL      bool                     // optional
	BusyTimeoutMS     int                      // optional
	ID                string
	Logger            *events.Logger
}

ReflectorConfig is used to configure a Reflector instance that is instantiated by ReflectorFromConfig

func (ReflectorConfig) Printable

func (c ReflectorConfig) Printable() string

Printable returns a "pretty" stringified version of the config

type ReflectorCtl

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

reflectorCtl controls starting and stopping the reflector for the purposes of a supervisor being able to perform a snapshot of the ldb without the reflector running concurrently. When the snapshot must be made, it will stop the reflector, perform the snapshot, and then start the reflector again.

func NewReflectorCtl

func NewReflectorCtl(reflector ReflectorI) *ReflectorCtl

func (*ReflectorCtl) Close

func (r *ReflectorCtl) Close() error

func (*ReflectorCtl) Start

func (r *ReflectorCtl) Start(ctx context.Context)

Start sends a start msg to the lifecycle goroutine. The lifecycle goroutine manages the state machine of the reflector. Since the lifecycle is a single goroutine it is last-write-wins.

func (*ReflectorCtl) Stop

func (r *ReflectorCtl) Stop(ctx context.Context)

Stop sends a start msg to the lifecycle goroutine. The lifecycle goroutine manages the state machine of the reflector. Since the lifecycle is a single goroutine it is last-write-wins.

type ReflectorI

type ReflectorI interface {
	Start(ctx context.Context) error
	Close() error
}

type S3Client

type S3Client interface {
	s3iface.S3API
}

type S3Downloader

type S3Downloader struct {
	Region              string // optional
	Bucket              string
	Key                 string
	S3Client            S3Client
	StartOverOnNotFound bool // whether we should rebuild LDB if snapshot not found
}

func (*S3Downloader) DownloadTo

func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error)

type UpstreamConfig

type UpstreamConfig struct {
	Driver                string
	DSN                   string
	LedgerTable           string
	QueryBlockSize        int
	PollInterval          time.Duration
	PollTimeout           time.Duration
	PollJitterCoefficient float64
}

UpstreamConfig specifies how to reach and treat the upstream CtlDB.

type WALMonitor added in v0.0.4

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

WALMonitor is responsible for querying the file size of sqlite's WAL file while in WAL mode as well as sqlite's checkpointing of the WAL file.

func NewMonitor added in v0.0.4

func NewMonitor(cfg MonitorConfig, checkpointTester checkpointTesterFunc, opts ...MonitorOps) *WALMonitor

func (*WALMonitor) Start added in v0.0.4

func (m *WALMonitor) Start(ctx context.Context)

Start runs the wal file size check and sqlite checkpoint check on PollInterval's cadence this method blocks

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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