Module: CI::Queue::Redis::KeyShortener
- Defined in:
- lib/ci/queue/redis/key_shortener.rb
Constant Summary collapse
- SUFFIX_ALIASES =
Suffix mapping for common key patterns
{ 'running' => 'r', 'processed' => 'p', 'queue' => 'q', 'owners' => 'o', 'error-reports' => 'e', 'requeues-count' => 'rc', 'assertions' => 'a', 'errors' => 'er', 'failures' => 'f', 'skips' => 's', 'requeues' => 'rq', 'total_time' => 't', 'test_failed_count' => 'fc', 'completed' => 'c', 'master-status' => 'm', 'created-at' => 'ca', 'workers' => 'w', 'worker' => 'w', 'warnings' => 'wn', 'worker-errors' => 'we', 'flaky-reports' => 'fl', }.freeze
Class Method Summary collapse
-
.key(build_id, *args) ⇒ Object
We’re transforming the key to a shorter format to minimize network traffic.
Class Method Details
.key(build_id, *args) ⇒ Object
We’re transforming the key to a shorter format to minimize network traffic.
Strategy:
-
Shorten prefix: ‘b’ instead of ‘build’
-
Hash UUID: 8-char MD5 instead of 36-char UUID
-
Alias suffixes: single letters instead of full words
Example:
build:unit:019aef0e-c010-433e-b706-c658d3c16372:running (55 bytes)
-> b:f03d3bef:r (13 bytes, 76% reduction)
44 45 46 47 48 49 |
# File 'lib/ci/queue/redis/key_shortener.rb', line 44 def self.key(build_id, *args) digest = Digest::MD5.hexdigest(build_id)[0..7] shortened_args = args.map { |arg| SUFFIX_ALIASES[arg] || arg } ['b', digest, *shortened_args].join(':') end |