etypes

package
v0.0.0-...-8c2001a Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyUserContext = "Empty user context"

	ResourceModuleNotFound = "Resource: module not found"
	ResourceWrongType      = "Resource: wrong type"
	ResourceNotFound       = "Resource: not found"

	LinkNotFound = "Link: not found"
)

Functions

This section is empty.

Types

type AdminLaunchData

type AdminLaunchData struct {
	PlugId  string `json:"plug_id,omitempty"`
	AgentId string `json:"agent_id,omitempty"`
}

type AgentIface

type AgentIface struct {
	Name        string                `json:"name,omitempty"`
	Definations map[string]any        `json:"definations,omitempty"`
	Methods     map[string]*Method    `json:"methods,omitempty"`
	Events      map[string]*EventType `json:"events,omitempty"`
	Schemas     map[string]*ValueType `json:"schemas,omitempty"`
}

type AuthLaunchData

type AuthLaunchData struct{}

type BootData

type BootData struct {
	TenantId   string `json:"tenant_id,omitempty"`
	ApiBaseURL string `json:"api_base_url,omitempty"`
	PlugId     string `json:"plug_id,omitempty"`
	AgentId    string `json:"agent_id,omitempty"`
	EntryName  string `json:"entry_name,omitempty"`
	ExecLoader string `json:"exec_loader,omitempty"`
}

type BuilderFactory

type BuilderFactory func(app any) (ExecutorBuilder, error)

type DebugMessage

type DebugMessage struct {
	EventId  string   `json:"event_id,omitempty"`
	PlugId   string   `json:"plug_id,omitempty"`
	AgentId  string   `json:"agent_id,omitempty"`
	Messages []string `json:"messages,omitempty"`
}

type Engine

type Engine interface {
	Run() error
	GetRuntime() Runtime
	ListExecutors() []string
	ListModules() []string

	Execute(options Execution) ([]byte, error)

	ServeAgentFile(tenantId, plugId, agentId, file string) ([]byte, error)
	ServeExecutorFile(tenantId, plugId, agentId, file string) ([]byte, error)
}

type EngineHub

type EngineHub interface {
	GetEngine() Engine
	Start() error

	LaunchTargetDomain(tenantId, host, plugId, agentId string) (*LaunchDomainOptions, error)
	LaunchTarget(uclaim *claim.Session, data TargetLaunchData) (*LaunchOptions, error)
	LaunchAdmin(uclaim *claim.Session, data AdminLaunchData) (*LaunchOptions, error)

	Execute(tenantId, action string, ctx *gin.Context)
	ExecuteDev(dclaim *claim.UserContext, plug, agent, action string, body []byte) ([]byte, error)
	Reset(tenantId, plugId, agentId string) error

	ServeAgentFile(tenantId, plugId, agentId, file string) ([]byte, error)
	ServeExecutorFile(tenantId, plugId, agentId, file string) ([]byte, error)
	ListExecutors() ([]string, error)
	ListModules() ([]string, error)

	RunStartupHooks(tenants []string, minwait time.Duration)
}

EngineHub is sits on top of Engine, Launch are related to TargetApps, Run are related to TargetHooks.

type EventType

type EventType struct {
	Info       string     `json:"info,omitempty"`
	Async      bool       `json:"async,omitempty"`
	ArgData    ValueType  `json:"arg_data,omitempty"`
	ReturnData *ValueType `json:"return_data,omitempty"`
}

type ExecBuilderFunc

type ExecBuilderFunc func(ExecutorOption) (Executor, error)

func (ExecBuilderFunc) ExecFile

func (e ExecBuilderFunc) ExecFile(file string) ([]byte, error)

func (ExecBuilderFunc) IfaceFile

func (e ExecBuilderFunc) IfaceFile() (*ExecutorIface, error)

func (ExecBuilderFunc) Instance

func (e ExecBuilderFunc) Instance(opts ExecutorOption) (Executor, error)

type ExecPool

type ExecPool interface {
	Borrow(plugId, agentId string) (bindx.Bindings, int)
	Destroy(plugId string, agentIds []string)
	Return(b bindx.Bindings)
	SetEpoch(plug, agent string, e int64)
	PoolId() int
}

type Execution

type Execution struct {
	TenantId string
	PlugId   string
	AgentId  string
	Action   string
	Payload  []byte
	Invoker  invoker.Invoker
}

type Executor

type Executor interface {
	Process(*event.Request) (*event.Response, error)
}

type ExecutorBinder

type ExecutorBinder interface {
	bindx.Bindings

	GetApp() any
	GetLogger() *zerolog.Logger
	GetModuleInstance(id uint32) any

	AttachJob(j *job.Job)
	Execute() (*event.Response, error)
}

type ExecutorBuilder

type ExecutorBuilder interface {
	Instance(ExecutorOption) (Executor, error)
	ExecFile(file string) ([]byte, error)
	IfaceFile() (*ExecutorIface, error)
}

type ExecutorIface

type ExecutorIface struct {
	Methods     map[string]*Method    `json:"methods,omitempty"`
	Events      map[string]*EventType `json:"events,omitempty"`
	Schemas     map[string]*ValueType `json:"schemas,omitempty"`
	Bindings    map[string]*Method    `json:"bindings,omitempty"`
	Definations map[string]any        `json:"definations,omitempty"`
}

type ExecutorOption

type ExecutorOption struct {
	Binder   bindx.Bindings
	TenantId string
	PlugId   string
	AgentId  string
	File     string
	ExecType string
	EnvVars  map[string]string
}

type LaunchDomainOptions

type LaunchDomainOptions struct {
	LoaderScript string
	ScriptFile   string
	StyleFile    string
	ExtScripts   map[string]string
	BootData     string
	ApiBaseURL   string
	PlugId       string
	AgentId      string
	Name         string
	ExecLoader   string
}

type LaunchOptions

type LaunchOptions struct {
	ApiBaseURL   string            `json:"api_base_url,omitempty"`
	Token        string            `json:"token,omitempty"`
	EntryName    string            `json:"entry,omitempty"`
	ExecLoader   string            `json:"exec_loader,omitempty"`
	JSPlugScript string            `json:"js_plug_script,omitempty"`
	StyleFile    string            `json:"style,omitempty"`
	ExtScripts   map[string]string `json:"ext_scripts,omitempty"`
	Plug         string            `json:"plug,omitempty"`
	Agent        string            `json:"agent,omitempty"`
}

type Method

type Method struct {
	Info       string            `json:"info,omitempty"`
	Arg        ValueType         `json:"arg,omitempty"`
	ReturnType ValueType         `json:"return_type,omitempty"`
	ErrorTypes map[string]string `json:"error_types,omitempty"` // <error_id, error_info>
}

type ModExecOptions

type ModExecOptions struct {
	PlugId  string
	AgentId string
	Mod     string
	Method  string
	Data    xtypes.LazyData
}

type Module

type Module interface {
	Handle(method string, args xtypes.LazyData) (xtypes.LazyData, error)
	Close() error
}

type ModuleBuilder

type ModuleBuilder interface {
	Instance(ModuleOptions) (Module, error)
}

type ModuleBuilderFunc

type ModuleBuilderFunc func(app any) (ModuleBuilder, error)

type ModuleOptions

type ModuleOptions struct {
	Binder       ExecutorBinder
	Resource     *entities.Resource
	InvokerToken string
	Args         xtypes.LazyData
}

type PoolManager

type PoolManager interface {
	CloseSidePool(id int)
	GetSidePool() ExecPool

	RootPool() ExecPool
}

type Router

type Router interface {
	Route(j *job.Job) (*event.Response, error)
}

type RunningExec

type RunningExec struct {
	EventId  string
	BprintId string
	PlugId   string
	AgentId  string
}

type Runtime

type Runtime interface {
	Run(map[string]ExecutorBuilder, map[string]ModuleBuilder) error

	Preform(j *job.Job) (*event.Response, error)
	PreformAsync(j *job.AsyncJob)

	ResetAgents(tenantId, plug string, agents []string)
	ResetBprint(tenantId, bprint string)
	ListRunning(tenantId string) ([]RunningExec, error)
}

type TargetLaunchData

type TargetLaunchData struct {
	TargetId   int64  `json:"target_id,omitempty"`
	TargetType string `json:"target_type,omitempty"`
}

type ValueType

type ValueType struct {
	Type         string      `json:"type,omitempty"`
	Values       []ValueType `json:"values,omitempty"`
	PropertyName string      `json:"property,omitempty"` // only applicable to object
	Ref          string      `json:"ref,omitempty"`      // (type, valye, prop_name) ||  ref to schema key
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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