Documentation
¶
Index ¶
- Constants
- type EventBusInterface
- type EventData
- type Handler
- type Interface
- type ManagerInterface
- type Metadata
- type OptionalImpl
- func (o *OptionalImpl) Cleanup() error
- func (o *OptionalImpl) GetServiceInfo() *ServiceInfo
- func (o *OptionalImpl) NeedServiceDiscovery() bool
- func (o *OptionalImpl) PostInit() error
- func (o *OptionalImpl) PreCleanup() error
- func (o *OptionalImpl) PreInit() error
- func (o *OptionalImpl) RegisterRoutes(router *gin.RouterGroup)
- func (o *OptionalImpl) Status() string
- type OptionalMethods
- type PluginLoaderInterface
- type Service
- type ServiceDiscoveryInterface
- type ServiceInfo
- type Wrapper
Constants ¶
const ( ServiceStatusHealthy = "healthy" ServiceStatusUnhealthy = "unhealthy" ServiceStatusUnknown = "unknown" )
Service Status constants
const ( // StatusActive indicates the extension is running normally StatusActive = "active" // StatusInactive indicates the extension is installed but not running StatusInactive = "inactive" // StatusError indicates the extension encountered an error StatusError = "error" // StatusInitializing indicates the extension is in initialization process StatusInitializing = "initializing" // StatusMaintenance indicates the extension is under maintenance StatusMaintenance = "maintenance" // StatusDisabled indicates the extension has been manually disabled StatusDisabled = "disabled" )
Extension status constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBusInterface ¶
type EventBusInterface interface {
Subscribe(eventName string, handler func(any))
Publish(eventName string, data any)
PublishWithRetry(eventName string, data any, maxRetries int)
GetMetrics() map[string]any
}
EventBusInterface defines the interface for event bus operations
type Interface ¶
type Interface interface {
// Name returns the name of the extension
Name() string
// Init initializes the extension with the given config
Init(conf *config.Config, m ManagerInterface) error
// GetHandlers returns the handlers for the extension
GetHandlers() Handler
// GetServices returns the services for the extension
GetServices() Service
// GetMetadata returns the metadata of the extension
GetMetadata() Metadata
// Version returns the version of the extension
Version() string
// Dependencies returns the dependencies of the extension
Dependencies() []string
// OptionalMethods returns the optional methods of the extension
OptionalMethods
}
Interface defines the structure for an extension (Plugin / Module)
type ManagerInterface ¶
type ManagerInterface interface {
GetConfig() *config.Config
Register(ext Interface) error
InitExtensions() error
GetExtension(name string) (Interface, error)
GetExtensions() map[string]*Wrapper
Cleanup()
GetHandler(name string) (Handler, error)
GetHandlers() map[string]Handler
GetService(name string) (Service, error)
GetServices() map[string]Service
GetMetadata() map[string]Metadata
GetStatus() map[string]string
LoadPlugins() error
LoadPlugin(path string) error
ReloadPlugin(name string) error
UnloadPlugin(name string) error
ReloadPlugins() error
PublishEvent(eventName string, data any)
SubscribeEvent(eventName string, handler func(any))
RegisterConsulService(name string, info *ServiceInfo) error
DeregisterConsulService(name string) error
GetConsulService(name string) (*api.AgentService, error)
CheckServiceHealth(name string) string
GetHealthyServices(name string) ([]*api.ServiceEntry, error)
GetServiceCacheStats() map[string]any
RegisterRoutes(router *gin.Engine)
ManageRoutes(router *gin.RouterGroup)
ExecuteWithCircuitBreaker(extensionName string, fn func() (any, error)) (any, error)
PublishMessage(exchange, routingKey string, body []byte) error
SubscribeToMessages(queue string, handler func([]byte) error) error
}
ManagerInterface defines the interface for extension manager operations
type Metadata ¶
type Metadata struct {
// Name is the name of the extension
Name string `json:"name,omitempty"`
// Version is the version of the extension
Version string `json:"version,omitempty"`
// Dependencies are the dependencies of the extension
Dependencies []string `json:"dependencies,omitempty"`
// Description is the description of the extension
Description string `json:"description,omitempty"`
// Type is the type of the extension, e.g. core, business, plugin, module, etc
Type string `json:"type,omitempty"`
// Group is the belong group of the extension, e.g. iam, res, flow, sys, org, rt, plug, etc
Group string `json:"group,omitempty"`
}
Metadata represents the metadata of an extension
type OptionalImpl ¶
type OptionalImpl struct{}
OptionalImpl implements the optional methods
func (*OptionalImpl) Cleanup ¶
func (o *OptionalImpl) Cleanup() error
Cleanup cleans up the extension
func (*OptionalImpl) GetServiceInfo ¶
func (o *OptionalImpl) GetServiceInfo() *ServiceInfo
GetServiceInfo returns service registration info if NeedServiceDiscovery returns true
func (*OptionalImpl) NeedServiceDiscovery ¶
func (o *OptionalImpl) NeedServiceDiscovery() bool
NeedServiceDiscovery returns if the extension needs to be registered as a service
func (*OptionalImpl) PostInit ¶
func (o *OptionalImpl) PostInit() error
PostInit performs any necessary setup after initialization
func (*OptionalImpl) PreCleanup ¶
func (o *OptionalImpl) PreCleanup() error
PreCleanup performs any necessary cleanup before the main cleanup
func (*OptionalImpl) PreInit ¶
func (o *OptionalImpl) PreInit() error
PreInit performs any necessary setup before initialization
func (*OptionalImpl) RegisterRoutes ¶
func (o *OptionalImpl) RegisterRoutes(router *gin.RouterGroup)
RegisterRoutes registers routes for the extension
func (*OptionalImpl) Status ¶
func (o *OptionalImpl) Status() string
Status returns the status of the extension
type OptionalMethods ¶
type OptionalMethods interface {
// PreInit performs any necessary setup before initialization
PreInit() error
// PostInit performs any necessary setup after initialization
PostInit() error
// RegisterRoutes registers routes for the extension (optional)
RegisterRoutes(router *gin.RouterGroup)
// PreCleanup performs any necessary cleanup before the main cleanup
PreCleanup() error
// Cleanup cleans up the extension
Cleanup() error
// Status returns the status of the extension
Status() string
// NeedServiceDiscovery returns if the extension needs to be registered as a service
NeedServiceDiscovery() bool
// GetServiceInfo returns service registration info if NeedServiceDiscovery returns true
GetServiceInfo() *ServiceInfo
}
OptionalMethods represents the optional methods for an extension
type PluginLoaderInterface ¶
type PluginLoaderInterface interface {
LoadPlugin(path string, manager ManagerInterface) error
UnloadPlugin(name string) error
GetPlugin(name string) *Wrapper
GetPlugins() map[string]*Wrapper
RegisterPlugin(ext Interface, metadata Metadata)
GetRegisteredPlugins() []*Wrapper
}
PluginLoaderInterface defines the interface for plugin loading/unloading
type ServiceDiscoveryInterface ¶
type ServiceDiscoveryInterface interface {
RegisterService(name string, info *ServiceInfo) error
DeregisterService(name string) error
GetService(name string) (*api.AgentService, error)
CheckServiceHealth(name string) string
GetHealthyServices(name string) ([]*api.ServiceEntry, error)
SetCacheTTL(ttl time.Duration)
ClearCache()
GetCacheStats() map[string]any
}
ServiceDiscoveryInterface defines the interface for service discovery operations