Documentation
¶
Index ¶
- Variables
- type Action
- type ActionRequest
- type App
- func (a *App) DeleteLegacyService(deleteFromCloud bool)
- func (a *App) DeleteOrphanedCloudServices(tedgeEntities map[string]tedge.Entity) error
- func (a *App) Monitor(ctx context.Context, filterOptions container.FilterOptions) error
- func (a *App) ReconnectContainerClient(ctx context.Context) error
- func (a *App) Stop(clean bool)
- func (a *App) Subscribe() error
- func (a *App) Update(filterOptions container.FilterOptions) error
- func (a *App) UpdateMetrics(filterOptions container.FilterOptions) error
- type Config
- type EventRateLimiter
- type UpdateDebouncer
Constants ¶
This section is empty.
Variables ¶
var ContainerEventText = map[events.Action]string{ events.ActionCreate: "created", events.ActionStart: "started", events.ActionStop: "stopped", events.ActionDestroy: "destroyed", events.ActionRemove: "removed", events.ActionDie: "died", events.ActionPause: "paused", events.ActionUnPause: "unpaused", events.ActionExecDie: "process died", events.ActionHealthStatusHealthy: "healthy", events.ActionHealthStatusUnhealthy: "unhealthy", }
Functions ¶
This section is empty.
Types ¶
type ActionRequest ¶
func NewUpdateAllAction ¶
func NewUpdateAllAction(filter container.FilterOptions) ActionRequest
func NewUpdateMetricsAction ¶
func NewUpdateMetricsAction(filter container.FilterOptions) ActionRequest
type App ¶
func (*App) DeleteLegacyService ¶
func (*App) DeleteOrphanedCloudServices ¶
Delete any unclaimed/orphaned cloud services which haven't been registered with
func (*App) ReconnectContainerClient ¶
ReconnectContainerClient creates a new ContainerClient using the same host options as the original and atomically replaces the current one. It is called by the Monitor restart loop when the event stream fails, so that a stale client (e.g. after a podman socket restart) does not block recovery. It uses a bounded retry count so it doesn't block forever during shutdown.
func (*App) UpdateMetrics ¶
func (a *App) UpdateMetrics(filterOptions container.FilterOptions) error
type Config ¶
type Config struct {
ContainerHost string
ServiceName string
// TLS
KeyFile string
CertFile string
CAFile string
// Feature flags
EnableMetrics bool
EnableEngineEvents bool
DeleteFromCloud bool
DeleteOrphans bool
RunOnce bool
HTTPHost string
HTTPPort uint16
MQTTHost string
MQTTPort uint16
CumulocityHost string
CumulocityPort uint16
// CrashLoopThreshold is the number of daemon-initiated restarts since the
// last healthy state required to declare a crash loop.
CrashLoopThreshold int
// UseModuleNameForService controls whether the thin-edge service name for
// container-group services is derived from the stored module name (true,
// default) or from the compose project name taken from Docker labels
// (false). Set to false when you want the runtime service identity to be
// decoupled from the software module name, e.g. the module is "myapp-dev"
// but the compose project name (and therefore the service name) is "myapp".
UseModuleNameForService bool
// SyncRetryInterval is the delay before a failed cloud sync is retried,
// e.g. a stale service which could not be deleted from the cloud because
// the local Cumulocity proxy was unavailable. The retry is scheduled by
// the plugin itself so pending operations recover even when no container
// engine event or bridge health message arrives to trigger an update (the
// health message can be lost entirely, see
// https://github.com/thin-edge/thin-edge.io/issues/3185).
// A value of 0 (or less) disables the failure-driven retry.
SyncRetryInterval time.Duration
// OrphansCheckInterval is the minimum time between routine checks for
// orphaned cloud services, limiting the additional Cumulocity REST calls
// the check costs on each update. The interval is bypassed whenever an
// update removed stale services, since that is when new orphans are
// likely, so cleanup after a container removal is never delayed by it.
// A value of 0 (or less) checks on every update.
// Only applies when DeleteFromCloud and DeleteOrphans are enabled.
OrphansCheckInterval time.Duration
}
type EventRateLimiter ¶
type EventRateLimiter struct {
// contains filtered or unexported fields
}
EventRateLimiter enforces a minimum interval between events per key. It is used to prevent crash-looping containers from flooding the MQTT broker with engine event messages (start/die bursts at millisecond intervals can saturate the broker and starve other MQTT operations).
The key is typically "<containerName>/<eventType>" so that each (container, event-type) pair is rate-limited independently.
func NewEventRateLimiter ¶
func NewEventRateLimiter(interval time.Duration) *EventRateLimiter
NewEventRateLimiter creates a limiter that passes at most one event per key per interval duration.
func (*EventRateLimiter) Allow ¶
func (r *EventRateLimiter) Allow(key string) bool
Allow returns true if at least interval has elapsed since the last allowed event for key, and records the current time as its new last-seen time. Returns false when the event should be suppressed.
func (*EventRateLimiter) Remove ¶
func (r *EventRateLimiter) Remove(key string)
Remove clears the rate-limit history for key, effectively resetting its window. Call this when a container is removed or becomes healthy so that fresh events are not incorrectly suppressed.
type UpdateDebouncer ¶
type UpdateDebouncer struct {
// contains filtered or unexported fields
}
UpdateDebouncer coalesces rapid-fire ActionUpdateAll requests into a single execution after a configurable quiet period. This prevents a crash-looping container (with restart policy "always") from causing a flood of doUpdate calls.
Requests received during the debounce window are merged: scoped requests have their IDs/Names unioned, and a full-scan request always supersedes any scoped request.
func NewUpdateDebouncer ¶
func NewUpdateDebouncer(delay time.Duration, dispatch func(ActionRequest)) *UpdateDebouncer
NewUpdateDebouncer creates a debouncer with the given quiet-period delay. dispatch is called with the merged request once the quiet period elapses after the last Enqueue call.
func (*UpdateDebouncer) Enqueue ¶
func (d *UpdateDebouncer) Enqueue(req ActionRequest)
Enqueue adds req to the pending set. If a request is already waiting it is merged with req and the debounce timer is reset.