Files
pages/internal/server/ordoschnellic.go
T
Anya Tokugawa d5d21b7841
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s
Refactor architecture into eight components and consolidate reliability work
Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts.

Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation.

Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
2026-11-01 15:23:31 +09:00

50 lines
1.8 KiB
Go

package server
import (
"context"
"fmt"
"net/http"
"time"
"pageswiki/internal/ordoschnellic"
"pageswiki/internal/store"
)
type notificationDeliveryQueue struct{ store *store.Store }
func (q notificationDeliveryQueue) Cleanup(ctx context.Context, at time.Time) error {
return q.store.CleanupNotificationPush(ctx, at)
}
func (q notificationDeliveryQueue) Claim(ctx context.Context, at time.Time) (*ordoschnellic.PushDelivery, error) {
return q.store.ClaimNotificationPushAt(ctx, at)
}
func (q notificationDeliveryQueue) DeferFocused(ctx context.Context, d *ordoschnellic.PushDelivery, at time.Time) error {
return q.store.DeferFocusedNotificationPushAt(ctx, d, at)
}
func (q notificationDeliveryQueue) Finish(ctx context.Context, d *ordoschnellic.PushDelivery, outcome ordoschnellic.Outcome, at time.Time) error {
return q.store.FinishNotificationPushAt(ctx, d, outcome.Retry, outcome.Expired, at)
}
func notificationDeliveryClient() *http.Client {
// Preserve pinned public-address dialing and never follow push redirects.
client := calendarSourceClient()
client.Timeout = 5 * time.Second
client.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }
return client
}
func (s *Server) deliverNotificationPushContext(ctx context.Context, job *store.EventJob) error {
dispatcher := ordoschnellic.Dispatcher{
Queue: notificationDeliveryQueue{s.store},
Sender: ordoschnellic.WebPush{Keys: s.notificationPushKeys, Client: notificationDeliveryClient()},
}
stats, err := dispatcher.Run(ctx)
if err != nil {
return err
}
if stats.Sent+stats.Failed > 0 {
_ = s.store.AddEventLog(job.UUID, job.EventUUID, "info", fmt.Sprintf("component=%s push sent=%d failed=%d (no payload or endpoint logged)", ordoschnellic.Component, stats.Sent, stats.Failed))
}
return nil
}