这是indexloc提供的服务,不要输入任何密码
Skip to content

v0.1.41

Compare
Choose a tag to compare
@Raezil Raezil released this 26 Apr 07:52
· 26 commits to main since this release

Release Notes (v0.1.41, 2025-04-26)

Welcome to the inaugural April 2025 release of GoEventBus, your in-process, lock-free event bus for Go. This version delivers a major overhaul—with context-aware handlers, flexible back-pressure, observability, and async support—designed to power low-latency pipelines, microservices, and game loops.

Highlights

  • Context-Aware Handlers
    Every event handler now receives a context.Context, unlocking deadlines, cancellation, and tracing for your event-driven workflows.

  • Lock-Free Ring Buffer
    Under the hood is a cache-aligned, atomic ring buffer that dispatches events without locks or syscalls—delivering sub-microsecond hand-offs and zero garbage.

  • Configurable Overrun Policies
    Choose how to handle a full buffer with three strategies:

    • DropOldest (default): discard the oldest events to make room
    • Block: back-pressure until space becomes available
    • ReturnError: fail fast with ErrBufferFull for explicit retry logic
  • Async or Sync Processing
    Flip the Async flag to switch between inline, predictable dispatch or massive parallelism via a worker pool sized to your CPU count.

  • Middleware & Hooks
    Introduce cross-cutting behavior with middleware chains, and tap into execution with before-, after-, and error-hooks for observability and instrumentation.

  • Built-In Metrics
    Track total published, processed, and errored events directly via Metrics(), without additional instrumentation.

  • Zero Dependencies
    Drop-in import (github.com/Raezil/GoEventBus), no brokers to manage—just Go 1.21+ and you’re off.


Changelog

v0.1.41 (2025-04-26)

🚀 Added

  • New context.Context support for all handlers to enable cancellation, timeouts, and tracing.
  • Lock-free ring buffer implementation with cache-line padding for minimal latency.
  • Overrun policies: DropOldest, Block, and ReturnError for flexible back-pressure strategies.
  • Async flag on EventStore to toggle between synchronous and asynchronous dispatch.
  • Middleware support via Use(mw Middleware) to wrap handlers.
  • Hooks:
    • OnBefore (before handler execution)
    • OnAfter (after handler execution)
    • OnError (on handler error)
  • Worker pool sized to runtime.NumCPU() for async processing when Async=true.
  • Metrics() method exposing publishedCount, processedCount, and errorCount.
  • Drain(ctx) and Close(ctx) for graceful shutdown of async workers.

🔧 Changed

  • Default back-pressure policy remains DropOldest to preserve prior behavior.
  • Improved API ergonomics: event IDs and projections are explicit in the Event struct.
  • Internal buffer size validation now panics if not a power of two.

🐞 Fixed

  • Corrected atomic indexing in Subscribe to prevent rare race conditions under extreme load.
  • Ensured Publish skips nil slots to avoid spurious dispatch attempts.

🗑️ Removed

  • Deprecated previous no-context handler signature (fully replaced by HandlerFunc).