Files
next.orly.dev/pkg/event/routing/ephemeral.go
woikos 9da1784b1b
Some checks are pending
Go / build-and-release (push) Waiting to run
Add Blossom bandwidth limiting and tune rate limiters (v0.49.0)
- Add token-bucket bandwidth rate limiting for Blossom uploads
  - ORLY_BLOSSOM_RATE_LIMIT enables limiting (default: false)
  - ORLY_BLOSSOM_DAILY_LIMIT_MB sets daily limit (default: 10MB)
  - ORLY_BLOSSOM_BURST_LIMIT_MB sets burst cap (default: 50MB)
  - Followed users, admins, owners are exempt (unlimited)
- Change emergency mode throttling from exponential to linear scaling
  - Old: 16x multiplier at emergency threshold entry
  - New: 1x at threshold, +1x per 20% excess pressure
- Reduce follows ACL throttle increment from 200ms to 25ms per event
- Update dependencies

Files modified:
- app/blossom.go: Pass rate limit config to blossom server
- app/config/config.go: Add Blossom rate limit config options
- pkg/blossom/ratelimit.go: New bandwidth limiter implementation
- pkg/blossom/server.go: Add rate limiter integration
- pkg/blossom/handlers.go: Check rate limits on upload/mirror/media
- pkg/ratelimit/limiter.go: Linear emergency throttling
- pkg/acl/follows.go: Reduce default throttle increment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:09:39 +01:00

33 lines
950 B
Go

package routing
import (
"git.mleku.dev/mleku/nostr/encoders/event"
"git.mleku.dev/mleku/nostr/encoders/kind"
"lol.mleku.dev/log"
)
// Publisher abstracts event delivery to subscribers.
type Publisher interface {
// Deliver sends an event to all matching subscribers.
Deliver(ev *event.E)
}
// IsEphemeral checks if a kind is ephemeral (20000-29999).
func IsEphemeral(k uint16) bool {
return kind.IsEphemeral(k)
}
// MakeEphemeralHandler creates a handler for ephemeral events.
// Ephemeral events (kinds 20000-29999):
// - Are NOT persisted to the database
// - Are immediately delivered to subscribers
func MakeEphemeralHandler(publisher Publisher) Handler {
return func(ev *event.E, authedPubkey []byte) Result {
log.I.F("ephemeral handler received event kind %d, id %0x", ev.Kind, ev.ID[:8])
// Clone and deliver immediately without persistence
cloned := ev.Clone()
go publisher.Deliver(cloned)
return HandledResult("")
}
}