Remove queue trigger again, made tests fail, change schedule times

pull/25/head
Jan-Lukas Else 8 months ago
parent 5f969f8ba8
commit 9035f9bf46
  1. 2
      Dockerfile
  2. 2
      activityPubSending.go
  3. 2
      app.go
  4. 6
      postsScheduler.go
  5. 10
      queue.go
  6. 2
      webmentionVerification.go

@ -18,7 +18,7 @@ RUN go build -ldflags '-w -s' -o GoBlog
FROM build as test
RUN go test -cover ./...
RUN go test -timeout 15s -cover ./...
FROM alpine:3.15 as base

@ -23,7 +23,7 @@ type apRequest struct {
}
func (a *goBlog) initAPSendQueue() {
a.listenOnQueue("ap", time.Minute, func(qi *queueItem, dequeue func(), reschedule func(time.Duration)) {
a.listenOnQueue("ap", 30*time.Second, func(qi *queueItem, dequeue func(), reschedule func(time.Duration)) {
var r apRequest
if err := gob.NewDecoder(bytes.NewReader(qi.content)).Decode(&r); err != nil {
log.Println("activitypub queue:", err.Error())

@ -73,8 +73,6 @@ type goBlog struct {
regexRedirects []*regexRedirect
// Sessions
loginSessions, captchaSessions *dbSessionStore
// Queue triggers
queueTriggers []chan struct{}
// Shutdown
shutdown shutdowner.Shutdowner
// Template strings

@ -6,8 +6,8 @@ import (
)
func (a *goBlog) startPostsScheduler() {
ticker := time.NewTicker(10 * time.Second)
done := make(chan bool)
ticker := time.NewTicker(30 * time.Second)
done := make(chan struct{})
go func() {
for {
select {
@ -20,7 +20,7 @@ func (a *goBlog) startPostsScheduler() {
}()
a.shutdown.Add(func() {
ticker.Stop()
done <- true
done <- struct{}{}
log.Println("Posts scheduler stopped")
})
}

@ -31,10 +31,6 @@ func (a *goBlog) enqueue(name string, content []byte, schedule time.Time) error
if err != nil {
return err
}
// Trigger all queue listeners
for _, trigger := range a.queueTriggers {
trigger <- struct{}{}
}
return nil
}
@ -82,10 +78,6 @@ func (a *goBlog) peekQueue(ctx context.Context, name string) (*queueItem, error)
type queueProcessFunc func(qi *queueItem, dequeue func(), reschedule func(time.Duration))
func (a *goBlog) listenOnQueue(queueName string, wait time.Duration, process queueProcessFunc) {
// Queue trigger
trigger := make(chan struct{})
a.queueTriggers = append(a.queueTriggers, trigger)
// Start goroutine to listen on queue
go func() {
done := false
var wg sync.WaitGroup
@ -109,8 +101,6 @@ func (a *goBlog) listenOnQueue(queueName string, wait time.Duration, process que
select {
case <-time.After(wait):
continue
case <-trigger:
continue
case <-ctx.Done():
done = true
continue

@ -21,7 +21,7 @@ import (
)
func (a *goBlog) initWebmentionQueue() {
a.listenOnQueue("wm", time.Minute, func(qi *queueItem, dequeue func(), reschedule func(time.Duration)) {
a.listenOnQueue("wm", 30*time.Second, func(qi *queueItem, dequeue func(), reschedule func(time.Duration)) {
var m mention
if err := gob.NewDecoder(bytes.NewReader(qi.content)).Decode(&m); err != nil {
log.Println("webmention queue:", err.Error())

Loading…
Cancel
Save