added tootIngester, does not ingest yet

This commit is contained in:
Jeffrey Paul 2019-12-14 07:39:58 -08:00
parent 4d15e61fd6
commit f2590fbe75
4 changed files with 38 additions and 2 deletions

View File

@ -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()

25
ingester.go Normal file
View File

@ -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
}
}

View File

@ -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

View File

@ -1,7 +1,5 @@
package feta
//import "github.com/rs/zerolog/log"
type toot struct {
}