Class: ElasticGraph::Admin::DatastoreClientDryRunDecorator

Inherits:
Object
  • Object
show all
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

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

#bulkObject



73
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 73

def bulk(*) = nil

#create_indexObject



62
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 62

def create_index(*) = nil

#delete_all_documentsObject



71
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 71

def delete_all_documents(*) = nil

#delete_index_templateObject



53
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 53

def delete_index_template(*) = nil

#delete_indicesObject



60
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 60

def delete_indices(*) = nil

#delete_scriptObject



48
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 48

def delete_script(*) = nil

#put_index_mappingObject



64
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 64

def put_index_mapping(*) = nil

#put_index_settingsObject



66
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 66

def put_index_settings(*) = nil

#put_index_templateObject



55
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 55

def put_index_template(*) = nil

#put_persistent_cluster_settingsObject



41
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 41

def put_persistent_cluster_settings(*) = nil

#put_scriptObject



46
# File 'lib/elastic_graph/admin/datastore_client_dry_run_decorator.rb', line 46

def put_script(*) = nil