importer

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImporterNameUsed = errors.New("importer name used")
)

Functions

This section is empty.

Types

type Factory

type Factory struct {
	runtime.Schema

	// FactoryFunc is used
	FactoryFunc FactoryFunc
}

Factory creates a new import handler.

type FactoryFunc

type FactoryFunc func(ctx context.Context, app *app.App, config runtime.Section) ([]*Instance, error)

FactoryFunc is called to create a one ore more importer instances from config.

type Handler

type Handler interface {
	// Import should import data from the external source.
	// The returned interface is published as an event to
	// "event/importer/<instance>/done"
	Import(ctx context.Context) (interface{}, error)
}

Handler is capable of importing data from an external source.

type ImportFinsihedEvent

type ImportFinsihedEvent struct {
	Importer string
	Time     time.Time
	Duration time.Duration
	Data     interface{}
	Error    string
}

type ImportFunc

type ImportFunc func(ctx context.Context) (interface{}, error)

ImportFunc implements Handler.

func (ImportFunc) Import

func (fn ImportFunc) Import(ctx context.Context) (interface{}, error)

Import imports data.

type ImportStartedEvent

type ImportStartedEvent struct {
	Importer string
	Time     time.Time
}

type Instance

type Instance struct {
	ID       string
	Schedule string
	Handler  Handler
	// contains filtered or unexported fields
}

Instance is a import handler instance that executes at a certain schedule.

func (*Instance) Run

func (inst *Instance) Run()

Run implements cron.Job.

type Manager

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

func NewManager

func NewManager(ctx context.Context, config *runtime.ConfigSchema, app *app.App) (*Manager, error)

func (*Manager) Config

func (mng *Manager) Config() *runtime.ConfigSchema

func (*Manager) NotifyChange

func (mng *Manager) NotifyChange(ctx context.Context, changeType, id string, sec *conf.Section) error

func (*Manager) Register

func (mng *Manager) Register(ctx context.Context, factory Factory) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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