plugin

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseJob

type BaseJob struct {
	*BasePlugin
	// contains filtered or unexported fields
}

BaseJob: a fundamental job class that assists and simplifies the implementation of job interfaces

func NewBaseJob

func NewBaseJob() *BaseJob

NewBaseJob: a function or method to acquire a new instance of BaseJob

func (*BaseJob) Collector

func (b *BaseJob) Collector() JobCollector

Collector: a component or system that collects data or information

func (*BaseJob) JobID added in v0.1.2

func (b *BaseJob) JobID() int64

JobID: the identifier for a job

func (*BaseJob) SetCollector

func (b *BaseJob) SetCollector(collector JobCollector)

SetCollector: a function or method to set or configure a collector

func (*BaseJob) SetJobID added in v0.1.2

func (b *BaseJob) SetJobID(jobID int64)

SetJobID: a function or method to set the ID of a job

type BasePluggable

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

BasePluggable - A basic pluggable interface Used to assist in the implementation of various pluggable interfaces, simplifying their implementation

func NewBasePluggable

func NewBasePluggable() *BasePluggable

NewBasePluggable - Creates a pluggable plugin

func (*BasePluggable) Description

func (b *BasePluggable) Description() (string, error)

Description - Plugin Description, will return an error if description is not present or not a string

func (*BasePluggable) Developer

func (b *BasePluggable) Developer() (string, error)

Developer - Plugin Developer, will return an error if developer is not present or not a string

func (*BasePluggable) PeerPluginJobConf

func (b *BasePluggable) PeerPluginJobConf() *config.JSON

PeerPluginJobConf - Set personalized configuration

func (*BasePluggable) PeerPluginName

func (b *BasePluggable) PeerPluginName() string

PeerPluginName - Corresponding Plugin Name

func (*BasePluggable) PluginConf

func (b *BasePluggable) PluginConf() *config.JSON

PluginConf - Plugin Configuration

func (*BasePluggable) PluginJobConf

func (b *BasePluggable) PluginJobConf() *config.JSON

PluginJobConf - Working Configuration

func (*BasePluggable) PluginName

func (b *BasePluggable) PluginName() (string, error)

PluginName - Plugin Name, will return an error if name is not present or not a string

func (*BasePluggable) SetPeerPluginJobConf

func (b *BasePluggable) SetPeerPluginJobConf(conf *config.JSON)

SetPeerPluginJobConf - Sets the corresponding peer plugin's working configuration

func (*BasePluggable) SetPeerPluginName

func (b *BasePluggable) SetPeerPluginName(name string)

SetPeerPluginName - Sets the corresponding peer plugin name

func (*BasePluggable) SetPluginConf

func (b *BasePluggable) SetPluginConf(conf *config.JSON)

SetPluginConf - Sets the plugin configuration

func (*BasePluggable) SetPluginJobConf

func (b *BasePluggable) SetPluginJobConf(conf *config.JSON)

SetPluginJobConf - Sets the plugin's working configuration

type BasePlugin

type BasePlugin struct {
	*BasePluggable
}

BasePlugin: a fundamental plugin class that assists and simplifies the implementation of plugins

func NewBasePlugin

func NewBasePlugin() *BasePlugin

NewBasePlugin: a function or method to create a new instance of BasePlugin

func (*BasePlugin) Post

func (b *BasePlugin) Post(ctx context.Context) error

Post: an empty method for post-notification

func (*BasePlugin) PostHandler

func (b *BasePlugin) PostHandler(ctx context.Context, conf *config.JSON) error

PostHandler: an empty method for post-notification processing

func (*BasePlugin) PreCheck

func (b *BasePlugin) PreCheck(ctx context.Context) error

PreCheck: an empty method for pre-checking

func (*BasePlugin) PreHandler

func (b *BasePlugin) PreHandler(ctx context.Context, conf *config.JSON) error

PreHandler: an empty method for preprocessing

func (*BasePlugin) Prepare

func (b *BasePlugin) Prepare(ctx context.Context) error

Prepare: an empty method for preparation

type BaseTask

type BaseTask struct {
	*BasePlugin
	// contains filtered or unexported fields
}

BaseTask - A basic task that assists and simplifies the implementation of task interfaces

func NewBaseTask

func NewBaseTask() *BaseTask

NewBaseTask - Creates a new instance of a base task

func (*BaseTask) Format

func (b *BaseTask) Format(format string) string

Format - The format for logging messages

func (*BaseTask) JobID

func (b *BaseTask) JobID() int64

JobID - The unique identifier for a job

func (*BaseTask) SetJobID

func (b *BaseTask) SetJobID(jobID int64)

SetJobID - Sets the unique identifier for a job

func (*BaseTask) SetTaskCollector

func (b *BaseTask) SetTaskCollector(collector TaskCollector)

SetTaskCollector - Sets the task information collector

func (*BaseTask) SetTaskGroupID

func (b *BaseTask) SetTaskGroupID(taskGroupID int64)

SetTaskGroupID - Sets the unique identifier for a group of tasks

func (*BaseTask) SetTaskID

func (b *BaseTask) SetTaskID(taskID int64)

SetTaskID - Sets the unique identifier for a task

func (*BaseTask) TaskCollector

func (b *BaseTask) TaskCollector() TaskCollector

TaskCollector - Collects information related to tasks

func (*BaseTask) TaskGroupID

func (b *BaseTask) TaskGroupID() int64

TaskGroupID - The unique identifier for a group of tasks

func (*BaseTask) TaskID

func (b *BaseTask) TaskID() int64

TaskID - The unique identifier for a task

func (*BaseTask) Wrapf

func (b *BaseTask) Wrapf(err error, format string, args ...interface{}) error

Wrapf - Wraps an error with additional context

type Job

type Job interface {
	Plugin
	// Job ID: a unique identifier for a job
	JobID() int64
	// Set Job ID: a function or method to set the ID of a job
	SetJobID(jobID int64)
	Collector() JobCollector   // todo: The job collector is currently not in use
	SetCollector(JobCollector) // todo: The function or method to set the job collector is currently not in use
}

Job: a unit of work

type JobCollector

type JobCollector interface {
	JSON() *encoding.JSON
	JSONByKey(key string) *encoding.JSON
}

JobCollector: a work information collector used to collect the progress, error messages, and other information of the entire job. toto: The monitoring module is currently not implemented, so the structure of this interface needs to be implemented later.

type Pluggable

type Pluggable interface {
	// Plugin Developer, generally written in the plugin configuration
	Developer() (string, error)
	// Plugin Description, generally written in the plugin configuration
	Description() (string, error)
	// Plugin Name, generally written in the plugin configuration
	PluginName() (string, error)
	/* Plugin Configuration, basic configuration is as follows, the rest can be customized according to individual needs
	{
		"name" : "mysqlreader",
		"developer":"Breeze0806",
		"description":"use github.com/go-sql-driver/mysql. database/sql DB execute select sql, retrieve data from the ResultSet. warn: The more you know about the database, the less problems you encounter."
	}
	*/
	PluginConf() *config.JSON
	// Plugin Working Configuration
	PluginJobConf() *config.JSON
	// Corresponding Plugin Name (for Writer, it's Reader; for Reader, it's Writer)
	PeerPluginName() string
	// Corresponding Plugin Configuration (for Writer, it's Reader; for Reader, it's Writer)
	PeerPluginJobConf() *config.JSON
	// Set Working Plugin
	SetPluginJobConf(conf *config.JSON)
	// Set Corresponding Plugin Configuration (for Writer, it's Reader; for Reader, it's Writer)
	SetPeerPluginJobConf(conf *config.JSON)
	// Set Corresponding Plugin Name (for Writer, it's Reader; for Reader, it's Writer)
	SetPeerPluginName(name string)
	// Set Plugin Configuration
	SetPluginConf(conf *config.JSON)
	// Initialize Plugin, needs to be implemented by the implementer according to their needs
	Init(ctx context.Context) error
	// Destroy Plugin, needs to be implemented by the implementer according to their needs
	Destroy(ctx context.Context) error
}

Pluggable - A pluggable interface

type Plugin

type Plugin interface {
	Pluggable
	// PreCheck: a pre-processing check or verification step
	PreCheck(ctx context.Context) error
	// Prepare: a preparation step before the main operation
	Prepare(ctx context.Context) error
	// PostNotification: a notification step after the main operation
	Post(ctx context.Context) error
	// PreHandler: preprocessing, todo: currently not in use
	PreHandler(ctx context.Context, conf *config.JSON) error
	// PostHandler: post-notification processing, todo: currently not in use
	PostHandler(ctx context.Context, conf *config.JSON) error
}

Plugin: an extension or add-on component

type RecordReceiver

type RecordReceiver interface {
	GetFromReader() (element.Record, error) // Reads records from the reader
	Shutdown() error                        // Closes the receiver
}

RecordReceiver - A component that receives records

type RecordSender

type RecordSender interface {
	CreateRecord() (element.Record, error)  // Create Record
	SendWriter(record element.Record) error // Send Record to Writer
	Flush() error                           // Refresh Record to Record Sender
	Terminate() error                       // Terminate Transmission Signal
	Shutdown() error                        // Close
}

RecordSender: Record Sender

type Task

type Task interface {
	Plugin

	// Task Information Collector, todo: not currently used
	TaskCollector() TaskCollector
	// Set Task Information Collector, todo: not currently used
	SetTaskCollector(collector TaskCollector)

	// Job ID
	JobID() int64
	// Set Job ID
	SetJobID(jobID int64)
	// Task Group ID
	TaskGroupID() int64
	// Set Task Group ID
	SetTaskGroupID(taskGroupID int64)
	// Task ID
	TaskID() int64
	// Set Task ID
	SetTaskID(taskID int64)
	// Wrap Error
	Wrapf(err error, format string, args ...interface{}) error
	// Format - Log format
	Format(format string) string
}

Task - An interface for representing tasks

type TaskCollector

type TaskCollector interface {
	CollectDirtyRecordWithError(record element.Record, err error)
	CollectDirtyRecordWithMsg(record element.Record, msgErr string)
	CollectDirtyRecord(record element.Record, err error, msgErr string)
	CollectMessage(key string, value string)
}

TaskCollector: a component or system that collects task information todo: currently not in use

type Type

type Type string

Type: Plugin Type

var (
	Reader      Type = "reader"      // Reader
	Writer      Type = "writer"      // Writer
	Transformer Type = "transformer" // Converter
	Handler     Type = "handler"     // Processor
)

Plugin Type Enumeration

func NewType

func NewType(s string) Type

NewType: New Type

func (Type) IsValid

func (t Type) IsValid() bool

IsValid: Is Valid

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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