source

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileHandler

type FileHandler interface {
	io.ReadCloser

	// Unique identifier of the file content
	Etag() string
	// Path to the file in the data source
	Path() string

	// Arbitrary metadata created by user that is used inside user application. Will be passed to source suring events.
	UserMetadata() any
}

type FileProcessingDoneEvent

type FileProcessingDoneEvent struct {
	// Unique identifier of the processing. Same for all events during same processing
	UUID string
	// Path to the processed file
	Path string
	// File user metadata
	UserMetadata any
	// Why processing finished
	Reason FileProcessingDoneReason
	// Only valid if reason is ERROR
	Error error
}

type FileProcessingDoneReason

type FileProcessingDoneReason string
const FileProcessingAborted FileProcessingDoneReason = "ABORTED"
const FileProcessingError FileProcessingDoneReason = "ERROR"
const FileProcessingOk FileProcessingDoneReason = "OK"

type FileProcessingRunningEvent

type FileProcessingRunningEvent struct {
	// Unique identifier of the processing. Same for all events during same processing
	UUID string
	// Path to the processed file
	Path string
	// File user metadata
	UserMetadata any
	// Progress in percentages from 0 to 100
	Progress uint8
}

type FileProcessingStartedEvent

type FileProcessingStartedEvent struct {
	// Unique identifier of the processing. Same for all events during same processing
	UUID string
	// Path to the processed file
	Path string
	// File user metadata
	UserMetadata any
}

type Iterator

type Iterator interface {
	io.Closer

	// Get and open next file. Thread safe. If there are no files left, returns [io.EOF] error
	Next(ctx context.Context) (FileHandler, error)
}

Opened data source

type Source

type Source interface {
	UUID() string
	// Open data source for iteration
	Open() (Iterator, error)

	// Notify source that processing of the file is started.
	NotifyFileProcessingStarted(ctx context.Context, event FileProcessingStartedEvent) error
	// Notify source that processing of the file is still running.
	// Notifications may be not synchronized with start and done events but handled one by one and in order. Use event UUID to detect sync problems.
	// Event handling blocks processing and stops it if returns error. Separate done event will be emited if this hanler return error.
	// Running events must be emmited with at most 30 seconds interval.
	NotifyFileProcessingRunning(ctx context.Context, event FileProcessingRunningEvent) error
	// Notify source that processing of the file is finished
	NotifyFileProcessingDone(ctx context.Context, event FileProcessingDoneEvent) error
}

Place where data located

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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