bolshakov / stoplight

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

Pass Redis client to data store #19

Closed tfausak closed 10 years ago

tfausak commented 10 years ago

Instead of creating a Redis client inside the data store, one could simply be passed into it. This would remove the need to track if Redis was loaded or not.

# before
data_store = Stoplight::DataStore::Redis.new(url: 'redis://...')

# after
redis = Redis.new(url: 'redis://...')
data_store = Stoplight::DataStore::Redis.new(redis)

That would free up the data store to accept actual options, like which key prefix to use.

Stoplight::DataStore::Redis.new(redis, key_prefix: 'stoplight-no-conflict')
clifton commented 10 years ago

Yeah this makes for a better API