status

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StageSchemaCreation = "schema_creation"
	StageDataLoad       = "data_load"
)

Variables

This section is empty.

Functions

func CreateStatusAndExceptionTables

func CreateStatusAndExceptionTables(ctx context.Context, conn *pgx.Conn) error

func DeleteAllExceptionLogs

func DeleteAllExceptionLogs(ctx context.Context, conn *pgx.Conn) error

Used to clear the continuation tokens on fresh runs.

func ExtractFileNameFromErr

func ExtractFileNameFromErr(errString string) string

func GetTableSchemaToExceptionLog

func GetTableSchemaToExceptionLog(el []*ExceptionLog) map[string]*ExceptionLog

func MaybeReportException

func MaybeReportException(
	ctx context.Context,
	logger zerolog.Logger,
	conn *pgx.Conn,
	table dbtable.Name,
	inputErr error,
	fileName string,
	stage string,
	isClearContinuationTokenMode bool,
	exceptionLog *ExceptionLog,
) error

TODO (rluu): use connection pool later on.

Types

type ExceptionLog

type ExceptionLog struct {
	ID       uuid.UUID
	FetchID  uuid.UUID
	Table    string
	Schema   string
	Message  string
	SQLState string
	FileName string
	Command  string
	Stage    string
	Time     time.Time
}

func GetAllExceptionLogs

func GetAllExceptionLogs(
	ctx context.Context, conn *pgx.Conn, numResults int,
) ([]ExceptionLog, error)

func GetAllExceptionLogsByFetchID

func GetAllExceptionLogsByFetchID(
	ctx context.Context, conn *pgx.Conn, fetchID string,
) ([]*ExceptionLog, error)

func GetExceptionLogByToken

func GetExceptionLogByToken(
	ctx context.Context, conn *pgx.Conn, token string,
) (*ExceptionLog, error)

func (ExceptionLog) Caption

func (l ExceptionLog) Caption() string

func (*ExceptionLog) CreateEntry

func (e *ExceptionLog) CreateEntry(ctx context.Context, conn *pgx.Conn, stage string) error

Added logic to be able to set the time from the struct itself to simplify testing. For some of the tests, we must test exceptions created at multiple times in order to properly validate behavior. Testutils.hook for date doesn't work since all entries would end up having the same. In the actual use case (non-testing) the time will be generated as the current time as the logic below shows.

func (*ExceptionLog) DeleteEntry

func (e *ExceptionLog) DeleteEntry(ctx context.Context, conn *pgx.Conn) error

DeleteEntry is used when, on a continuation run, the import succeeds and we want to clear the exception from the table.

func (ExceptionLog) JSONFormat

func (l ExceptionLog) JSONFormat() string

func (ExceptionLog) TableFormat

func (l ExceptionLog) TableFormat() []string

func (ExceptionLog) TableHeaders

func (l ExceptionLog) TableHeaders() []string

func (*ExceptionLog) UpdateEntry

func (e *ExceptionLog) UpdateEntry(
	ctx context.Context, conn *pgx.Conn, msg, sqlState, fileName string,
) error

type FetchStatus

type FetchStatus struct {
	ID            uuid.UUID
	Name          string
	StartedAt     time.Time
	SourceDialect string
}

func (*FetchStatus) CreateEntry

func (s *FetchStatus) CreateEntry(ctx context.Context, conn *pgx.Conn) error

Jump to

Keyboard shortcuts

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