tracker

package
v0.0.0-...-cee4934 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GORMTracker

type GORMTracker struct {
	gobulk.BaseStorage
	Cfg GORMTrackerConfig
	// contains filtered or unexported fields
}

GORMTracker represents a tracker that stores the import progress inside a database supported by gorm like PostgresSQL, MySQL and others.

func NewGORMTracker

func NewGORMTracker(cfg GORMTrackerConfig) *GORMTracker

NewGORMTracker returns a new instance of the GORMTracker.

func (*GORMTracker) AfterRun

func (t *GORMTracker) AfterRun() error

AfterRun is called right after each process cycle in order to finalize the storage operations. As for the GORMTracker, it simply marks the tracker as "dirty".

func (*GORMTracker) BeforeRun

func (t *GORMTracker) BeforeRun() error

BeforeRun is called right before each process cycle in order to prepare the storage for the run. As for the GORMTracker, it's possible to configure the tracker to resets started but not finished containers between runs by setting t.CleanupBetweenRuns to true.

func (*GORMTracker) CurrentIteration

func (t *GORMTracker) CurrentIteration(format gobulk.Format) (*gobulk.Iteration, error)

CurrentIteration retrieves the current iteration state of the passed format.

func (*GORMTracker) FinishContainers

func (t *GORMTracker) FinishContainers(containers []*gobulk.Container) (*gobulk.ProcessContainersResult, error)

FinishContainers sets the containers state as successfully and completely imported.

func (*GORMTracker) GetUnfinishedContainers

func (t *GORMTracker) GetUnfinishedContainers() ([]*gobulk.Container, error)

GetUnfinishedContainers returns a list of containers which have already been tracked but haven't yet been finished.

func (*GORMTracker) NewIteration

func (t *GORMTracker) NewIteration(format gobulk.Format, number uint) (*gobulk.Iteration, error)

NewIteration creates a new iteration based on the format definitions and saves it in the tracker.

func (*GORMTracker) NextContainers

func (t *GORMTracker) NextContainers(readStrategy gobulk.Strategy, number int, opts ...gobulk.TrackerNextContainersOpt) ([]*gobulk.Container, error)

NextContainers by default, searches for and returns new processable containers and locks them (marks as started). However, it's possible to modify the method behaviour by the opts parameter.

func (*GORMTracker) Setup

func (t *GORMTracker) Setup() error

Setup contains the storage preparations like connection etc. Is called only once at the very beginning of the work with the storage. As for the GORMTracker, it tests the connection / read access of the tracker, prepares everything like migrations.

func (*GORMTracker) Shutdown

func (t *GORMTracker) Shutdown()

Shutdown is called only once at the very end of the work with the storage. As for the GORMTracker, it closes the initially opened db connection.

func (*GORMTracker) TrackContainerOperations

func (t *GORMTracker) TrackContainerOperations(containers []*gobulk.Container) (*gobulk.ProcessContainersResult, error)

TrackContainerOperations persists the containers operations and their error/success status.

func (*GORMTracker) TrackContainers

func (t *GORMTracker) TrackContainers(containers []*gobulk.Container) (*gobulk.TrackContainersResponse, error)

TrackContainers tracks the containers in the slice and updates the corresponding Iteration last tracked container with the last one in the slice.

func (*GORMTracker) TrackIssue

func (t *GORMTracker) TrackIssue(issue *gobulk.Issue) error

TrackIssue tracks the issue.

type GORMTrackerConfig

type GORMTrackerConfig struct {
	Host               string           `validate:"required"`
	Database           string           `validate:"required"`
	User               string           `validate:"required"`
	Password           string           `validate:"required"`
	Port               string           `validate:"required"`
	Logger             logger.Interface `validate:"required"`
	CleanupOnStart     bool
	CleanupBetweenRuns bool
}

GORMTrackerConfig represents the GORMTracker config structure.

type MySQLTracker

type MySQLTracker struct {
	GORMTracker
}

MySQLTracker represents a tracker that stores the import progress inside a MySQL database.

Jump to

Keyboard shortcuts

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