Sha256: 777aba20e0a37e687e423a5e6de78f14088f0c8df6fa913ddb889c59c3b39cc2
Contents?: true
Size: 983 Bytes
Versions: 3
Compression:
Stored size: 983 Bytes
Contents
require 'active_support' require 'sitehub/config_server' class SiteHub module Middleware class ConfigLoader attr_reader :config_server, :app, :cache, :caching_options def initialize(_app, config_server_url, caching_options:) @config_server = ConfigServer.new(config_server_url) @cache = ActiveSupport::Cache::MemoryStore.new(size: 1.megabytes) @caching_options = caching_options end def call(env) begin load_config rescue ConfigServer::Error => e if @app env[ERRORS] << e.message else raise e unless @app end end @app.call env end # TODO: handle errors connecting to the config server def load_config unless cache.exist?(:sitehub_config) cache.write(:sitehub_config, :retrieved, caching_options) @app = Core.from_hash(config_server.get).build end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sitehub-0.5.0.alpha12 | lib/sitehub/middleware/config_loader.rb |
sitehub-0.5.0.alpha11 | lib/sitehub/middleware/config_loader.rb |
sitehub-0.5.0.alpha10 | lib/sitehub/middleware/config_loader.rb |