Module: Appfuel::Service::Config
- Defined in:
- lib/appfuel/service/config.rb,
lib/appfuel/service/config/aws.rb,
lib/appfuel/service/config/sentry.rb,
lib/appfuel/service/config/worker.rb,
lib/appfuel/service/config/database.rb,
lib/appfuel/service/config/newrelic.rb,
lib/appfuel/service/config/sneakers.rb
Class Method Summary collapse
-
.aws_definition ⇒ Object
Defines how to parse and validate configuration data for aws.
-
.db_definition ⇒ Object
Defines database configuration.
-
.definition(options = {}) ⇒ Object
Returns the worker definition while allowing you to override it and its child definition values through the options hash.
- .newrelic_definition ⇒ Object
- .sentry_definition ⇒ Object
-
.sneakers_definition ⇒ Object
Defines how to parse and validate configuration data for sneakers for more information of the configuration please go to the wiki for the sneakers project github.com/jondot/sneakers/wiki/Configuration.
- .update_definition(definition, options) ⇒ Object
-
.worker_definition ⇒ Object
Defines the configuration for the whole worker.
Class Method Details
.aws_definition ⇒ Object
Defines how to parse and validate configuration data for aws
Configuration Overview:
access_key_id: access credentials for aws
secret_access_key: access credentials for aws
assets_bucket: name of bucket to hold assets
documents_buckets name of bucket to hold documents
@returns Config::Definition
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/appfuel/service/config/aws.rb', line 14 def self.aws_definition Appfuel::Configuration.define :aws do defaults region: 'us-west-2' validator { required(:region).filled(:str?) optional(:access_key_id).filled(:str?) optional(:secret_access_key).filled(:str?) optional(:kms_master_key_id).filled(:str?) optional(:kms_data_key_cipher).filled(:str?) } end end |
.db_definition ⇒ Object
Defines database configuration. This is designed to hold more than one database connection which is why they are named invidually. We are using active record so the config is taylored to that style connection.
Configuration Overview
pool: Managed connection which controls the amount of thread access to
a limited number of database connections
adapter: We always use postgres, rarely changes encoding: We always use unicode, rarely changes database Name of the database username Name of the database user password Database password host Location of the database server
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/appfuel/service/config/database.rb', line 20 def self.db_definition Appfuel::Configuration.define :db do validator { required(:main).filled(:hash?) required(:path).filled(:str?) required(:seed_path).filled(:str?) required(:migrations_path).filled(:str?) } db_path = 'db' defaults path: db_path, migrations_path: "#{db_path}/migrations", seed_path: 'db/seed' define :main do defaults pool: 5, adapter: 'postgresql', encoding: 'unicode', schema_format: 'sql' validator do required(:schema_search_path).filled(:str?) required(:schema_format).filled(:str?) required(:database).filled(:str?) required(:username).filled(:str?) required(:password).filled(:str?) required(:host).filled(:str?) required(:adapter).filled(:str?) optional(:pool).filled(:int?) optional(:encoding).filled(:str?) optional(:port).filled(:int?) end end end end |
.definition(options = {}) ⇒ Object
Returns the worker definition while allowing you to override it and its child definition values through the options hash
20 21 22 23 |
# File 'lib/appfuel/service/config.rb', line 20 def definition( = {}) definition = .delete(:definition) || worker_definition update_definition(definition, ) end |
.newrelic_definition ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/appfuel/service/config/newrelic.rb', line 4 def self.newrelic_definition Appfuel::Configuration.define :newrelic do defaults log_level: 'info', monitor_mode: 'true', agent_enabled: 'true' validator { required(:license_key).filled(:str?) required(:app_name).filled(:str?) optional(:log_level).filled(:str?) optional(:monitor_mode).filled(:str?) optional(:agent_enabled).filled(:str?) } end end |
.sentry_definition ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/appfuel/service/config/sentry.rb', line 4 def self.sentry_definition Appfuel::Configuration.define :sentry do validator { required(:dsn).filled(:str?) } end end |
.sneakers_definition ⇒ Object
Defines how to parse and validate configuration data for sneakers for more information of the configuration please go to the wiki for the sneakers project github.com/jondot/sneakers/wiki/Configuration
Configuration Overview:
heartbeat: RabbitMQ heartbeat delay in seconds
ack: RabbitMQ the worker must acknowledge work is done
daemonize: Sneakers deameonize the worker
log Sneakers log file location
pid_path Sneakers daemon's pidfile location
workers Sneakers the number of worker processes
threads Sneakers number of threads per worker
prefetch RabbitMQ how many messages to send to a worker
timeout_job_after Sneakers Maximal seconds to wait for job
start_worker_delay Sneakers Delay between thread startup
durable RabbitMQ Queue should persist
exchange RabbitMQ name of the exchange
exchange_type RabbitMQ type of exchange (direct, topic, fanout)
vhost RabbitMQ name of the vhost
amqp RabbitMQ connection string used to communicate
@returns Config::Definition
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/appfuel/service/config/sneakers.rb', line 27 def self.sneakers_definition Appfuel::Configuration.define :sneakers do defaults heartbeat: 60, ack: true, pid_path: 'tmp/sneakers.pid', log: 'tmp/log/sneakers.log', daemonize: true, workers: 1, threads: 1, prefetch: 1, timeout_job_after: 5, durable: true env RABBITMQ_URL: :amqp validator { required(:amqp).filled(:str?) required(:vhost).filled(:str?) required(:exchange).filled(:str?) required(:exchange_type).filled(:str?) required(:durable).filled(:bool?) required(:ack).filled(:bool?) required(:daemonize).filled(:bool?) required(:heartbeat).filled(:int?) required(:log).filled(:str?) required(:pid_path).filled(:str?) required(:threads).filled(:int?) required(:workers).filled(:int?) required(:timeout_job_after).filled(:int?) required(:prefetch).filled(:int?) } end end |
.update_definition(definition, options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/appfuel/service/config.rb', line 25 def update_definition(definition, ) = validate_hash!() return definition if .empty? [:defaults, :file, :env, :exclude, :children].each do |type| name = "definition_#{type}" send(name, definition, [type]) if .key?(type) end definition end |
.worker_definition ⇒ Object
Defines the configuration for the whole worker. It basically has two child definitions :db and :sneakers
Configuration Overview
env: The environement this worker is deployed as dev, qa, stg, prod logfile: The location of the application log file if the value is
stdout or stderr it will use that instead
dispatchers List of workers that dispatch messages to actions. The reason
why you would want more than one is to use different exchange
types
db Database configuration please see sp_offers/config/database sneakers RabbitMQ configuration please see sp_offers/config/sneakers aws Configuration S3 where we store our documents
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/appfuel/service/config/worker.rb', line 20 def self.worker_definition Appfuel::Configuration.define :worker do file 'config/app.yaml' defaults logfile: 'stdout', audit_logfile: 'stdout' validator { required(:env).filled(:str?) required(:logfile).filled(:str?) required(:audit_logfile).filled(:str?) # Children will be validated on there own # we are just ensuring they exist required(:db).filled(:hash?) required(:sneakers).filled(:hash?) } self << [ Config.sneakers_definition, Config.db_definition, ] end end |