Module: Fluence::Gateway::Configuration

Included in:
Fluence::Gateway
Defined in:
lib/fluence/gateway/configuration.rb

Overview

Provides SDK configuration management.

Extended by Fluence::Gateway so that #config and #configure are available directly on the module (no instance to pass around). The underlying storage is a Settings singleton.

Every attribute (except timeout and tenants) resolves in three tiers: explicit setter value, then a matching ENV variable, then a hard-coded default. client_id and client_secret have no hard-coded default — they must be provided either via the setter or via APPCENTER_CLIENT_ID/APPCENTER_CLIENT_SECRET before any gateway call.

Examples:

Configure the SDK explicitly (typically in a Rails initializer)

Fluence::Gateway.configure do |config|
  config.client_id     = ENV.fetch('APPCENTER_CLIENT_ID')
  config.client_secret = ENV.fetch('APPCENTER_CLIENT_SECRET')
  config.gateway_url   = 'https://gateway.staging.fluence-europe.cloud'
end

Rely on the built-in ENV fallback (e.g. in CI)

# With APPCENTER_CLIENT_ID and APPCENTER_CLIENT_SECRET exported,
# no explicit configuration is required:
Fluence::Gateway.config.client_id # => value of ENV['APPCENTER_CLIENT_ID']

Read a setting at runtime

Fluence::Gateway.config.timeout # => 30

Defined Under Namespace

Classes: Settings, TenantConfig

Constant Summary collapse

PROFILES =

Profiles of default settings. Selecting a profile via Settings#profile= (or ENV['GATEWAY_PROFILE']) swaps the defaults for gateway_url, appcenter_url, ssl_verify, and the built-in tenants. Explicit setter values and matching ENV variables still win over profile defaults — the profile only affects the fallback layer.

Available profiles:

  • :production (default) — the Fluence cloud infrastructure. URLs resolve to *.fluence.eu, SSL peer verification is :peer, and the :mosaic built-in tenant points at mosaic.fluence.eu.
  • :local — the Fluence local Caddy setup exposing *.fluence-europe.dev. URLs resolve to *.fluence-europe.dev, SSL peer verification is :none (Caddy's self-signed chain is not always in Ruby's trust store), and the :mosaic built-in tenant points at mosaic.fluence-europe.dev.

Each profile entry carries the default global URLs and a nested :tenants Hash with the per-profile built-in tenant overrides.

{
  production: {
    gateway_url: 'https://gateway.fluence.eu',
    appcenter_url: 'https://appcenter.fluence.eu',
    ssl_verify: :peer,
    tenants: {
      mosaic: {
        gateway_url: 'https://mosaic.fluence.eu',
        ssr_tenant: true
      }.freeze
    }.freeze
  }.freeze,
  local: {
    gateway_url: 'https://gateway.fluence-europe.dev',
    appcenter_url: 'https://appcenter.fluence-europe.dev',
    ssl_verify: :none,
    tenants: {
      mosaic: {
        gateway_url: 'https://mosaic.fluence-europe.dev',
        ssr_tenant: true
      }.freeze
    }.freeze
  }.freeze
}.freeze

Instance Method Summary collapse

Instance Method Details

#configSettings

Returns the singleton configuration instance.

Returns:

  • (Settings)

    the configuration instance

#configure {|config| ... } ⇒ void

This method returns an undefined value.

Configures the SDK via a block.

Yield Parameters:

  • config (Settings)

    the configuration instance to modify