Skip to content

Releases: pinealctx/x

v0.3.0

15 Apr 14:31
c552a31

Choose a tag to compare

What's New

ds.SortedMap[K,V]

Ordered map combining O(1) random access by key with O(log n) sorted iteration. Backed by a hash map and B-tree. The sort key and the map lookup key can be different fields of V.

m := ds.NewSortedMap[int, Item](
    func(v Item) int { return v.ID },
    func(a, b Item) bool { return a.Score < b.Score },
)
m.Set(Item{ID: 1, Score: 3.0})
for v := range m.Ascend() {
    fmt.Println(v.ID, v.Score)
}

Breaking Changes

- ds.Set.Contains(val) renamed to ds.Set.Has(val) for consistency with other container types

Improvements

- Unified panic message format to "pkg: FuncName: condition" across ds, syncx, retryx
- Added SortedMap documentation explaining why Clone()/Keys()/Values() are not provided
- Fixed README dependency claim ("Zero""Minimal") and added SortedMap section

Full Changelog

- 939f170 Add ds.SortedMap[K,V] backed by hash map + B-tree
- 86530e4 Fix API consistency and panic message format from full audit

v0.2.0 — 2026-04-10

10 Apr 06:20
d370945

Choose a tag to compare

v0.2.0 — 2026-04-10

Adds three new packages, syncx.Race, and several fixes.

Requires Go 1.26+. Zero external dependencies.

New packages

panicx — Panic recovery with structured stack capture.

  • NewPanicError(r) / NewPanicErrorSkip(r, skip) — convert recovered value to *PanicError
  • ErrPanic sentinel — checkable via errors.Is(err, panicx.ErrPanic)
  • Stack() — returns captured stack frames as []string

handlerx — Generic, framework-agnostic middleware chain for RPC handlers.

  • Handler[Req, Resp] / Interceptor[Req, Resp] — core function types
  • Chain — composes interceptors around a handler, outermost-first
  • WithTimeout / WithRecovery — built-in interceptors

pipeline — Declarative step-execution graph.

  • Then — sequential step
  • Parallel — concurrent, all must succeed
  • Race — concurrent, first success wins

New APIs

  • syncx.Race[T] — returns the first successful result from concurrent functions; if all fail, returns the last error.

Fixes

  • syncx.Group / syncx.SingleFlight — panic recovery now produces *panicx.PanicError (checkable via errors.Is(err, panicx.ErrPanic)) instead of opaque fmt.Errorf.
  • retryx.NewExponential — large attempt values no longer overflow time.Duration to negative; capped at math.MaxInt64.
  • ds.HeapPop clears the slot to help GC with pointer-typed elements.

Other changes

  • go.mod bumped to 1.26.2.
  • README.md updated with all 8 packages, accurate API examples, and complete method references.

Quality

  • 100% test coverage across all 8 packages
  • Race-detector clean (go test -race ./...)
  • golangci-lint and govulncheck pass with zero issues

First release of `github.com/pinealctx/x`.

07 Apr 08:16

Choose a tag to compare

v0.1.0 — 2026-04-07

First release of github.com/pinealctx/x.

Requires Go 1.26+. Zero external dependencies.

New packages

errorx — Typed error codes and domain-isolated sentinels.

  • Error[Code] — coded error with optional cause chain
  • Sentinel[D] — phantom-type sentinel, prevents cross-domain errors.Is
  • IsCode / ContainsCode — chain-aware code queries

syncx — Generic concurrent primitives.

  • KeyedMutex[K] / KeyedLocker[K] — per-key mutex/rwmutex with ref-counted cleanup
  • BlockingQueue[T] — context-aware blocking queue with close semantics
  • RingQueue[T] — fixed-capacity queue, evicts oldest on full
  • ReadThrough[K,V] — cache-aside with per-key stampede protection
  • Pool[T] — type-safe sync.Pool wrapper with optional reset
  • Dispatcher[K,V] — key-hash routed slot dispatcher, preserves per-key ordering
  • SingleFlight[K,V] — concurrent call deduplication per key
  • Group[T] — concurrent result collector, submission-order results, panic recovery

ds — Generic data structures.

  • OrderedMap[K,V] — insertion-ordered map, O(1) access, zero-allocation iteration
  • Set[T] — set algebra and relation checks
  • BiMap[K,V] — bidirectional O(1) lookup
  • Stack[T] — LIFO stack
  • Heap[T] — binary heap with custom comparator (NewMinHeap / NewMaxHeap)

retryx — Generic retry with composable backoff.

  • Do[T] — retries a function with Attempts, Backoff, RetryIf, OnRetry
  • NewExponential / NewFixed — backoff bases
  • WithJitter / WithMaxWait — backoff decorators

ctxv — Type-safe context values.

  • Key[T] — generic context key bound to type T
  • WithValue / Value / MustValue — compile-time type-safe context access