Class: GOM::Storage::ElasticSearch::CouchDB::River
- Inherits:
-
Object
- Object
- GOM::Storage::ElasticSearch::CouchDB::River
- Defined in:
- lib/gom/storage/elastic_search/couchdb/river.rb
Instance Method Summary collapse
- #create ⇒ Object
- #create_if_missing ⇒ Object
- #delete ⇒ Object
- #delete_if_exists ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(options) ⇒ River
constructor
A new instance of River.
Constructor Details
#initialize(options) ⇒ River
Returns a new instance of River.
5 6 7 8 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 5 def initialize() @couch_db = [:couch_db] @elastic_search = [:elastic_search] end |
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 10 def create Transport::JSON.request :put, "#{elastic_search_base_url}/_river/#{@elastic_search[:index_name]}/_meta", :body => { :type => "couchdb", :couchdb => { :host => @couch_db[:host], :port => @couch_db[:port], :db => @couch_db[:database], :user => @couch_db[:username], :password => @couch_db[:password] }, :index => { :index => @elastic_search[:index_name], :type => @elastic_search[:index_name], :bulk_size => "100", :bulk_timeout => "10ms" } }, :expected_status_code => [ 200, 201 ] end |
#create_if_missing ⇒ Object
31 32 33 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 31 def create_if_missing create unless exists? end |
#delete ⇒ Object
35 36 37 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 35 def delete Transport::JSON.request :delete, "#{elastic_search_base_url}/_river/#{@elastic_search[:index_name]}", :expected_status_code => 200 end |
#delete_if_exists ⇒ Object
39 40 41 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 39 def delete_if_exists delete if exists? end |
#exists? ⇒ Boolean
43 44 45 46 47 48 |
# File 'lib/gom/storage/elastic_search/couchdb/river.rb', line 43 def exists? Transport::JSON.request :get, "#{elastic_search_base_url}/_river/#{@elastic_search[:index_name]}/_meta", :expected_status_code => 200 true rescue Transport::UnexpectedStatusCodeError false end |