Add rudimentary database watcher

Adds a simple database watcher. At this point it's just one process, but
the plan is to allow different implementations that inform the local running
workers of changes that have occured on entities of interest in the database.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-04-03 14:46:32 +00:00
parent 214cb05072
commit 8d57fc8fa2
18 changed files with 514 additions and 41 deletions

View file

@ -0,0 +1,45 @@
//go:build testing
// +build testing
package testing
import "github.com/cloudbase/garm/database/common"
type MockWatcher struct{}
func (w *MockWatcher) RegisterProducer(_ string) (common.Producer, error) {
return &MockProducer{}, nil
}
func (w *MockWatcher) RegisterConsumer(_ string, _ ...common.PayloadFilterFunc) (common.Consumer, error) {
return &MockConsumer{}, nil
}
type MockProducer struct{}
func (p *MockProducer) Notify(_ common.ChangePayload) error {
return nil
}
func (p *MockProducer) IsClosed() bool {
return false
}
func (p *MockProducer) Close() {
}
type MockConsumer struct{}
func (c *MockConsumer) Watch() <-chan common.ChangePayload {
return nil
}
func (c *MockConsumer) SetFilters(_ ...common.PayloadFilterFunc) {
}
func (c *MockConsumer) Close() {
}
func (c *MockConsumer) IsClosed() bool {
return false
}