Documentation
¶
Index ¶
- Constants
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func AllPlugins() map[string]PluginMeta
- func Decrypt(encKey, encryptedText string) (string, error)
- func Encrypt(encKey, plainText string) (string, error)
- func FindPluginNameBySubPkgPath(subPkgPath string) (string, error)
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func RandomCapsStr(len int) string
- func RandomEncKey() string
- func RegisterPlugin(name string, plugin PluginMeta) error
- type ApiResourceHandler
- type ApiResourceInput
- type ApiResourceOutput
- type ExecContext
- type LogLevel
- type Logger
- type Migratable
- type PluginApi
- type PluginInit
- type PluginMeta
- type PluginTask
- type ProgressType
- type RunningProgress
- type SubTask
- type SubTaskContext
- type SubTaskEntryPoint
- type SubTaskMeta
- type TaskContext
Constants ¶
const EncodeKeyEnvStr = "ENCODE_KEY"
Variables ¶
This section is empty.
Functions ¶
func AllPlugins ¶
func AllPlugins() map[string]PluginMeta
func Encrypt ¶
TODO: maybe move encryption/decryption into helper? AES + Base64 encryption using ENCODE_KEY in .env as key
func RandomCapsStr ¶
A random string of length len uppercase characters
func RandomEncKey ¶
func RandomEncKey() string
func RegisterPlugin ¶
func RegisterPlugin(name string, plugin PluginMeta) error
Types ¶
type ApiResourceHandler ¶
type ApiResourceHandler func(input *ApiResourceInput) (*ApiResourceOutput, error)
type ApiResourceInput ¶
type ApiResourceInput struct {
Params map[string]string // path variables
Query url.Values // query string
Body map[string]interface{} // json body
}
Contains api request information
type ApiResourceOutput ¶
type ApiResourceOutput struct {
Body interface{} // response body
Status int
}
Describe response data of a api
type ExecContext ¶
type ExecContext interface {
GetName() string
GetConfig(name string) string
GetDb() *gorm.DB
GetContext() context.Context
GetLogger() Logger
GetData() interface{}
SetProgress(current int, total int)
IncProgress(quantity int)
}
This interface define all resources that needed for task/subtask execution
type Logger ¶
type Logger interface {
IsLevelEnabled(level LogLevel) bool
Printf(format string, a ...interface{})
Log(level LogLevel, format string, a ...interface{})
Debug(format string, a ...interface{})
Info(format string, a ...interface{})
Warn(format string, a ...interface{})
Error(format string, a ...interface{})
// return a new logger which output nested log
Nested(name string) Logger
}
General logger interface, can be used any where
type Migratable ¶
type PluginApi ¶
type PluginApi interface {
ApiResources() map[string]map[string]ApiResourceHandler
}
Implement this interface if plugin offered API Code sample to register a api on `sources/:connectionId`:
func (plugin Jira) ApiResources() map[string]map[string]core.ApiResourceHandler {
return map[string]map[string]core.ApiResourceHandler{
"connections/:connectionId": {
"PUT": api.PutConnection,
"DELETE": api.DeleteConnection,
"GET": api.GetConnection,
},
}
}
type PluginInit ¶
Implement this interface if plugin needed some initialization
type PluginMeta ¶
type PluginMeta interface {
Description() string
// PkgPath information lost when compiled as plugin(.so)
RootPkgPath() string
}
Minimal features a plugin should comply, should be implemented by all plugins
func GetPlugin ¶
func GetPlugin(name string) (PluginMeta, error)
type PluginTask ¶
type PluginTask interface {
// return all available subtasks, framework will run them for you in order
SubTaskMetas() []SubTaskMeta
// based on task context and user input options, return data that shared among all subtasks
PrepareTaskData(taskCtx TaskContext, options map[string]interface{}) (interface{}, error)
}
Implement this interface to let framework run tasks for you
type ProgressType ¶
type ProgressType int
const ( TaskSetProgress ProgressType = iota TaskIncProgress SubTaskSetProgress SubTaskIncProgress SetCurrentSubTask )
type RunningProgress ¶
type RunningProgress struct {
Type ProgressType
Current int
Total int
SubTaskName string
SubTaskNumber int
}
type SubTaskContext ¶
type SubTaskContext interface {
ExecContext
TaskContext() TaskContext
}
This interface define all resources that needed for subtask execution
type SubTaskEntryPoint ¶
type SubTaskEntryPoint func(c SubTaskContext) error
All subtasks from plugins should comply to this prototype, so they could be orchestrated by framework
type SubTaskMeta ¶
type SubTaskMeta struct {
Name string
EntryPoint SubTaskEntryPoint
// Required SubTask will be executed no matter what
Required bool
EnabledByDefault bool
Description string
}
Meta data of a subtask
type TaskContext ¶
type TaskContext interface {
ExecContext
SetData(data interface{})
SubTaskContext(subtask string) (SubTaskContext, error)
}
This interface define all resources that needed for task execution