fix(ap): increase outbound worker pool size to use follower count (#4049)

This commit is contained in:
Gabe Kangas
2024-12-17 08:47:15 -08:00
committed by GitHub
parent ae1be1379c
commit 4fbdb3f0cd
2 changed files with 19 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
package activitypub
import (
"math"
"github.com/owncast/owncast/activitypub/crypto"
"github.com/owncast/owncast/activitypub/inbox"
"github.com/owncast/owncast/activitypub/outbox"
@@ -17,7 +19,9 @@ import (
func Start(datastore *data.Datastore) {
configRepository := configrepository.Get()
persistence.Setup(datastore)
workerpool.InitOutboundWorkerPool()
outboundWorkerPoolSize := getOutboundWorkerPoolSize()
workerpool.InitOutboundWorkerPool(outboundWorkerPoolSize)
inbox.InitInboxWorkerPool()
// Generate the keys for signing federated activity if needed.
@@ -31,6 +35,17 @@ func Start(datastore *data.Datastore) {
}
}
func getOutboundWorkerPoolSize() int {
var followerCount int64
fc, err := persistence.GetFollowerCount()
if err != nil {
log.Errorln("Unable to get follower count", err)
fc = 50 // Arbitrary fallback value.
}
followerCount = int64(math.Max(float64(fc), 50))
return int(followerCount * 5)
}
// SendLive will send a "Go Live" message to followers.
func SendLive() error {
return outbox.SendLive()