Help us shape the future of Go! Take the 2026 Go Developer Survey

process

package
v0.10.4-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handlers = map[string]Handler{}

Handlers ProcessHanlders

Functions

func Alias

func Alias(name string, alias string)

Alias set an alias a process

func Register

func Register(name string, handler Handler)

Register register a process handler

func RegisterGroup

func RegisterGroup(name string, group map[string]Handler)

RegisterGroup register a process handler group

Types

type Handler

type Handler func(process *Process) interface{}

Handler the process handler

type Process

type Process struct {
	Name    string
	Group   string
	Method  string
	Handler string
	ID      string
	Args    []interface{}
	Global  map[string]interface{} // Global vars
	Sid     string                 // Session ID
	Context context.Context        // Context
	Runtime Runtime                // Runtime
	// contains filtered or unexported fields
}

Process the process sturct

func New

func New(name string, args ...interface{}) *Process

New make a new process

func Of

func Of(name string, args ...interface{}) (*Process, error)

Of make a new process and return error

func (*Process) ArgsArray

func (process *Process) ArgsArray(index int) []interface{}

ArgsArray 读取 []interface{} 参数值

func (*Process) ArgsBool

func (process *Process) ArgsBool(i int, defaults ...bool) bool

ArgsBool 读取参数 String

func (*Process) ArgsInt

func (process *Process) ArgsInt(i int, defaults ...int) int

ArgsInt 读取参数 Int

func (*Process) ArgsMap

func (process *Process) ArgsMap(i int, defaults ...maps.MapStrAny) maps.MapStrAny

ArgsMap 读取Map 类型参数

func (*Process) ArgsNotNull

func (process *Process) ArgsNotNull(i int)

ArgsNotNull parameters should be not null

func (*Process) ArgsQueryParams

func (process *Process) ArgsQueryParams(i int, defaults ...types.QueryParam) types.QueryParam

ArgsQueryParams 读取参数 QueryParam

func (*Process) ArgsRecords

func (process *Process) ArgsRecords(index int) []map[string]interface{}

ArgsRecords 读取 []map[string]interface{} 参数值

func (*Process) ArgsString

func (process *Process) ArgsString(i int, defaults ...string) string

ArgsString 读取参数 String

func (*Process) ArgsStrings

func (process *Process) ArgsStrings(index int) []string

ArgsStrings 读取 []string 参数值

func (*Process) ArgsURLValue

func (process *Process) ArgsURLValue(i int, name string, defaults ...string) string

ArgsURLValue 读取参数

func (*Process) ArgsUint32

func (process *Process) ArgsUint32(i int, defaults ...uint32) uint32

ArgsUint32 get Uint32

func (*Process) Dispose added in v1.0.0

func (process *Process) Dispose()

Dispose the process after run success

func (*Process) Exec

func (process *Process) Exec() (value interface{}, err error)

Exec execute the process and return error

****

This function causes a memory leak, will be disposed in the future, Use Execute() instead Example:

process := Of("models.user.pet.Find", 1, {})
err := process.Execute();
if err != nil {
 	// handle error
}
defer process.Release()  // or  process.Dispose() if you want to relese the runtime isolate after run success
result := process.Value() // Get the result

****

func (*Process) Execute added in v1.0.0

func (process *Process) Execute() (err error)

Execute execute the process and return error only

func (*Process) NumOfArgs

func (process *Process) NumOfArgs() int

NumOfArgs get the parameters numbers

func (*Process) NumOfArgsIs

func (process *Process) NumOfArgsIs(num int) bool

NumOfArgsIs check if the number of parameters is the given value

func (*Process) Release added in v1.0.0

func (process *Process) Release()

Release the value of the process

func (*Process) Run

func (process *Process) Run() interface{}

Run the process ****

This function causes a memory leak, will be disposed in the future, Use Execute() instead

****

func (*Process) ValidateArgNums

func (process *Process) ValidateArgNums(length int)

ValidateArgNums Validate the parameters numbers

func (*Process) Value added in v1.0.0

func (process *Process) Value() interface{}

Value get the result of the process

func (*Process) WithContext added in v1.0.0

func (process *Process) WithContext(ctx context.Context) *Process

WithContext set the context

func (*Process) WithGlobal

func (process *Process) WithGlobal(global map[string]interface{}) *Process

WithGlobal set the global vars

func (*Process) WithRuntime added in v1.0.0

func (process *Process) WithRuntime(runtime Runtime) *Process

WithRuntime set the runtime interface

func (*Process) WithSID

func (process *Process) WithSID(sid string) *Process

WithSID set the session id

type Runtime added in v1.0.0

type Runtime interface {
	Dispose()
}

Runtime interface

Jump to

Keyboard shortcuts

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