Documentation
¶
Overview ¶
Package engine implements the core.Engine interface and orchestration pipeline.
Index ¶
- Constants
- func New() core.Engine
- func NewScheduler(...) *scheduler
- type CoreCEngine
- func (e *CoreCEngine) AddDriver(config core.DriverConfig) error
- func (e *CoreCEngine) AddTransport(config core.TransportConfig) error
- func (e *CoreCEngine) GetDriver(name string) (core.Driver, bool)
- func (e *CoreCEngine) GetRuleStats() []core.RuleStat
- func (e *CoreCEngine) GetTransport(name string) (core.Transport, bool)
- func (e *CoreCEngine) LatestValues(driver string) map[string]core.DataPoint
- func (e *CoreCEngine) ListDrivers() []core.DriverStatus
- func (e *CoreCEngine) ListTransports() []core.TransportStatus
- func (e *CoreCEngine) OnAlert(handler func(point core.DataPoint, rule core.Rule))
- func (e *CoreCEngine) ReadTag(ctx context.Context, driver, tag string) (*core.TagValue, error)
- func (e *CoreCEngine) Reload(config *core.Config) error
- func (e *CoreCEngine) RemoveDriver(name string) error
- func (e *CoreCEngine) RemoveTransport(name string) error
- func (e *CoreCEngine) Resume() error
- func (e *CoreCEngine) SetRuleDisabled(index int, disabled bool) error
- func (e *CoreCEngine) SetRules(rules []core.RuleConfig) error
- func (e *CoreCEngine) Start(ctx context.Context, config *core.Config) error
- func (e *CoreCEngine) Stats() core.EngineStats
- func (e *CoreCEngine) Status() core.EngineStatus
- func (e *CoreCEngine) Stop() error
- func (e *CoreCEngine) Subscribe(filter string) (ch <-chan core.DataPoint, unsub func())
- func (e *CoreCEngine) SubscribeWithBuffer(filter string, size int) (ch <-chan core.DataPoint, unsub func())
- func (e *CoreCEngine) Suspend() error
- func (e *CoreCEngine) WriteTag(ctx context.Context, cmd core.WriteCommand) (*core.WriteResult, error)
- type DataBus
- func (b *DataBus) Broadcast(point core.DataPoint)
- func (b *DataBus) Channel() <-chan core.DataPoint
- func (b *DataBus) Close()
- func (b *DataBus) Dropped() int64
- func (b *DataBus) Push(point core.DataPoint)
- func (b *DataBus) PushDropped() int64
- func (b *DataBus) Subscribe(filter string) (events <-chan core.DataPoint, unsub func())
- func (b *DataBus) SubscribeWithBuffer(filter string, size int) (events <-chan core.DataPoint, unsub func())
- type LatestCache
Constants ¶
const DefaultSubscriberBuffer = 256
DefaultSubscriberBuffer is the default buffer size for DataBus subscriber channels.
Variables ¶
This section is empty.
Functions ¶
func NewScheduler ¶
func NewScheduler( readFunc func(ctx context.Context, driver string, tags []string) ([]core.TagValue, error), onData func(driver string, values []core.TagValue), errorThrottleWindow time.Duration, ) *scheduler
NewScheduler creates a new scheduler. readFunc is called to read tags from a driver. onData is called when data is received. errorThrottleWindow is the time window for suppressing repeated error logs; <=0 falls back to core.DefaultErrorThrottleWindow.
Types ¶
type CoreCEngine ¶
type CoreCEngine struct {
// contains filtered or unexported fields
}
CoreCEngine implements core.Engine. This is the central orchestrator.
func (*CoreCEngine) AddDriver ¶
func (e *CoreCEngine) AddDriver(config core.DriverConfig) error
func (*CoreCEngine) AddTransport ¶
func (e *CoreCEngine) AddTransport(config core.TransportConfig) error
func (*CoreCEngine) GetRuleStats ¶
func (e *CoreCEngine) GetRuleStats() []core.RuleStat
func (*CoreCEngine) GetTransport ¶
func (e *CoreCEngine) GetTransport(name string) (core.Transport, bool)
func (*CoreCEngine) LatestValues ¶
func (e *CoreCEngine) LatestValues(driver string) map[string]core.DataPoint
func (*CoreCEngine) ListDrivers ¶
func (e *CoreCEngine) ListDrivers() []core.DriverStatus
func (*CoreCEngine) ListTransports ¶
func (e *CoreCEngine) ListTransports() []core.TransportStatus
func (*CoreCEngine) OnAlert ¶
func (e *CoreCEngine) OnAlert(handler func(point core.DataPoint, rule core.Rule))
func (*CoreCEngine) RemoveDriver ¶
func (e *CoreCEngine) RemoveDriver(name string) error
func (*CoreCEngine) RemoveTransport ¶
func (e *CoreCEngine) RemoveTransport(name string) error
func (*CoreCEngine) Resume ¶
func (e *CoreCEngine) Resume() error
func (*CoreCEngine) SetRuleDisabled ¶
func (e *CoreCEngine) SetRuleDisabled(index int, disabled bool) error
func (*CoreCEngine) SetRules ¶
func (e *CoreCEngine) SetRules(rules []core.RuleConfig) error
func (*CoreCEngine) Stats ¶
func (e *CoreCEngine) Stats() core.EngineStats
func (*CoreCEngine) Status ¶
func (e *CoreCEngine) Status() core.EngineStatus
func (*CoreCEngine) Stop ¶
func (e *CoreCEngine) Stop() error
func (*CoreCEngine) Subscribe ¶
func (e *CoreCEngine) Subscribe(filter string) (ch <-chan core.DataPoint, unsub func())
func (*CoreCEngine) SubscribeWithBuffer ¶
func (e *CoreCEngine) SubscribeWithBuffer(filter string, size int) (ch <-chan core.DataPoint, unsub func())
SubscribeWithBuffer is like Subscribe but lets the caller choose the subscriber channel buffer size.
func (*CoreCEngine) Suspend ¶
func (e *CoreCEngine) Suspend() error
func (*CoreCEngine) WriteTag ¶
func (e *CoreCEngine) WriteTag(ctx context.Context, cmd core.WriteCommand) (*core.WriteResult, error)
type DataBus ¶
type DataBus struct {
// contains filtered or unexported fields
}
DataBus is the internal data channel that connects drivers to the processing pipeline. It uses Go channels for high-performance, lock-free data flow.
func NewDataBus ¶
NewDataBus creates a new DataBus with the given buffer size.
func (*DataBus) Dropped ¶
Dropped returns the total number of messages dropped due to slow subscribers.
func (*DataBus) Push ¶
Push sends a DataPoint into the bus. It is safe to call Push concurrently with Close; a Push that races with Close is silently dropped instead of panicking.
func (*DataBus) PushDropped ¶
PushDropped returns the number of messages evicted from the main channel because the bus buffer was full (producer faster than consumer).
type LatestCache ¶
type LatestCache struct {
// contains filtered or unexported fields
}
LatestCache maintains the most recent value for each tag. It is sharded by driver name to reduce mutex contention when multiple processing workers update the cache concurrently.
func (*LatestCache) Get ¶
func (c *LatestCache) Get(driver, tag string) (core.DataPoint, bool)
Get retrieves the latest value for a specific driver and tag.
func (*LatestCache) GetByDriver ¶
func (c *LatestCache) GetByDriver(driver string) map[string]core.DataPoint
GetByDriver retrieves all latest values for a driver. It returns an atomic snapshot that is reused across calls when the data hasn't changed, avoiding a full map copy.
func (*LatestCache) Update ¶
func (c *LatestCache) Update(point core.DataPoint)
Update stores or updates a DataPoint in the cache.