Skip to content

Redis-Synchronized Time: Infrastructure & TimeTravel Helper - #917

Open
bolshakov wants to merge 6 commits into
developfrom
feature/use-redis-time
Open

Redis-Synchronized Time: Infrastructure & TimeTravel Helper#917
bolshakov wants to merge 6 commits into
developfrom
feature/use-redis-time

Conversation

@bolshakov

@bolshakov bolshakov commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Creates infrastructure for Redis-synchronized time across distributed Stoplight instances, eliminating clock skew. Implements:

  • now() Lua function that reads from redis.call("TIME") for server-authoritative timestamps
  • Script inclusion system (@include directives) supporting multiple lookup paths
  • Stoplight::TimeTravel helper for deterministic test time control with Redis stack awareness

Time-dependent logic (recovery windows, metrics snapshots, state transitions) requires consistent time across distributed instances. This phase creates the foundation.

Part of: 3-phase refactoring (Phase 1/3) - See GitHub stack below.

Considered alternatives:

  • using FUNCTION LOAD/PCALL - convenient, but essentially requires a migration to be executed before the code
  • injecting time in tests through an script argument and using "TIME" Redis function in production - two completely different mechanism could be error-prone, sometimes we have varargs and this complicates injection.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review price tag

🟢 172 effective lines — about 21–52 min of focused review (based on 200–500 lines/hour). This is within the range where reviewers find the most issues per line, and small changes usually receive feedback the fastest.

Why these numbers?

These minutes are what careful defect-finding costs at 200–500 lines/hour — the rate review studies report, not how long a skim takes. "Effective lines" already exclude generated files and lockfiles. Treat the rates and the 200/400 thresholds as guardrails, not laws.

@github-actions github-actions Bot added the proquo: small ProQuo review price tier: small label Sep 1, 2026
@bolshakov
bolshakov force-pushed the feature/use-redis-time branch 2 times, most recently from 52fd534 to b142e99 Compare September 1, 2026 18:50
@bolshakov bolshakov changed the title Implement redis' now() function with time-traveling capabilities Freezes time in both Ruby and Redis for consistent test time control. Sep 1, 2026
@bolshakov bolshakov changed the title Freezes time in both Ruby and Redis for consistent test time control. Freezes time in both Ruby and Redis for consistent test time control Sep 1, 2026
@bolshakov
bolshakov force-pushed the feature/use-redis-time branch 6 times, most recently from a0f55c1 to 4b31581 Compare September 2, 2026 10:11
@bolshakov
bolshakov force-pushed the feature/use-redis-time branch from 4b31581 to 0c1f82f Compare September 2, 2026 11:13
@bolshakov
bolshakov marked this pull request as ready for review September 2, 2026 11:13
@bolshakov bolshakov changed the title Freezes time in both Ruby and Redis for consistent test time control Redis-Synchronized Time: Infrastructure & TimeTravel Helper Sep 2, 2026
@bolshakov
bolshakov requested a review from Lokideos September 2, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

proquo: small ProQuo review price tier: small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant