github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/monitor/interfaces.go (about)

     1  package monitor
     2  
     3  import (
     4  	"context"
     5  
     6  	"go.aporeto.io/enforcerd/trireme-lib/monitor/config"
     7  	"go.aporeto.io/enforcerd/trireme-lib/monitor/registerer"
     8  )
     9  
    10  // A Monitor is an interface implmented to start/stop monitors.
    11  type Monitor interface {
    12  
    13  	// Start starts the monitor.
    14  	Run(ctx context.Context) error
    15  
    16  	// UpdateConfiguration updates the configuration of the monitor
    17  	UpdateConfiguration(ctx context.Context, config *config.MonitorConfig) error
    18  
    19  	// Resync requests to the monitor to do a resync.
    20  	Resync(ctx context.Context) error
    21  }
    22  
    23  // Implementation for a monitor.
    24  type Implementation interface {
    25  
    26  	// Run starts the monitor implementation.
    27  	Run(ctx context.Context) error
    28  
    29  	// SetupConfig provides a configuration to implmentations. Every implmentation
    30  	// can have its own config type.
    31  	SetupConfig(registerer registerer.Registerer, cfg interface{}) error
    32  
    33  	// SetupHandlers sets up handlers for monitors to invoke for various events such as
    34  	// processing unit events and synchronization events. This will be called before Start()
    35  	// by the consumer of the monitor
    36  	SetupHandlers(c *config.ProcessorConfig)
    37  
    38  	// Resync should resynchronize PUs. This should be done while starting up.
    39  	Resync(ctx context.Context) error
    40  }