diff --git a/feta.go b/feta.go index d6ee5b0..25d0da7 100644 --- a/feta.go +++ b/feta.go @@ -33,6 +33,7 @@ type Process struct { builduser string locator *InstanceLocator manager *InstanceManager + ingester *tootIngester api *fetaAPIServer db *gorm.DB startup time.Time @@ -100,12 +101,19 @@ func (f *Process) runForever() int { f.locator = newInstanceLocator() f.manager = newInstanceManager() + f.ingester = newTootIngester() + f.api = new(fetaAPIServer) f.api.setFeta(f) // api needs to get to us to access data f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications) f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications) + f.manager.addTootDestination(f.ingester.getDeliveryChannel()) + + // ingester goroutine: + go f.ingester.ingest() + // locator goroutine: go f.locator.locate() diff --git a/ingester.go b/ingester.go new file mode 100644 index 0000000..16fe65d --- /dev/null +++ b/ingester.go @@ -0,0 +1,25 @@ +package feta + +import "time" +import "github.com/rs/zerolog/log" + +type tootIngester struct { + inbound chan *toot +} + +func newTootIngester() *tootIngester { + ti := new(tootIngester) + ti.inbound = make(chan *toot, 1) + return ti +} + +func (ti *tootIngester) getDeliveryChannel() chan *toot { + return ti.inbound +} + +func (ti *tootIngester) ingest() { + log.Info().Msg("tootIngester starting") + for { + time.Sleep(1 * time.Second) // FIXME do something + } +} diff --git a/manager.go b/manager.go index 330da3a..dc64ef9 100644 --- a/manager.go +++ b/manager.go @@ -19,6 +19,7 @@ type InstanceManager struct { mu sync.Mutex instances map[InstanceHostname]*instance newInstanceNotifications chan InstanceHostname + newToots chan *toot startup time.Time hostAdderSemaphore chan bool } @@ -30,6 +31,10 @@ func newInstanceManager() *InstanceManager { return i } +func (im *InstanceManager) addTootDestination(td chan *toot) { + im.newToots = td +} + func (im *InstanceManager) logCaller(msg string) { fpcs := make([]uintptr, 1) // Skip 2 levels to get the caller diff --git a/toot.go b/toot.go index 7a58330..7f01b6f 100644 --- a/toot.go +++ b/toot.go @@ -1,7 +1,5 @@ package feta -//import "github.com/rs/zerolog/log" - type toot struct { }