added tootIngester, does not ingest yet
This commit is contained in:
parent
4d15e61fd6
commit
f2590fbe75
8
feta.go
8
feta.go
@ -33,6 +33,7 @@ type Process struct {
|
|||||||
builduser string
|
builduser string
|
||||||
locator *InstanceLocator
|
locator *InstanceLocator
|
||||||
manager *InstanceManager
|
manager *InstanceManager
|
||||||
|
ingester *tootIngester
|
||||||
api *fetaAPIServer
|
api *fetaAPIServer
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
startup time.Time
|
startup time.Time
|
||||||
@ -100,12 +101,19 @@ func (f *Process) runForever() int {
|
|||||||
|
|
||||||
f.locator = newInstanceLocator()
|
f.locator = newInstanceLocator()
|
||||||
f.manager = newInstanceManager()
|
f.manager = newInstanceManager()
|
||||||
|
f.ingester = newTootIngester()
|
||||||
|
|
||||||
f.api = new(fetaAPIServer)
|
f.api = new(fetaAPIServer)
|
||||||
f.api.setFeta(f) // api needs to get to us to access data
|
f.api.setFeta(f) // api needs to get to us to access data
|
||||||
|
|
||||||
f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
||||||
f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
||||||
|
|
||||||
|
f.manager.addTootDestination(f.ingester.getDeliveryChannel())
|
||||||
|
|
||||||
|
// ingester goroutine:
|
||||||
|
go f.ingester.ingest()
|
||||||
|
|
||||||
// locator goroutine:
|
// locator goroutine:
|
||||||
go f.locator.locate()
|
go f.locator.locate()
|
||||||
|
|
||||||
|
25
ingester.go
Normal file
25
ingester.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ type InstanceManager struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
instances map[InstanceHostname]*instance
|
instances map[InstanceHostname]*instance
|
||||||
newInstanceNotifications chan InstanceHostname
|
newInstanceNotifications chan InstanceHostname
|
||||||
|
newToots chan *toot
|
||||||
startup time.Time
|
startup time.Time
|
||||||
hostAdderSemaphore chan bool
|
hostAdderSemaphore chan bool
|
||||||
}
|
}
|
||||||
@ -30,6 +31,10 @@ func newInstanceManager() *InstanceManager {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (im *InstanceManager) addTootDestination(td chan *toot) {
|
||||||
|
im.newToots = td
|
||||||
|
}
|
||||||
|
|
||||||
func (im *InstanceManager) logCaller(msg string) {
|
func (im *InstanceManager) logCaller(msg string) {
|
||||||
fpcs := make([]uintptr, 1)
|
fpcs := make([]uintptr, 1)
|
||||||
// Skip 2 levels to get the caller
|
// Skip 2 levels to get the caller
|
||||||
|
Loading…
Reference in New Issue
Block a user