Skip to content

Releases: bdurand/consistent_random

v2.3.0

Choose a tag to compare

@bdurand bdurand released this 11 Jul 16:57
Immutable release. Only release title and notes can be modified.
3808e68

Fixed

  • ConsistentRandom#rand can no longer return an out of range value. Previously there was a very small chance (about 1 in 2⁵³) that a seed could produce a value of exactly 1.0, causing rand to return 1.0, rand(n) to return n, and rand(range) to return a value above the range. Random floats are now derived from the top 53 bits of the seed, guaranteeing a uniform value in [0, 1). Note: this changes the exact values generated for existing seeds (the distribution is unchanged), so percentage rollouts in flight during an upgrade may reassign.
  • Fixed distribution bias in ConsistentRandom#rand for ranges with negative bounds. Values were truncated toward zero instead of floored, so for a range like -5..5 the minimum value was never returned and zero was returned twice as often as other values.
  • ConsistentRandom#rand now raises an ArgumentError for empty ranges (e.g. 5..1) and non-numeric ranges instead of returning out of range values or raising a NoMethodError.
  • ConsistentRandom::Testing#bytes now raises an ArgumentError for empty strings, which were previously accepted but silently ignored, producing non-deterministic values in tests.

Changed

  • ConsistentRandom.current_seed is now public API; it can be used to propagate a scope into threads or fibers, which do not inherit the fiber-local scope state.

Full Changelog: v2.2.0...v2.3.0

v2.2.0

Choose a tag to compare

@bdurand bdurand released this 20 Nov 08:04

Added

  • Added ConsistentRandom.testing method to allow for deterministic testing of random values.
  • Added ConsistentRandom#name method to return the name used for seeding the random value.

Full Changelog: v2.1.1...v2.2.0

v2.1.1

Choose a tag to compare

@bdurand bdurand released this 20 Nov 00:54
28c1167

What's Changed

Fixed

  • Fixed typo in == method which caused a NoMethodError when comparing ConsistentRandom instances.

Full Changelog: v2.1.0...v2.1.1

v2.1.0

Choose a tag to compare

@bdurand bdurand released this 27 Oct 18:15
734892f

Added

  • Added optional seed block to the Rack middleware to allow for custom seed values based on the request.
  • Added helper method ConsistentRandom::SidekiqMiddleware.install to install both the client and server middlewares in one call.

Full Changelog: v2.0.0...v2.1.0

v2.0.0

Choose a tag to compare

@bdurand bdurand released this 24 Oct 06:12
7dcb1df

Changed

  • ConsistentRandom#rand uses a faster hashing algorithm for generating random values. This will make the value consistent across different Ruby versions and platforms.

Added

  • Added ConsistentRandom::SidekiqClientMiddleware to allow persisting consistent random seeds to Sidekiq jobs so behavior is consistent between when jobs are enqueued and when they are executed.
  • Added ConsistentRandom::ActiveJob for hooking into ActiveJob to persist consistent random seeds to jobs.

Full Changelog: v1.0.0...v2.0.0

Initial release

Choose a tag to compare

@bdurand bdurand released this 06 Oct 05:33
v1.0.0

Version 1.0.0