Sha256: aae83f8423b84a0bfde29fbbe4cd30d6f25669cbe1580e59dd0316883c5a3435

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

module Rimless
  # The configuration for the rimless gem.
  class Configuration
    include ActiveSupport::Configurable

    # Used to identity this client on the user agent header
    config_accessor(:app_name) { Rimless.local_app_name }

    # Environment to use
    config_accessor(:env) do
      next(ENV.fetch('KAFKA_ENV', Rails.env).to_sym) if defined? Rails

      ENV.fetch('KAFKA_ENV', 'development').to_sym
    end

    # The Apache Kafka client id (consumer group name)
    config_accessor(:client_id) do
      ENV.fetch('KAFKA_CLIENT_ID', Rimless.local_app_name)
    end

    # The logger instance to use (when available we use the +Rails.logger+)
    config_accessor(:logger) do
      next(Rails.logger) if defined? Rails

      Logger.new($stdout)
    end

    # At least one broker of the Apache Kafka cluster
    config_accessor(:kafka_brokers) do
      ENV.fetch('KAFKA_BROKERS', 'kafka://message-bus.local:9092').split(',')
    end

    # The source Apache Avro schema files location (templates)
    config_accessor(:avro_schema_path) do
      path = %w[config avro_schemas]
      next(Rails.root.join(*path)) if defined? Rails

      Pathname.new(Dir.pwd).join(*path)
    end

    # The compiled Apache Avro schema files location (usable with Avro gem)
    config_accessor(:compiled_avro_schema_path) do
      path = %w[config avro_schemas compiled]
      next(Rails.root.join(*path)) if defined? Rails

      Pathname.new(Dir.pwd).join(*path)
    end

    # The Confluent Schema Registry API URL to use
    config_accessor(:schema_registry_url) do
      ENV.fetch('KAFKA_SCHEMA_REGISTRY_URL',
                'http://schema-registry.message-bus.local')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rimless-0.3.0 lib/rimless/configuration.rb
rimless-0.2.1 lib/rimless/configuration.rb
rimless-0.2.0 lib/rimless/configuration.rb
rimless-0.1.4 lib/rimless/configuration.rb
rimless-0.1.3 lib/rimless/configuration.rb
rimless-0.1.2 lib/rimless/configuration.rb
rimless-0.1.1 lib/rimless/configuration.rb
rimless-0.1.0 lib/rimless/configuration.rb