core

package
v0.0.0-...-34fcd26 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

The program is use the agent to schedule the plugin. The return value of the plugin is stored in the result channel. There will be a pool of transaction that used to store the plugin that is running. The transaction will be executed in parallel.

Description: This is the Go function that frontend can call for. Author: Hughie21 Date: 2024-09-16 license that can be found in the LICENSE file.

Description: the core package is the core of the program, it is used to manage the configuration, the agent, and the logger. Author: Hughie21 Date: 2024-11-21 license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	TransactionStateWaiting = iota
	TransactionStateRunning
)

Variables

This section is empty.

Functions

func FileOpenDialog

func FileOpenDialog(app *App, displayName string, pattern string) string

func FileSaveDialog

func FileSaveDialog(app *App, filename string, pattern string) string

Types

type Agent

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

Agent is a manager for all plugins, so there is map that store all the registered plugins. The context that carraied by the agent is used to cancel the plugin when the app is shutdown. The timeout that represent the time to wait for the plugin to find a empty transaction.

func NewAgent

func NewAgent(size int, timeout time.Duration) *Agent

NewAgent create a new agent with the size of the transaction pool and the timeout for the plugin to execute the size of the pool and the timeout are defined at the config file.

func (*Agent) Close

func (agt *Agent) Close()

func (*Agent) Exec

func (agt *Agent) Exec(name string, args ...interface{}) Result

func (*Agent) RegisterPlugin

func (agt *Agent) RegisterPlugin(name string, plugin Pluginer) error

type App

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

App struct

func NewApp

func NewApp() *App

NewApp creates a new App application struct

func (*App) Base64Decode

func (a *App) Base64Decode(str string) string

func (*App) Base64Encode

func (a *App) Base64Encode(str string) string

func (*App) DirectLoading

func (a *App) DirectLoading() Message

func (*App) FileDelete

func (a *App) FileDelete(name string) Message

corresponding to the "Delete" button on the "insert picture"

func (*App) FileOpen

func (a *App) FileOpen() Message

func (*App) FileSave

func (a *App) FileSave(name string, rawJson string, skip bool) Message

corresponding to the "Save" button on the frontend

func (*App) Fr

func (a *App) Fr(path string) string

return the raw data of file

func (*App) GetConfig

func (a *App) GetConfig(sector string, key string) Message

get the configure

func (*App) GetImageData

func (a *App) GetImageData(filename string) Message

get the base64 string of the image

func (*App) GetStaticResources

func (a *App) GetStaticResources() Message

get the static resources list of the loacl server

func (*App) GetVersion

func (a *App) GetVersion()

func (*App) ImageDownload

func (a *App) ImageDownload(url string) Message

func (*App) ImageUpload

func (a *App) ImageUpload() ImageFIle

corresponding to the "Upload" button on the "insert picture"

func (*App) LoadImage

func (a *App) LoadImage(data string) Message

func (*App) NewFile

func (a *App) NewFile() Message

func (*App) OpenImage

func (a *App) OpenImage() Message

corresponding to the "Cover Upload" on the "Book info"

func (*App) SetConfig

func (a *App) SetConfig(sector string, key string, value string) Message

func (*App) Trace

func (a *App) Trace(source, stack string)

type Core

type Core struct {
	Args string
	// contains filtered or unexported fields
}

func NewCore

func NewCore() *Core

NewCore create a new core instance, it is a singleton.

func (*Core) Init

func (c *Core) Init(assets embed.FS, app *App) *options.App

type EpubReader

type EpubReader struct {
	PluginInfo
	// contains filtered or unexported fields
}

func NewEpubReader

func NewEpubReader(tempDir string) *EpubReader

func (*EpubReader) Run

func (e *EpubReader) Run(ctx context.Context, args ...interface{}) (interface{}, error)

type EpubWriter

type EpubWriter struct {
	PluginInfo
	// contains filtered or unexported fields
}

func NewEpubWriter

func NewEpubWriter(tempDir string) *EpubWriter

func (*EpubWriter) Run

func (e *EpubWriter) Run(ctx context.Context, args ...interface{}) (interface{}, error)

type ImageFIle

type ImageFIle struct {
	Code int
	Name string
	Id   string
}

type Message

type Message struct {
	Code int
	Msg  string
	Data string
}

the message formula that communiacte with the frontend

type PluginInfo

type PluginInfo struct {
	Name     string
	Type     string
	Priority int
	Version  string
	Author   string
	Email    string
	Source   string
}

func (*PluginInfo) Info

func (p *PluginInfo) Info() PluginInfo

type Pluginer

type Pluginer interface {
	Run(context.Context, ...interface{}) (interface{}, error)
	Info() PluginInfo
}

type Result

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

the result carry the data and error of the plugin

func (*Result) Data

func (r *Result) Data() interface{}

func (*Result) Err

func (r *Result) Err() error

type Transaction

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

func NewTransaction

func NewTransaction() *Transaction

Jump to

Keyboard shortcuts

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