{"id":18542725,"url":"https://github.com/coinbase/service_variables","last_synced_at":"2025-10-25T12:33:02.237Z","repository":{"id":56895127,"uuid":"102164690","full_name":"coinbase/service_variables","owner":"coinbase","description":"Service level variables backed by Redis - useful for service wide configuration.","archived":false,"fork":false,"pushed_at":"2019-11-03T05:14:23.000Z","size":15,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-24T10:38:40.537Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/service_variables","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-02T01:25:23.000Z","updated_at":"2024-09-29T01:05:48.000Z","dependencies_parsed_at":"2022-08-21T01:20:43.326Z","dependency_job_id":null,"html_url":"https://github.com/coinbase/service_variables","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fservice_variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fservice_variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fservice_variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fservice_variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/service_variables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248087842,"owners_count":21045598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T20:09:59.269Z","updated_at":"2025-10-25T12:32:57.205Z","avatar_url":"https://github.com/coinbase.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ServiceVariables\n\n_Service-wide_ Redis backed configuration variables which can be edited while your application is running. This is particularly useful for 12 factor apps which can scale arbitrarily but need centralized configuration. Data types, defaults and boundaries can all be specified.\n\n_Note:_ this was implemented on Redis 3.\n\n## Install\n```bash\ngem install service_variables\n```\n\n## Usage\n\nYou will want to create a configuration object where you can configure the Redis endpoint and the define configuration variables.\n\n```ruby\nrequire 'service_variables'\n\nmodule App\n  class Config\n    extend ServiceVariables\n\n    # redis_client [Required] Give the ServiceConfig object a Redis client to store values.\n    # redis_key    [Optional] Specify a redis key if you have multiple of these\n    #                         objects using the same Redis instance.\n    # failure_mode [Optional] Sepcify a failure mode to fall back on if redis is unavailable.\n    #                         Defaults to :raise_exception\n    configure redis_client: Redis.new(url: ENV.fetch('REDIS_URL')),\n              redis_key: 'special_key',\n              failure_mode: :raise_exception\n\n    boolean_option :foo, default: false, failure_mode: :use_last_value\n    integer_option :bar, default: 10, min: 1, max: 100, failure_mode: :use_default\n    float_option   :baz, default: 3.0, min: 1.0, max: 5.0\n    string_option  :boo, default: 'fizz', enum: ['fizz', 'fuzz']\n\n    # If the default param is not given, `nil` is assumed.\n    # If boundary or enum params are not given, these checks are ignored.\n  end\nend\n```\n\nIn your application you can then call or edit values.\n\n```ruby\nApp::Config.foo #=\u003e false\nApp::Config.foo = true\nApp::Config.foo #=\u003e true\n\nApp::Config.bar = 1_000 #=\u003e throws InvalidValueError, 'Value too large. max = 1000'\n```\n\n### Failure Modes\n\nTo protect against redis connection failures you can specify a designated failure mode when you create your configuration object or on a configuration variable granularity.\n\n```ruby\nfailure_mode: :raise_exception #=\u003e raise an exception if cannot connect to Redis\nfailure_mode: :use_default #=\u003e use the default value provided at configuration\nfailure_mode: :use_last_value #=\u003e use the last value that was read from Redis\n```\n\n## Testing\n\n```bash\n# spin up redis locally\ndocker run --rm -d -p 6379:6379 redis\n\n# run spec\nbundle exec rspec spec\n```\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at https://github.com/coinbase/service_variables.\n\n## License\nThe gem is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fservice_variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fservice_variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fservice_variables/lists"}