- In-memory event bus built for notifications
- Reliable delivery with automatic retry, exponential backoff, and dead-letter logging
- Priority: high-priority notifications are processed before low-priority ones
- Decoupling: producers emit events without knowing who is listening
- Retry + dead-letter: failed handlers are retried up to 3 times with exponential backoff; unrecoverable failures are logged
- Idempotency:
NotificationRecordprevents duplicate delivery across retries
go get github.com/OsagieDG/hyper
import github.com/OsagieDG/hyper/event
- Check out the example.go for a sample usage
record := event.NewNotificationRecord()
fmt.Println("\n Pub/Sub Usage Example")
createUser := event.Subscribe("user_created", func(_ context.Context, msg any) error {
userID := fmt.Sprintf("%v", msg)
if record.HasSent(userID) {
return nil
}
slog.Info(fmt.Sprintf("Sending user_created notification: %v", msg))
record.MarkSent(userID)
return nil
})
event.Produce("user_created", "Alice", event.HighPriority)
event.Produce("user_created", "Bob", event.MediumPriority)
time.Sleep(50 * time.Millisecond)
fmt.Println("\n Unsubscribe Usage Example")
event.Unsubscribe(createUser)
time.Sleep(50 * time.Millisecond)