Module: Smplkit

Defined in:
lib/smplkit.rb,
lib/smplkit/ws.rb,
lib/smplkit/debug.rb,
lib/smplkit/client.rb,
lib/smplkit/errors.rb,
lib/smplkit/context.rb,
lib/smplkit/helpers.rb,
lib/smplkit/metrics.rb,
lib/smplkit/railtie.rb,
lib/smplkit/version.rb,
lib/smplkit/log_level.rb,
lib/smplkit/flags/types.rb,
lib/smplkit/flags/client.rb,
lib/smplkit/flags/models.rb,
lib/smplkit/config/client.rb,
lib/smplkit/config/models.rb,
lib/smplkit/flags/helpers.rb,
lib/smplkit/config/helpers.rb,
lib/smplkit/logging/client.rb,
lib/smplkit/logging/levels.rb,
lib/smplkit/logging/models.rb,
lib/smplkit/logging/helpers.rb,
lib/smplkit/logging/sources.rb,
lib/smplkit/management/types.rb,
lib/smplkit/config_resolution.rb,
lib/smplkit/logging/normalize.rb,
lib/smplkit/management/buffer.rb,
lib/smplkit/management/client.rb,
lib/smplkit/management/models.rb,
lib/smplkit/logging/adapters/base.rb,
lib/smplkit/generators/install_generator.rb,
lib/smplkit/logging/adapters/stdlib_logger_adapter.rb,
lib/smplkit/logging/adapters/semantic_logger_adapter.rb

Overview

Official Ruby SDK for the smplkit platform.

require "smplkit"

client = Smplkit::Client.new(environment: "production", service: "my-svc")
flag = client.flags.boolean_flag("checkout-v2", default: false)
flag.get

Defined Under Namespace

Modules: Config, ConfigResolution, Debug, Errors, Flags, Generators, Helpers, Logging, Management, Op, RequestContext Classes: ApiErrorDetail, Client, ConflictError, ConnectionError, Context, ContextScope, Error, FlagDeclaration, LogLevel, ManagementClient, MetricsReporter, NotFoundError, Railtie, Rule, SharedWebSocket, TimeoutError, ValidationError

Constant Summary collapse

VERSION =
"0.0.0"
FlagValue =

Top-level re-exports for convenience.

Flags::FlagValue
FlagRule =
Flags::FlagRule
FlagEnvironment =
Flags::FlagEnvironment
ConfigItem =

Top-level re-exports.

Config::ConfigItem
ConfigEnvironment =
Config::ConfigEnvironment
ItemType =
Config::ItemType
LoggerSource =

Top-level re-export.

Logging::LoggerSource
Color =
Management::Color
EnvironmentClassification =
Management::EnvironmentClassification
LoggingAdapter =

Top-level re-export.

Logging::Adapters::Base
StdlibLoggerAdapter =
Logging::Adapters::StdlibLoggerAdapter

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject

Returns the value of attribute client.



46
47
48
# File 'lib/smplkit/railtie.rb', line 46

def client
  @client
end

.context_providerObject

Returns the value of attribute context_provider.



46
47
48
# File 'lib/smplkit/railtie.rb', line 46

def context_provider
  @context_provider
end

Class Method Details

.configure_for_rails(options) ⇒ Object

Construct the global Smplkit.client from a Rails-friendly options struct. Falls back to SMPLKIT_* env vars + ~/.smplkit resolution for any field the customer left blank.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smplkit/railtie.rb', line 29

def configure_for_rails(options)
  client = Client.new(
    api_key: options.api_key,
    environment: options.environment || (defined?(::Rails) ? ::Rails.env : nil),
    service: options.service,
    profile: options.profile,
    base_domain: options.base_domain,
    scheme: options.scheme,
    debug: options.debug,
    telemetry: options.telemetry
  )
  @client = client
  @context_provider = options.context_provider
  client
end

.debug(subsystem, message) ⇒ Object



43
44
45
# File 'lib/smplkit/debug.rb', line 43

def debug(subsystem, message)
  Debug.emit(subsystem, message)
end

.enable_debugObject



47
48
49
# File 'lib/smplkit/debug.rb', line 47

def enable_debug
  Debug.enable!
end

.request_contextObject



65
66
67
# File 'lib/smplkit/context.rb', line 65

def request_context
  RequestContext.get
end

.set_request_context(contexts) ⇒ Object



60
61
62
63
# File 'lib/smplkit/context.rb', line 60

def set_request_context(contexts)
  previous = RequestContext.set(contexts)
  ContextScope.new(previous)
end