Top Level Namespace

Defined Under Namespace

Classes: CustomStrategyHandler, YggdrasilEngine

Constant Summary collapse

STANDARD_STRATEGIES =
[
  "default",
  "userWithId",
  "gradualRolloutUserId",
  "gradualRolloutSessionId",
  "gradualRolloutRandom",
  "flexibleRollout",
  "remoteAddress",
].freeze
TOGGLE_MISSING_RESPONSE =
'NotFound'.freeze
ERROR_RESPONSE =
'Error'.freeze
OK_RESPONSE =
'Ok'.freeze

Instance Method Summary collapse

Instance Method Details

#platform_specific_libObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/yggdrasil_engine.rb', line 10

def platform_specific_lib
  os = RbConfig::CONFIG['host_os']
  cpu = RbConfig::CONFIG['host_cpu']

  extension, prefix = case os
  when /darwin|mac os/
    ['dylib', 'lib']
  when /linux/
    ['so', 'lib']
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
    ['dll', '']
  else
    raise "unsupported platform #{os}"
  end

  arch_suffix = case cpu
  when /x86_64|x64/
    'x86_64'
  when /arm|aarch64/
    'arm64'
  else
    raise "unsupported architecture #{cpu}"
  end

  lib_type_suffix = if os =~ /linux/
    musl = system("ldd /bin/sh | grep -q musl")
    musl ? "-musl" : ""
  else
    ""
  end

  "#{prefix}yggdrasilffi_#{arch_suffix}#{lib_type_suffix}.#{extension}"
end

#to_variant(raw_variant) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/yggdrasil_engine.rb', line 44

def to_variant(raw_variant)
  payload = raw_variant[:payload] && raw_variant[:payload].transform_keys(&:to_s)
  {
    name: raw_variant[:name],
    enabled: raw_variant[:enabled],
    feature_enabled: raw_variant[:featureEnabled],
    payload: payload,
  }
end