Repository navigation
Releases: bdurand/consistent_random
Releases · bdurand/consistent_random
Release list
v2.3.0
Fixed
ConsistentRandom#randcan 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, causingrandto return 1.0,rand(n)to returnn, andrand(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#randfor ranges with negative bounds. Values were truncated toward zero instead of floored, so for a range like-5..5the minimum value was never returned and zero was returned twice as often as other values. ConsistentRandom#randnow raises anArgumentErrorfor empty ranges (e.g.5..1) and non-numeric ranges instead of returning out of range values or raising aNoMethodError.ConsistentRandom::Testing#bytesnow raises anArgumentErrorfor empty strings, which were previously accepted but silently ignored, producing non-deterministic values in tests.
Changed
ConsistentRandom.current_seedis 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
Added
- Added
ConsistentRandom.testingmethod to allow for deterministic testing of random values. - Added
ConsistentRandom#namemethod to return the name used for seeding the random value.
Full Changelog: v2.1.1...v2.2.0
v2.1.1
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
Added
- Added optional seed block to the Rack middleware to allow for custom seed values based on the request.
- Added helper method
ConsistentRandom::SidekiqMiddleware.installto install both the client and server middlewares in one call.
Full Changelog: v2.0.0...v2.1.0
v2.0.0
Changed
ConsistentRandom#randuses a faster hashing algorithm for generating random values. This will make the value consistent across different Ruby versions and platforms.
Added
- Added
ConsistentRandom::SidekiqClientMiddlewareto allow persisting consistent random seeds to Sidekiq jobs so behavior is consistent between when jobs are enqueued and when they are executed. - Added
ConsistentRandom::ActiveJobfor hooking into ActiveJob to persist consistent random seeds to jobs.
Full Changelog: v1.0.0...v2.0.0