Skip to content

OsagieDG/hyper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyper

  • In-memory event bus built for notifications
  • Reliable delivery with automatic retry, exponential backoff, and dead-letter logging

Hyper provides?

  • 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: NotificationRecord prevents duplicate delivery across retries

Installation

     go get github.com/OsagieDG/hyper

Usage

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)

About

In-memory event bus built for notifications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages