Tyrex.Pool.Strategy.Hash (Tyrex v0.3.0)

Copy Markdown View Source

Hash-based dispatch strategy for sticky sessions.

Routes requests by a :key option — the same key always hits the same runtime. Useful for stateful JavaScript sessions (e.g., per-user state).

Tyrex.Pool.eval(:pool, "getCart()", key: user_id)

If no :key is provided, falls back to random selection.

Summary

Functions

Selects a runtime index in 0..size-1 deterministically from opts[:key] using :erlang.phash2/2. Falls back to a random index when no :key is provided.

Functions

select(size, opts)

Selects a runtime index in 0..size-1 deterministically from opts[:key] using :erlang.phash2/2. Falls back to a random index when no :key is provided.