bolshakov / stoplight

:traffic_light: Traffic control for code.
http://bolshakov.github.io/stoplight/
MIT License
381 stars 40 forks source link

Update #names method to retain lights without failures #215

Open bolshakov opened 1 year ago

bolshakov commented 1 year ago

This PR addresses an issue with the #names method. Previously, the method would only retrieve light names that had failures or been locked. This update ensures that the #names method correctly includes light names without failures and locks as well.

Since Stoplight does not require lights to be registered or unregistered explicitly, we lack a means to understand whether a light is still in use or not. To address this issue, I have added an additional stoplight:v4:last_used_at key that stores information about the last time the light was used. This information is updated with every call to Stoplight's #run method.

By default, the #names method returns all lights that have been used within the last 7 days. However, if you provide an optional used_after argument, you can retrieve lights that were used during a different time period.