Skip to content

Commit

Permalink
Generate updated mongoid.yml config file
Browse files Browse the repository at this point in the history
I generated the file with `rails g mongoid:config` and then copied the
custom options from our previous config.

Notable differences:

* The `safe: true` option has been removed. The new `w: 1` option
  provides the same behaviour by default. From the Changelog for v4[1]:

    > Mongoid now defaults all writes to propagate (formerly "safe
    > mode") and now has different propagate semantics:
    >
    > { w: -1 }: Don't verify writes and raise no network errors.
    > { w: 0 }: Don't verify writes and raise network errors.
    > { w: 1 }: Verify writes on the primary node. (default)
    > { w: n }: Verify writes on n number of nodes.
    > { w: "majority" }: Verify writes on a majority of nodes.

* The `consistency: strong` option has been replaced by `read: primary`
  in the test and production sessions. You can see from the comments in
  this diff that these are equivalent.

* The `use_activesupport_time_zone`, `refresh_interval` and
  `refresh_mode` options have been moved to the "Configure Mongoid
  specific options" key.

[1]: https://github.com/mongodb/mongoid/blob/master/CHANGELOG.md
  • Loading branch information
chrisroos committed May 16, 2017
1 parent 13d53ab commit c3183b3
Showing 1 changed file with 52 additions and 30 deletions.
82 changes: 52 additions & 30 deletions config/mongoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,63 @@ development:
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
# hosts:
# - localhost:27017
# - localhost:27017
uri: 'mongodb://localhost/govuk_content_development'
options:
# Change whether the session persists in safe mode by default.
# (default: false)
safe: true
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1

# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual
# Change the default consistency model to primary, secondary.
# 'secondary' will send reads to secondaries, 'primary' sends everything
# to master. (default: primary)
# read: secondary_preferred

# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# failure. (default: The number of nodes in the cluster)
# max_retries: 20

# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Configuration for whether or not to allow access to fields that do
# not have a field definition on the model. (default: true)
# allow_dynamic_fields: true
# operation on failure. (default: 0.25)
# retry_interval: 0.25

# The connection pool size per-node. This should match or exceed the
# number of threads for a multi-threaded application. (default: 5)
# pool_size: 5

# The time in seconds that Moped should wait for the pool to provide
# an available connection. This number should probably remain at the
# default, unless for some reason you absolutely need to limit the
# pool_size, as this wait is only used when the pool is saturated.
# (default: 0.5)
# pool_timeout: 0.5

# The time in seconds before Moped will timeout connection and node
# operations. (default: 5)
# timeout: 5

# The amount of time in seconds between forced refreshes of node
# information including the discovery of new peers. (default: 300)
# refresh_interval: 300

# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# The amount of time in seconds that a node will be flagged as down.
# (default: 30)
# down_interval: 30

# Whether connections should use SSL. (default: nil/false)
# ssl: false

# Whether Moped will use the existing seeds/nodes to find other peers.
# (default: true)
# auto_discover: true


# Configure Mongoid specific options. (optional)
options:
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false

# Include the _type field in serializaion. (default: false)
# Include the _type field in serialization. (default: false)
# include_type_for_serialization: false

# Preload all models in development, needed when models use
Expand All @@ -58,11 +83,7 @@ development:
# existing method. (default: false)
# scope_overwrite_exception: false

# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false

# User Active Support's time zone in conversions. (default: true)
# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true

# Ensure all times are UTC in the app side. (default: false)
Expand All @@ -76,7 +97,7 @@ test:
# - localhost:27017
uri: 'mongodb://localhost/govuk_content_manuals_publisher_test'
options:
consistency: :strong
read: primary
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
Expand All @@ -88,7 +109,8 @@ production:
uri: <%= ENV['MONGODB_URI'] %>
options:
logger: false
use_activesupport_time_zone: true
refresh_interval: 120
refresh_mode: :sync
consistency: :strong
read: :primary
options:
use_activesupport_time_zone: true
refresh_interval: 120
refresh_mode: :sync

0 comments on commit c3183b3

Please sign in to comment.