Documentation
¶
Index ¶
- type BlockHookData
- type DifficultyHookData
- type Event
- type EventBus
- func (eb *EventBus) Close()
- func (eb *EventBus) GetHistory(limit int) []*Event
- func (eb *EventBus) GetMetrics() *EventMetrics
- func (eb *EventBus) Publish(event *Event) error
- func (eb *EventBus) Subscribe(eventTypes []EventType, handler EventHandler) string
- func (eb *EventBus) SubscribeAsync(eventTypes []EventType, handler EventHandler) string
- func (eb *EventBus) SubscribeWithFilter(eventTypes []EventType, handler EventHandler, filter EventFilter, async bool) string
- func (eb *EventBus) Unsubscribe(subscriptionID string) error
- type EventFilter
- type EventHandler
- type EventMetrics
- func (m *EventMetrics) EventDelivered(eventType EventType)
- func (m *EventMetrics) EventDeliveryFailed(eventType EventType)
- func (m *EventMetrics) EventPublished(eventType EventType)
- func (m *EventMetrics) GetStats() map[string]any
- func (m *EventMetrics) SubscriptionCreated()
- func (m *EventMetrics) SubscriptionRemoved()
- type EventType
- type ExtensionChain
- type ExtensionFactory
- type ExtensionRegistry
- func (r *ExtensionRegistry) CreateExtension(extType interfaces.ExtensionType, config map[string]any) (interfaces.Extension, error)
- func (r *ExtensionRegistry) ExecuteExtensions(ctx context.Context, pointName string, input interfaces.ExtensionInput) ([]interfaces.ExtensionOutput, error)
- func (r *ExtensionRegistry) GetExtensions(pointName string) ([]interfaces.Extension, error)
- func (r *ExtensionRegistry) RegisterExtension(pointName string, ext interfaces.Extension) error
- func (r *ExtensionRegistry) RegisterExtensionPoint(point *interfaces.ExtensionPoint) error
- func (r *ExtensionRegistry) RegisterFactory(extType interfaces.ExtensionType, factory ExtensionFactory)
- type HasherExtension
- func (e *HasherExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
- func (e *HasherExtension) GetMetadata() interfaces.ExtensionMetadata
- func (e *HasherExtension) GetName() string
- func (e *HasherExtension) GetType() interfaces.ExtensionType
- func (e *HasherExtension) Validate(input interfaces.ExtensionInput) error
- type HookData
- type HookFunc
- type HookManager
- func (m *HookManager) Clear(point HookPoint)
- func (m *HookManager) ClearAll()
- func (m *HookManager) Clone() *HookManager
- func (m *HookManager) Execute(ctx context.Context, point HookPoint, data any) error
- func (m *HookManager) GetHooks(point HookPoint) []interfaces.Hook
- func (m *HookManager) Register(point HookPoint, hook interfaces.Hook)
- func (m *HookManager) Unregister(point HookPoint, name string) error
- type HookPoint
- type MiddlewareExtension
- func (e *MiddlewareExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
- func (e *MiddlewareExtension) GetMetadata() interfaces.ExtensionMetadata
- func (e *MiddlewareExtension) GetName() string
- func (e *MiddlewareExtension) GetType() interfaces.ExtensionType
- func (e *MiddlewareExtension) Validate(input interfaces.ExtensionInput) error
- type Registry
- func (r *Registry) Clone() *Registry
- func (r *Registry) Close() error
- func (r *Registry) ExecuteHooks(point HookPoint, data any) error
- func (r *Registry) Get(name string) (interfaces.Plugin, error)
- func (r *Registry) GetByCapability(capability interfaces.Capability) []interfaces.Plugin
- func (r *Registry) GetEventBus() *EventBus
- func (r *Registry) GetHookManager() *HookManager
- func (r *Registry) InitializeAll(ctx context.Context, configs map[string]map[string]any) error
- func (r *Registry) List() []interfaces.Plugin
- func (r *Registry) Register(plugin interfaces.Plugin) error
- func (r *Registry) RegisterHook(point HookPoint, hook interfaces.Hook)
- func (r *Registry) StartAll(ctx context.Context) error
- func (r *Registry) StopAll() error
- func (r *Registry) Unregister(name string) error
- type StateChangeEvent
- type Subscription
- type ValidationHookData
- type ValidatorExtension
- func (e *ValidatorExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
- func (e *ValidatorExtension) GetMetadata() interfaces.ExtensionMetadata
- func (e *ValidatorExtension) GetName() string
- func (e *ValidatorExtension) GetType() interfaces.ExtensionType
- func (e *ValidatorExtension) Validate(input interfaces.ExtensionInput) error
- type WorkerHookData
- type WorkerProgress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockHookData ¶
type BlockHookData struct {
HookData
Block interfaces.Block `json:"-"`
Result any `json:"result,omitempty"`
Error error `json:"error,omitempty"`
}
BlockHookData is passed to block-related hooks
type DifficultyHookData ¶
type DifficultyHookData struct {
HookData
OldDifficulty any `json:"old_difficulty"`
NewDifficulty any `json:"new_difficulty"`
Blocks []interfaces.Block `json:"-"`
Reason string `json:"reason"`
}
DifficultyHookData is passed to difficulty adjustment hooks
type Event ¶
type Event struct {
ID string `json:"id"`
Type EventType `json:"type"`
Source string `json:"source"`
Timestamp time.Time `json:"timestamp"`
Data any `json:"data"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Event represents a consensus event
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event publishing and subscriptions
func (*EventBus) GetHistory ¶
GetHistory returns recent events
func (*EventBus) GetMetrics ¶
func (eb *EventBus) GetMetrics() *EventMetrics
GetMetrics returns event bus metrics
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(eventTypes []EventType, handler EventHandler) string
Subscribe registers a handler for specific event types
func (*EventBus) SubscribeAsync ¶
func (eb *EventBus) SubscribeAsync(eventTypes []EventType, handler EventHandler) string
SubscribeAsync registers an async handler for specific event types
func (*EventBus) SubscribeWithFilter ¶
func (eb *EventBus) SubscribeWithFilter(eventTypes []EventType, handler EventHandler, filter EventFilter, async bool) string
SubscribeWithFilter registers a handler with a filter
func (*EventBus) Unsubscribe ¶
Unsubscribe removes a subscription
type EventFilter ¶
EventFilter filters events before delivery
type EventHandler ¶
EventHandler handles events
type EventMetrics ¶
type EventMetrics struct {
// contains filtered or unexported fields
}
EventMetrics tracks event bus statistics
func NewEventMetrics ¶
func NewEventMetrics() *EventMetrics
NewEventMetrics creates new metrics tracker
func (*EventMetrics) EventDelivered ¶
func (m *EventMetrics) EventDelivered(eventType EventType)
func (*EventMetrics) EventDeliveryFailed ¶
func (m *EventMetrics) EventDeliveryFailed(eventType EventType)
func (*EventMetrics) EventPublished ¶
func (m *EventMetrics) EventPublished(eventType EventType)
func (*EventMetrics) GetStats ¶
func (m *EventMetrics) GetStats() map[string]any
GetStats returns current metrics
func (*EventMetrics) SubscriptionCreated ¶
func (m *EventMetrics) SubscriptionCreated()
func (*EventMetrics) SubscriptionRemoved ¶
func (m *EventMetrics) SubscriptionRemoved()
type EventType ¶
type EventType string
EventType represents the type of event
const ( // State change events EventStateChanged EventType = "state_changed" EventConfigUpdated EventType = "config_updated" EventPluginRegistered EventType = "plugin_registered" EventPluginUnregistered EventType = "plugin_unregistered" // Consensus events EventConsensusStarted EventType = "consensus_started" EventConsensusStopped EventType = "consensus_stopped" EventConsensusError EventType = "consensus_error" // Block events EventBlockProposed EventType = "block_proposed" EventBlockValidated EventType = "block_validated" EventBlockAccepted EventType = "block_accepted" EventBlockRejected EventType = "block_rejected" EventBlockFinalized EventType = "block_finalized" // Worker events (consensus work processing) EventWorkStarted EventType = "work_started" EventWorkStopped EventType = "work_stopped" EventWorkCompleted EventType = "work_completed" EventSolutionFound EventType = "solution_found" EventThroughputUpdate EventType = "throughput_update" // Difficulty events EventDifficultyAdjusted EventType = "difficulty_adjusted" EventTargetUpdated EventType = "target_updated" // Network events EventPeerConnected EventType = "peer_connected" EventPeerDisconnected EventType = "peer_disconnected" EventSyncStarted EventType = "sync_started" EventSyncCompleted EventType = "sync_completed" // Performance events EventHighLatency EventType = "high_latency" EventResourceWarning EventType = "resource_warning" EventPerformanceMetric EventType = "performance_metric" )
type ExtensionChain ¶
type ExtensionChain struct {
// contains filtered or unexported fields
}
ExtensionChain chains multiple extensions together
func NewExtensionChain ¶
func NewExtensionChain(extensions ...interfaces.Extension) *ExtensionChain
NewExtensionChain creates a new extension chain
func (*ExtensionChain) Execute ¶
func (c *ExtensionChain) Execute(ctx context.Context, input interfaces.ExtensionInput) ([]interfaces.ExtensionOutput, error)
Execute runs all extensions in the chain
type ExtensionFactory ¶
type ExtensionFactory func(config map[string]any) (interfaces.Extension, error)
ExtensionFactory creates extensions of a specific type
type ExtensionRegistry ¶
type ExtensionRegistry struct {
// contains filtered or unexported fields
}
ExtensionRegistry manages extensions
func NewExtensionRegistry ¶
func NewExtensionRegistry() *ExtensionRegistry
NewExtensionRegistry creates a new extension registry
func (*ExtensionRegistry) CreateExtension ¶
func (r *ExtensionRegistry) CreateExtension(extType interfaces.ExtensionType, config map[string]any) (interfaces.Extension, error)
CreateExtension creates an extension using a registered factory
func (*ExtensionRegistry) ExecuteExtensions ¶
func (r *ExtensionRegistry) ExecuteExtensions(ctx context.Context, pointName string, input interfaces.ExtensionInput) ([]interfaces.ExtensionOutput, error)
ExecuteExtensions runs all extensions at a specific point
func (*ExtensionRegistry) GetExtensions ¶
func (r *ExtensionRegistry) GetExtensions(pointName string) ([]interfaces.Extension, error)
GetExtensions returns all extensions for a specific point
func (*ExtensionRegistry) RegisterExtension ¶
func (r *ExtensionRegistry) RegisterExtension(pointName string, ext interfaces.Extension) error
RegisterExtension adds an extension to a specific point
func (*ExtensionRegistry) RegisterExtensionPoint ¶
func (r *ExtensionRegistry) RegisterExtensionPoint(point *interfaces.ExtensionPoint) error
RegisterExtensionPoint registers a new extension point
func (*ExtensionRegistry) RegisterFactory ¶
func (r *ExtensionRegistry) RegisterFactory(extType interfaces.ExtensionType, factory ExtensionFactory)
RegisterFactory registers a factory for creating extensions
type HasherExtension ¶
type HasherExtension struct {
// contains filtered or unexported fields
}
HasherExtension adds custom hash algorithms
func NewHasherExtension ¶
func NewHasherExtension(name string, hasher interfaces.Hasher) *HasherExtension
NewHasherExtension creates a new hasher extension
func (*HasherExtension) Execute ¶
func (e *HasherExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
func (*HasherExtension) GetMetadata ¶
func (e *HasherExtension) GetMetadata() interfaces.ExtensionMetadata
func (*HasherExtension) GetName ¶
func (e *HasherExtension) GetName() string
func (*HasherExtension) GetType ¶
func (e *HasherExtension) GetType() interfaces.ExtensionType
func (*HasherExtension) Validate ¶
func (e *HasherExtension) Validate(input interfaces.ExtensionInput) error
type HookData ¶
type HookData struct {
Type HookPoint `json:"type"`
Timestamp int64 `json:"timestamp"`
Data map[string]any `json:"data"`
}
HookData contains data passed to hooks at various points
type HookFunc ¶
type HookFunc struct {
// contains filtered or unexported fields
}
HookFunc is a simple function-based hook implementation
func NewHookFunc ¶
NewHookFunc creates a new function-based hook
func (*HookFunc) ContinueOnError ¶
func (*HookFunc) GetPriority ¶
func (*HookFunc) SetEnabled ¶
type HookManager ¶
type HookManager struct {
// contains filtered or unexported fields
}
HookManager manages hook execution with proper ordering and error handling
func (*HookManager) Clear ¶
func (m *HookManager) Clear(point HookPoint)
Clear removes all hooks from a specific point
func (*HookManager) Clone ¶
func (m *HookManager) Clone() *HookManager
Clone creates a deep copy of the HookManager
func (*HookManager) GetHooks ¶
func (m *HookManager) GetHooks(point HookPoint) []interfaces.Hook
GetHooks returns all hooks for a specific point
func (*HookManager) Register ¶
func (m *HookManager) Register(point HookPoint, hook interfaces.Hook)
Register adds a hook to a specific point
func (*HookManager) Unregister ¶
func (m *HookManager) Unregister(point HookPoint, name string) error
Unregister removes a hook by name from a specific point
type HookPoint ¶
type HookPoint string
HookPoint defines where hooks can be attached in the consensus flow
const ( // Consensus lifecycle hooks HookBeforeConsensusStart HookPoint = "before_consensus_start" HookAfterConsensusStart HookPoint = "after_consensus_start" HookBeforeConsensusStop HookPoint = "before_consensus_stop" HookAfterConsensusStop HookPoint = "after_consensus_stop" // Block processing hooks HookBeforeBlockPropose HookPoint = "before_block_propose" HookAfterBlockPropose HookPoint = "after_block_propose" HookBeforeBlockValidate HookPoint = "before_block_validate" HookAfterBlockValidate HookPoint = "after_block_validate" HookBeforeBlockAccept HookPoint = "before_block_accept" HookAfterBlockAccept HookPoint = "after_block_accept" HookBeforeBlockReject HookPoint = "before_block_reject" HookAfterBlockReject HookPoint = "after_block_reject" // Worker hooks (consensus work processing) HookBeforeWorkStart HookPoint = "before_work_start" HookAfterWorkStart HookPoint = "after_work_start" HookBeforeWorkStop HookPoint = "before_work_stop" HookAfterWorkStop HookPoint = "after_work_stop" HookOnSolutionFound HookPoint = "on_solution_found" HookOnWorkProgress HookPoint = "on_work_progress" // Difficulty adjustment hooks HookBeforeDifficultyAdjust HookPoint = "before_difficulty_adjust" HookAfterDifficultyAdjust HookPoint = "after_difficulty_adjust" // Validation hooks HookBeforeValidation HookPoint = "before_validation" HookAfterValidation HookPoint = "after_validation" HookOnValidationFailure HookPoint = "on_validation_failure" // Network hooks HookOnPeerConnect HookPoint = "on_peer_connect" HookOnPeerDisconnect HookPoint = "on_peer_disconnect" HookOnBlockReceived HookPoint = "on_block_received" HookOnBlockBroadcast HookPoint = "on_block_broadcast" )
type MiddlewareExtension ¶
type MiddlewareExtension struct {
// contains filtered or unexported fields
}
MiddlewareExtension adds processing middleware
func NewMiddlewareExtension ¶
func NewMiddlewareExtension(name string, middleware func(context.Context, any) (any, error)) *MiddlewareExtension
NewMiddlewareExtension creates a new middleware extension
func (*MiddlewareExtension) Execute ¶
func (e *MiddlewareExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
func (*MiddlewareExtension) GetMetadata ¶
func (e *MiddlewareExtension) GetMetadata() interfaces.ExtensionMetadata
func (*MiddlewareExtension) GetName ¶
func (e *MiddlewareExtension) GetName() string
func (*MiddlewareExtension) GetType ¶
func (e *MiddlewareExtension) GetType() interfaces.ExtensionType
func (*MiddlewareExtension) Validate ¶
func (e *MiddlewareExtension) Validate(input interfaces.ExtensionInput) error
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages plugin registration and lifecycle
func (*Registry) Clone ¶
Clone creates a deep copy of the Registry Note: This clones the structure but plugins themselves are references (as they're interfaces) The cloned registry will have: - The same plugins registered (but not initialized/started) - A clone of the HookManager with all hooks - A new EventBus (subscriptions are not cloned)
func (*Registry) ExecuteHooks ¶
ExecuteHooks executes all hooks for a specific point in priority order
func (*Registry) Get ¶
func (r *Registry) Get(name string) (interfaces.Plugin, error)
Get returns a plugin by name
func (*Registry) GetByCapability ¶
func (r *Registry) GetByCapability(capability interfaces.Capability) []interfaces.Plugin
GetByCapability returns all plugins with a specific capability
func (*Registry) GetEventBus ¶
GetEventBus returns the event bus for publishing/subscribing to events
func (*Registry) GetHookManager ¶
func (r *Registry) GetHookManager() *HookManager
GetHookManager returns the hook manager for direct access to hook operations
func (*Registry) InitializeAll ¶
InitializeAll initializes all plugins in dependency order
func (*Registry) List ¶
func (r *Registry) List() []interfaces.Plugin
List returns all registered plugins
func (*Registry) Register ¶
func (r *Registry) Register(plugin interfaces.Plugin) error
Register adds a plugin to the registry
func (*Registry) RegisterHook ¶
func (r *Registry) RegisterHook(point HookPoint, hook interfaces.Hook)
RegisterHook registers a hook for a specific hook point with priority support
func (*Registry) Unregister ¶
Unregister removes a plugin from the registry
type StateChangeEvent ¶
type StateChangeEvent struct {
Component string `json:"component"`
OldState any `json:"old_state"`
NewState any `json:"new_state"`
Reason string `json:"reason,omitempty"`
}
StateChangeEvent represents a state change in the consensus
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription represents an event subscription
type ValidationHookData ¶
type ValidationHookData struct {
HookData
Block interfaces.Block `json:"-"`
Validator interfaces.Validator `json:"-"`
Result interfaces.ValidationResult `json:"result"`
}
ValidationHookData is passed to validation hooks
type ValidatorExtension ¶
type ValidatorExtension struct {
// contains filtered or unexported fields
}
ValidatorExtension adds custom validation logic
func NewValidatorExtension ¶
func NewValidatorExtension(name string, validator interfaces.Validator) *ValidatorExtension
NewValidatorExtension creates a new validator extension
func (*ValidatorExtension) Execute ¶
func (e *ValidatorExtension) Execute(ctx context.Context, input interfaces.ExtensionInput) (interfaces.ExtensionOutput, error)
func (*ValidatorExtension) GetMetadata ¶
func (e *ValidatorExtension) GetMetadata() interfaces.ExtensionMetadata
func (*ValidatorExtension) GetName ¶
func (e *ValidatorExtension) GetName() string
func (*ValidatorExtension) GetType ¶
func (e *ValidatorExtension) GetType() interfaces.ExtensionType
func (*ValidatorExtension) Validate ¶
func (e *ValidatorExtension) Validate(input interfaces.ExtensionInput) error
type WorkerHookData ¶
type WorkerHookData struct {
HookData
JobID string `json:"job_id"`
Work interfaces.WorkPackage `json:"-"`
Result interfaces.WorkResult `json:"-"`
Progress WorkerProgress `json:"progress,omitempty"`
}
WorkerHookData is passed to worker-related hooks