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

process

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 15 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 Exists added in v1.0.0

func Exists(name string) bool

Exists check if the process exists

func Register

func Register(name string, handler Handler)

Register register a process handler

func RegisterDynamic added in v1.0.0

func RegisterDynamic(name string, handler Handler)

RegisterDynamic dynamically registers a process handler in a thread-safe manner

func RegisterDynamicGroup added in v1.0.0

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

RegisterDynamicGroup dynamically registers a process handler group in a thread-safe manner

func RegisterGroup

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

RegisterGroup register a process handler group

func Unregister added in v1.0.0

func Unregister(name string) bool

Unregister removes a process handler in a thread-safe manner Returns true if the handler was found and removed, false otherwise

func UnregisterGroup added in v1.0.0

func UnregisterGroup(name string) int

UnregisterGroup removes all handlers in a group in a thread-safe manner Returns the number of handlers removed

Types

type AuthorizedInfo added in v1.0.0

type AuthorizedInfo struct {
	Subject   string `json:"sub,omitempty"`        // Subject identifier
	ClientID  string `json:"client_id"`            // OAuth client ID
	Scope     string `json:"scope,omitempty"`      // Access scope
	SessionID string `json:"session_id,omitempty"` // Session ID
	UserID    string `json:"user_id,omitempty"`    // User ID

	// Extended fields for multi-tenancy and team support
	TeamID     string `json:"team_id,omitempty"`     // Team identifier
	TenantID   string `json:"tenant_id,omitempty"`   // Tenant identifier
	RememberMe bool   `json:"remember_me,omitempty"` // Remember Me flag preserved from login

	// Data access constraints (set by ACL enforcement)
	Constraints DataConstraints `json:"constraints,omitempty"`
}

AuthorizedInfo represents authorized information for the process This structure matches the AuthorizedInfo from the OAuth system

func (*AuthorizedInfo) AuthorizedToMap added in v1.0.0

func (auth *AuthorizedInfo) AuthorizedToMap() map[string]interface{}

AuthorizedToMap converts AuthorizedInfo to map[string]interface{} This is useful for passing authorized information to runtime bridges (e.g., V8)

func (*AuthorizedInfo) GetTeamID added in v1.0.0

func (auth *AuthorizedInfo) GetTeamID() string

GetTeamID returns the team ID from the authorized info.

func (*AuthorizedInfo) GetUserID added in v1.0.0

func (auth *AuthorizedInfo) GetUserID() string

GetUserID returns the user ID from the authorized info.

type CallbackFunc added in v1.0.0

type CallbackFunc func(process *Process, data map[string]interface{}) error

CallbackFunc the callback function

type DataConstraints added in v1.0.0

type DataConstraints struct {
	// Built-in constraints
	OwnerOnly   bool // Only access owner's data (current owner)
	CreatorOnly bool // Only access creator's data (who created the resource)
	EditorOnly  bool // Only access editor's data (who last updated the resource)
	TeamOnly    bool // Only access team's data (filter by TeamID)

	// Extra constraints (user-defined, flexible extension)
	Extra map[string]interface{} // Custom constraints like department_only, region_only, etc.
}

DataConstraints represents data access constraints for the process

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
	V8Context  interface{}            `json:"-"` // V8 Context (for thread affinity in JavaScript calls)
	Runtime    Runtime                `json:"-"` // Runtime
	Callback   CallbackFunc           `json:"-"` // Callback
	Authorized *AuthorizedInfo        `json:"-"` // Authorized information (set by OAuth guard)
	// contains filtered or unexported fields
}

Process the process sturct

func New

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

New make a new process

func NewWithContext added in v1.0.0

func NewWithContext(ctx context.Context, name string, args ...interface{}) *Process

NewWithContext make a new process with context

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) ExecuteSync added in v1.0.0

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

ExecuteSync execute the process synchronously in current thread (for V8 context sharing) This method is designed for calls from JavaScript with shared V8 context It executes in the current thread without creating goroutines to maintain thread affinity

func (*Process) GetAuthorized added in v1.0.0

func (process *Process) GetAuthorized() *AuthorizedInfo

GetAuthorized returns the authorized information from the process

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) String added in v1.0.0

func (process Process) String() string

String the process as string

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) WithAuthorized added in v1.0.0

func (process *Process) WithAuthorized(authorized interface{}) *Process

WithAuthorized set the authorized information Accepts either *AuthorizedInfo or map[string]interface{}

func (*Process) WithCallback added in v1.0.0

func (process *Process) WithCallback(callback CallbackFunc) *Process

WithCallback set the callback function

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

func (*Process) WithV8Context added in v1.0.0

func (process *Process) WithV8Context(v8ctx interface{}) *Process

WithV8Context set the V8 context for thread affinity

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