github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/aagent/model/watcher.go (about)

     1  // Copyright (c) 2021-2022, R.I. Pienaar and the Choria Project contributors
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package model
     6  
     7  import (
     8  	"context"
     9  	"sync"
    10  	"time"
    11  )
    12  
    13  // Watcher is anything that can be used to watch the system for events
    14  type Watcher interface {
    15  	Name() string
    16  	Type() string
    17  	Run(context.Context, *sync.WaitGroup)
    18  	NotifyStateChance()
    19  	CurrentState() any
    20  	AnnounceInterval() time.Duration
    21  	Delete()
    22  }
    23  
    24  // WatcherConstructor creates a new watcher plugin
    25  type WatcherConstructor interface {
    26  	New(machine Machine, name string, states []string, failEvent string, successEvent string, interval string, ai time.Duration, properties map[string]any) (any, error)
    27  	Type() string
    28  	EventType() string
    29  	UnmarshalNotification(n []byte) (any, error)
    30  }