Documentation
¶
Index ¶
- Variables
- func Alias(name string, alias string)
- func Exists(name string) bool
- func Register(name string, handler Handler)
- func RegisterDynamic(name string, handler Handler)
- func RegisterDynamicGroup(name string, group map[string]Handler)
- func RegisterGroup(name string, group map[string]Handler)
- func Unregister(name string) bool
- func UnregisterGroup(name string) int
- type AuthorizedInfo
- type CallbackFunc
- type DataConstraints
- type Handler
- type Process
- func (process *Process) ArgsArray(index int) []interface{}
- func (process *Process) ArgsBool(i int, defaults ...bool) bool
- func (process *Process) ArgsInt(i int, defaults ...int) int
- func (process *Process) ArgsMap(i int, defaults ...maps.MapStrAny) maps.MapStrAny
- func (process *Process) ArgsNotNull(i int)
- func (process *Process) ArgsQueryParams(i int, defaults ...types.QueryParam) types.QueryParam
- func (process *Process) ArgsRecords(index int) []map[string]interface{}
- func (process *Process) ArgsString(i int, defaults ...string) string
- func (process *Process) ArgsStrings(index int) []string
- func (process *Process) ArgsURLValue(i int, name string, defaults ...string) string
- func (process *Process) ArgsUint32(i int, defaults ...uint32) uint32
- func (process *Process) Dispose()
- func (process *Process) Exec() (value interface{}, err error)
- func (process *Process) Execute() (err error)
- func (process *Process) ExecuteSync() (err error)
- func (process *Process) GetAuthorized() *AuthorizedInfo
- func (process *Process) NumOfArgs() int
- func (process *Process) NumOfArgsIs(num int) bool
- func (process *Process) Release()
- func (process *Process) Run() interface{}
- func (process Process) String() string
- func (process *Process) ValidateArgNums(length int)
- func (process *Process) Value() interface{}
- func (process *Process) WithAuthorized(authorized interface{}) *Process
- func (process *Process) WithCallback(callback CallbackFunc) *Process
- func (process *Process) WithContext(ctx context.Context) *Process
- func (process *Process) WithGlobal(global map[string]interface{}) *Process
- func (process *Process) WithRuntime(runtime Runtime) *Process
- func (process *Process) WithSID(sid string) *Process
- func (process *Process) WithV8Context(v8ctx interface{}) *Process
- type Runtime
Constants ¶
This section is empty.
Variables ¶
var Handlers = map[string]Handler{}
Handlers ProcessHanlders
Functions ¶
func RegisterDynamic ¶ added in v1.0.0
RegisterDynamic dynamically registers a process handler in a thread-safe manner
func RegisterDynamicGroup ¶ added in v1.0.0
RegisterDynamicGroup dynamically registers a process handler group in a thread-safe manner
func RegisterGroup ¶
RegisterGroup register a process handler group
func Unregister ¶ added in v1.0.0
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
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
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 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 NewWithContext ¶ added in v1.0.0
NewWithContext make a new process with context
func (*Process) ArgsNotNull ¶
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 ¶
ArgsRecords 读取 []map[string]interface{} 参数值
func (*Process) ArgsString ¶
ArgsString 读取参数 String
func (*Process) ArgsStrings ¶
ArgsStrings 读取 []string 参数值
func (*Process) ArgsURLValue ¶
ArgsURLValue 读取参数
func (*Process) ArgsUint32 ¶
ArgsUint32 get Uint32
func (*Process) Dispose ¶ added in v1.0.0
func (process *Process) Dispose()
Dispose the process after run success
func (*Process) Exec ¶
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) ExecuteSync ¶ added in v1.0.0
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) NumOfArgsIs ¶
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 ¶
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
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
WithContext set the context
func (*Process) WithGlobal ¶
WithGlobal set the global vars
func (*Process) WithRuntime ¶ added in v1.0.0
WithRuntime set the runtime interface
func (*Process) WithV8Context ¶ added in v1.0.0
WithV8Context set the V8 context for thread affinity