Class: Asherah::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/asherah/config.rb

Constant Summary collapse

MAPPING =
{
  service_name: :ServiceName,
  product_id: :ProductID,
  kms: :KMS,
  metastore: :Metastore,
  connection_string: :ConnectionString,
  replica_read_consistency: :ReplicaReadConsistency,
  sql_metastore_db_type: :SQLMetastoreDBType,
  dynamo_db_endpoint: :DynamoDBEndpoint,
  dynamo_db_region: :DynamoDBRegion,
  dynamo_db_table_name: :DynamoDBTableName,
  enable_region_suffix: :EnableRegionSuffix,
  region_map: :RegionMap,
  preferred_region: :PreferredRegion,
  session_cache_max_size: :SessionCacheMaxSize,
  session_cache_duration: :SessionCacheDuration,
  enable_session_caching: :EnableSessionCaching,
  expire_after: :ExpireAfter,
  check_interval: :CheckInterval,
  verbose: :Verbose
}.freeze
KMS_TYPES =
['static', 'aws', 'test-debug-static'].freeze
METASTORE_TYPES =
['rdbms', 'dynamodb', 'memory', 'test-debug-memory'].freeze
SQL_METASTORE_DB_TYPES =
['mysql', 'postgres', 'oracle'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#check_interval,Integer

The amount of time in seconds before cached keys are considered stale

Returns:

  • (Integer)

    the current value of check_interval,



25
26
27
# File 'lib/asherah/config.rb', line 25

def check_interval,
  @check_interval,
end

#connection_string,String

The database connection string (required when metastore is rdbms)

Returns:

  • (String)

    the current value of connection_string,



25
26
27
# File 'lib/asherah/config.rb', line 25

def connection_string,
  @connection_string,
end

#dynamo_db_endpoint,String

An optional endpoint URL (for dynamodb metastore)

Returns:

  • (String)

    the current value of dynamo_db_endpoint,



25
26
27
# File 'lib/asherah/config.rb', line 25

def dynamo_db_endpoint,
  @dynamo_db_endpoint,
end

#dynamo_db_region,String

The AWS region for DynamoDB requests (for dynamodb metastore)

Returns:

  • (String)

    the current value of dynamo_db_region,



25
26
27
# File 'lib/asherah/config.rb', line 25

def dynamo_db_region,
  @dynamo_db_region,
end

#dynamo_db_table_name,String

The table name for DynamoDB (for dynamodb metastore)

Returns:

  • (String)

    the current value of dynamo_db_table_name,



25
26
27
# File 'lib/asherah/config.rb', line 25

def dynamo_db_table_name,
  @dynamo_db_table_name,
end

#enable_region_suffix,Boolean

Configure the metastore to use regional suffixes (for dynamodb metastore)

Returns:

  • (Boolean)

    the current value of enable_region_suffix,



25
26
27
# File 'lib/asherah/config.rb', line 25

def enable_region_suffix,
  @enable_region_suffix,
end

#enable_session_caching,Boolean

Enable shared session caching

Returns:

  • (Boolean)

    the current value of enable_session_caching,



25
26
27
# File 'lib/asherah/config.rb', line 25

def enable_session_caching,
  @enable_session_caching,
end

#expire_after,Integer

The amount of time in seconds a key is considered valid

Returns:

  • (Integer)

    the current value of expire_after,



25
26
27
# File 'lib/asherah/config.rb', line 25

def expire_after,
  @expire_after,
end

#kms,String

The master key management service (static or aws)

Returns:

  • (String)

    the current value of kms,



25
26
27
# File 'lib/asherah/config.rb', line 25

def kms,
  @kms,
end

#metastore,String

The type of metastore for persisting keys (rdbms, dynamodb, memory)

Returns:

  • (String)

    the current value of metastore,



25
26
27
# File 'lib/asherah/config.rb', line 25

def metastore,
  @metastore,
end

#preferred_region,String

The preferred AWS region (required for aws kms)

Returns:

  • (String)

    the current value of preferred_region,



25
26
27
# File 'lib/asherah/config.rb', line 25

def preferred_region,
  @preferred_region,
end

#product_id,String

The name of the product that owns this service

Returns:

  • (String)

    the current value of product_id,



25
26
27
# File 'lib/asherah/config.rb', line 25

def product_id,
  @product_id,
end

#region_map,String

List of key-value pairs in the form of REGION1=ARN1 (required for aws kms)

Returns:

  • (String)

    the current value of region_map,



25
26
27
# File 'lib/asherah/config.rb', line 25

def region_map,
  @region_map,
end

#replica_read_consistency,String

For Aurora sessions using write forwarding (eventual, global, session)

Returns:

  • (String)

    the current value of replica_read_consistency,



25
26
27
# File 'lib/asherah/config.rb', line 25

def replica_read_consistency,
  @replica_read_consistency,
end

#service_name,String

The name of this service

Returns:

  • (String)

    the current value of service_name,



25
26
27
# File 'lib/asherah/config.rb', line 25

def service_name,
  @service_name,
end

#session_cache_duration,Integer

The amount of time in seconds a session will remain cached

Returns:

  • (Integer)

    the current value of session_cache_duration,



25
26
27
# File 'lib/asherah/config.rb', line 25

def session_cache_duration,
  @session_cache_duration,
end

#session_cache_max_size,Integer

The maximum number of sessions to cache

Returns:

  • (Integer)

    the current value of session_cache_max_size,



25
26
27
# File 'lib/asherah/config.rb', line 25

def session_cache_max_size,
  @session_cache_max_size,
end

#sql_metastore_db_type,String

Which SQL driver to use (mysql, postgres, oracle), defaults to mysql

Returns:

  • (String)

    the current value of sql_metastore_db_type,



25
26
27
# File 'lib/asherah/config.rb', line 25

def sql_metastore_db_type,
  @sql_metastore_db_type,
end

#verbose,Boolean

Enable verbose logging output

Returns:

  • (Boolean)

    the current value of verbose,



25
26
27
# File 'lib/asherah/config.rb', line 25

def verbose,
  @verbose,
end

Instance Method Details

#to_json(*args) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/asherah/config.rb', line 63

def to_json(*args)
  config = {}.tap do |c|
    MAPPING.each_pair do |our_key, their_key|
      value = public_send(our_key)
      c[their_key] = value unless value.nil?
    end
  end

  JSON.generate(config, *args)
end

#validate!Object



54
55
56
57
58
59
60
61
# File 'lib/asherah/config.rb', line 54

def validate!
  validate_service_name
  validate_product_id
  validate_kms
  validate_metastore
  validate_sql_metastore_db_type
  validate_kms_attributes
end