Documentation
¶
Index ¶
- Variables
- func RegisterDriver(name string, factory Factory)
- type BACnetAddressNotifier
- type BACnetAddressNotifySetter
- type ConnState
- type ConnectFunc
- type ConnectionManager
- func (cm *ConnectionManager) AttemptHalfOpen(success bool)
- func (cm *ConnectionManager) CanRetry() (canRetry bool, waitTime time.Duration)
- func (cm *ConnectionManager) Close()
- func (cm *ConnectionManager) EnsureConnected(ctx context.Context, connect ConnectFunc) error
- func (cm *ConnectionManager) GetState() ConnState
- func (cm *ConnectionManager) GetStatus() (state ConnState, retryCount int, maxRetries int, ...)
- func (cm *ConnectionManager) RecordFailure() (shouldRetry bool, backoff time.Duration)
- func (cm *ConnectionManager) RecordSuccess()
- func (cm *ConnectionManager) ResetDaily()
- func (cm *ConnectionManager) ScheduleAsyncTask(parentCtx context.Context, timeout time.Duration, ...)
- func (cm *ConnectionManager) ScheduleReconnect(parentCtx context.Context, timeout time.Duration, connect ConnectFunc)
- func (cm *ConnectionManager) SetBackoffParams(base, max time.Duration, factor float64)
- func (cm *ConnectionManager) SetMaxFailCount(max int)
- func (cm *ConnectionManager) SetMaxRetries(max int)
- func (cm *ConnectionManager) SetState(state ConnState)
- func (cm *ConnectionManager) StartBackgroundLoop(fn func(context.Context))
- func (cm *ConnectionManager) StopBackgroundLoop()
- type DeviceCollectionResetter
- type Driver
- type Factory
- type HealthStatus
- type ObjectScanner
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var (
MaxGlobalReconnectRate = 10
)
Functions ¶
func RegisterDriver ¶
RegisterDriver registers a driver factory for a given protocol name
Types ¶
type BACnetAddressNotifier ¶ added in v0.0.7
BACnetAddressNotifier receives runtime BACnet address updates (e.g. UDP port change after reboot).
type BACnetAddressNotifySetter ¶ added in v0.0.7
type BACnetAddressNotifySetter interface {
SetBACnetAddressNotifier(BACnetAddressNotifier)
}
BACnetAddressNotifySetter allows wiring a notifier into the BACnet driver.
type ConnectFunc ¶ added in v0.0.7
ConnectFunc performs a single connection attempt (dial/open). Retry/backoff is owned exclusively by ConnectionManager.EnsureConnected.
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager(driverName string) *ConnectionManager
func (*ConnectionManager) AttemptHalfOpen ¶
func (cm *ConnectionManager) AttemptHalfOpen(success bool)
func (*ConnectionManager) CanRetry ¶
func (cm *ConnectionManager) CanRetry() (canRetry bool, waitTime time.Duration)
func (*ConnectionManager) Close ¶
func (cm *ConnectionManager) Close()
func (*ConnectionManager) EnsureConnected ¶ added in v0.0.7
func (cm *ConnectionManager) EnsureConnected(ctx context.Context, connect ConnectFunc) error
EnsureConnected is the single entry point for synchronous reconnect with backoff, cooldown, and global rate limiting.
func (*ConnectionManager) GetState ¶
func (cm *ConnectionManager) GetState() ConnState
func (*ConnectionManager) RecordFailure ¶
func (cm *ConnectionManager) RecordFailure() (shouldRetry bool, backoff time.Duration)
func (*ConnectionManager) RecordSuccess ¶
func (cm *ConnectionManager) RecordSuccess()
func (*ConnectionManager) ResetDaily ¶
func (cm *ConnectionManager) ResetDaily()
func (*ConnectionManager) ScheduleAsyncTask ¶ added in v0.0.7
func (cm *ConnectionManager) ScheduleAsyncTask(parentCtx context.Context, timeout time.Duration, task func(context.Context) error)
ScheduleAsyncTask runs a one-shot async operation under the same single-flight guard as ScheduleReconnect, without requiring a disconnected connection state. Use for device-level recovery probes while the channel remains connected.
func (*ConnectionManager) ScheduleReconnect ¶ added in v0.0.7
func (cm *ConnectionManager) ScheduleReconnect(parentCtx context.Context, timeout time.Duration, connect ConnectFunc)
ScheduleReconnect starts an asynchronous reconnect guarded by single-flight. Duplicate calls while a reconnect is in progress are ignored.
func (*ConnectionManager) SetBackoffParams ¶
func (cm *ConnectionManager) SetBackoffParams(base, max time.Duration, factor float64)
func (*ConnectionManager) SetMaxFailCount ¶
func (cm *ConnectionManager) SetMaxFailCount(max int)
func (*ConnectionManager) SetMaxRetries ¶
func (cm *ConnectionManager) SetMaxRetries(max int)
func (*ConnectionManager) SetState ¶
func (cm *ConnectionManager) SetState(state ConnState)
func (*ConnectionManager) StartBackgroundLoop ¶ added in v0.0.7
func (cm *ConnectionManager) StartBackgroundLoop(fn func(context.Context))
StartBackgroundLoop runs fn in a single managed goroutine until StopBackgroundLoop is called or the parent context passed to fn is cancelled via StopBackgroundLoop. Only one background loop may run per ConnectionManager.
func (*ConnectionManager) StopBackgroundLoop ¶ added in v0.0.7
func (cm *ConnectionManager) StopBackgroundLoop()
StopBackgroundLoop cancels and waits for the managed background goroutine to exit.
type DeviceCollectionResetter ¶ added in v0.0.7
type DeviceCollectionResetter interface {
ResetDeviceCollection(deviceID string)
}
DeviceCollectionResetter is optional. Drivers that cache per-device collection state (e.g. OPC UA subscriptions) should implement it so ScanEngine can drop stale state when points are added, removed, or the device is re-registered.
type Driver ¶
type Driver interface {
Init(cfg model.DriverConfig) error
Connect(ctx context.Context) error
Disconnect() error
ReadPoints(ctx context.Context, points []model.Point) (map[string]model.Value, error)
WritePoint(ctx context.Context, point model.Point, value any) error
Health() HealthStatus
// SetSlaveID sets the slave/unit ID for protocols that support multiple slaves (optional)
SetSlaveID(slaveID uint8) error
// SetDeviceConfig sets device specific configuration (optional, for protocols needing per-device connection info like BACnet IP)
SetDeviceConfig(config map[string]any) error
// GetConnectionMetrics returns transport-level connection metrics
GetConnectionMetrics() (connectionSeconds int64, reconnectCount int64, localAddr string, remoteAddr string, lastDisconnectTime time.Time)
}
Driver is the unified interface for all protocol drivers
type HealthStatus ¶
type HealthStatus int
HealthStatus represents the health of the driver connection
const ( HealthStatusUnknown HealthStatus = iota HealthStatusGood HealthStatusBad )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ethercat implements EtherCAT master driver for EdgeX gateway.
|
Package ethercat implements EtherCAT master driver for EdgeX gateway. |