Class: ElasticGraph::Admin::DatastoreClientDryRunDecorator
- Inherits:
-
Object
- Object
- ElasticGraph::Admin::DatastoreClientDryRunDecorator
- Extended by:
- Forwardable
- Defined in:
- lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb
Overview
Decorator that wraps a datastore client in order to implement dry run behavior. All write operations are implemented as no-ops, while read operations are passed through to the wrapped datastore client.
We prefer this over having to check a ‘dry_run` flag in many places because that’s easy to forget. One mistake and a dry run isn’t truly a dry run!
In contrast, this gives us a strong guarantee that dry run mode truly avoids mutating any datastore state. This decorator specifically picks and chooses which operations it allows.
-
Read operations are forwarded to the wrapped datastore client.
-
Write operations are implemented as no-ops.
If/when the calling code evolves to call a new method on this, it’ll trigger ‘NoMethodError`, giving us a good chance to evaluate how this decorator should support a particular API. This is also why this doesn’t use Ruby’s ‘delegate` library, because we don’t want methods automatically delegated; we want to opt-in to only the read-only methods.
Instance Method Summary collapse
- #bulk ⇒ Object
- #create_index ⇒ Object
- #delete_all_documents ⇒ Object
- #delete_index_template ⇒ Object
- #delete_indices ⇒ Object
- #delete_script ⇒ Object
-
#initialize(wrapped_client) ⇒ DatastoreClientDryRunDecorator
constructor
A new instance of DatastoreClientDryRunDecorator.
- #put_index_mapping ⇒ Object
- #put_index_settings ⇒ Object
- #put_index_template ⇒ Object
- #put_persistent_cluster_settings ⇒ Object
- #put_script ⇒ Object
Constructor Details
#initialize(wrapped_client) ⇒ DatastoreClientDryRunDecorator
Returns a new instance of DatastoreClientDryRunDecorator.
34 35 36 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 34 def initialize(wrapped_client) @wrapped_client = wrapped_client end |
Instance Method Details
#bulk ⇒ Object
73 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 73 def bulk(*) = nil |
#create_index ⇒ Object
62 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 62 def create_index(*) = nil |
#delete_all_documents ⇒ Object
71 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 71 def delete_all_documents(*) = nil |
#delete_index_template ⇒ Object
53 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 53 def delete_index_template(*) = nil |
#delete_indices ⇒ Object
60 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 60 def delete_indices(*) = nil |
#delete_script ⇒ Object
48 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 48 def delete_script(*) = nil |
#put_index_mapping ⇒ Object
64 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 64 def put_index_mapping(*) = nil |
#put_index_settings ⇒ Object
66 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 66 def put_index_settings(*) = nil |
#put_index_template ⇒ Object
55 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 55 def put_index_template(*) = nil |
#put_persistent_cluster_settings ⇒ Object
41 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 41 def put_persistent_cluster_settings(*) = nil |
#put_script ⇒ Object
46 |
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 46 def put_script(*) = nil |