Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListScripts ¶ added in v0.28.0
func ListScripts() []string
ListScripts returns the names of all loaded script plugins (without the "script:" prefix).
func LoadScripts ¶ added in v0.28.0
LoadScripts loads all executable scripts from a directory as command plugins. Scripts are registered as custom commands that can be invoked via `tinker plugin run <name>`.
Types ¶
type Context ¶ added in v0.28.0
type Context struct {
Data map[string]interface{}
}
Context carries data to and from hook handlers.
func NewContext ¶ added in v0.28.0
func NewContext() *Context
NewContext creates an empty hook context.
type Handler ¶ added in v0.28.0
Handler is a function that handles a hook invocation. It can modify the context and optionally return an error to abort the chain.
type Hook ¶ added in v0.28.0
type Hook string
Hook represents a named entry point where plugins can register behavior.
const ( // HookPreDBQuery runs before a database query is executed. HookPreDBQuery Hook = "pre_db_query" // HookPostDBQuery runs after a database query is executed. HookPostDBQuery Hook = "post_db_query" // HookPreAPIRequest runs before an API request is sent. HookPreAPIRequest Hook = "pre_api_request" // HookPostAPIRequest runs after an API response is received. HookPostAPIRequest Hook = "post_api_request" // HookPreGRPCCall runs before a gRPC call. HookPreGRPCCall Hook = "pre_grpc_call" // HookPostGRPCCall runs after a gRPC call. HookPostGRPCCall Hook = "post_grpc_call" // HookInit runs during tinker init after auto-detection. HookInit Hook = "init" )
type Plugin ¶ added in v0.28.0
type Plugin struct {
Name string
Description string
Version string
Meta map[string]interface{}
// contains filtered or unexported fields
}
Plugin represents a loaded plugin with its metadata and registered hooks.
type Registry ¶ added in v0.28.0
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all loaded plugins and dispatches hooks.
func NewRegistry ¶ added in v0.28.0
func NewRegistry() *Registry
NewRegistry creates a new empty registry.
func (*Registry) Dispatch ¶ added in v0.28.0
Dispatch sends a hook event to all registered handlers across all plugins. Handlers are called in plugin registration order. If any handler returns an error, dispatch stops and returns that error.
func (*Registry) ListPlugins ¶ added in v0.28.0
ListPlugins returns all registered plugins with their info.
func (*Registry) Unregister ¶ added in v0.28.0
Unregister removes a plugin from the registry.