Class: Seiun::Client
- Inherits:
-
Object
- Object
- Seiun::Client
- Defined in:
- lib/seiun/client.rb
Instance Method Summary collapse
- #delete(table_name, records, callback_class: nil, async: true) ⇒ Object
- #delete_queue(table_name, callback_class: nil, async: true) ⇒ Object
- #find_job(id, callback_class: nil) ⇒ Object
-
#initialize(databasedotcom: nil, batch_size: 10_000) ⇒ Client
constructor
A new instance of Client.
- #insert(table_name, records, callback_class: nil, async: true) ⇒ Object
- #insert_queue(table_name, callback_class: nil, async: true) ⇒ Object
- #query(table_name, soql, callback_class: nil) ⇒ Object
- #update(table_name, records, callback_class: nil, async: true) ⇒ Object
- #update_queue(table_name, callback_class: nil, async: true) ⇒ Object
- #upsert(table_name, records, ext_field_name, callback_class: nil, async: true) ⇒ Object
- #upsert_queue(table_name, ext_field_name, callback_class: nil, async: true) ⇒ Object
Constructor Details
#initialize(databasedotcom: nil, batch_size: 10_000) ⇒ Client
Returns a new instance of Client.
3 4 5 6 |
# File 'lib/seiun/client.rb', line 3 def initialize(databasedotcom: nil, batch_size: 10_000) @batch_size = batch_size @connection = Seiun::Connection.new(databasedotcom) end |
Instance Method Details
#delete(table_name, records, callback_class: nil, async: true) ⇒ Object
42 43 44 |
# File 'lib/seiun/client.rb', line 42 def delete(table_name, records, callback_class: nil, async: true) operate(:delete, table_name, records: records, callback: callback_class, async: async) end |
#delete_queue(table_name, callback_class: nil, async: true) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/seiun/client.rb', line 46 def delete_queue(table_name, callback_class: nil, async: true) @delete_queue ||= {} @delete_queue[table_name] ||= Seiun::Queue.new(batch_size: @batch_size) do |records| delete(table_name, records, callback_class: callback_class, async: async) end end |
#find_job(id, callback_class: nil) ⇒ Object
57 58 59 60 |
# File 'lib/seiun/client.rb', line 57 def find_job(id, callback_class: nil) callback_class = wrap_callback(callback_class) Seiun::Job.new(@connection, id: id, callback: callback_class) end |
#insert(table_name, records, callback_class: nil, async: true) ⇒ Object
8 9 10 |
# File 'lib/seiun/client.rb', line 8 def insert(table_name, records, callback_class: nil, async: true) operate(:insert, table_name, records: records, callback: callback_class, async: async) end |
#insert_queue(table_name, callback_class: nil, async: true) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/seiun/client.rb', line 12 def insert_queue(table_name, callback_class: nil, async: true) @insert_queue ||= {} @insert_queue[table_name] ||= Seiun::Queue.new(batch_size: @batch_size) do |records| insert(table_name, records, callback_class: callback_class, async: async) end end |
#query(table_name, soql, callback_class: nil) ⇒ Object
53 54 55 |
# File 'lib/seiun/client.rb', line 53 def query(table_name, soql, callback_class: nil) operate(:query, table_name, soql: soql, callback: callback_class) end |
#update(table_name, records, callback_class: nil, async: true) ⇒ Object
19 20 21 |
# File 'lib/seiun/client.rb', line 19 def update(table_name, records, callback_class: nil, async: true) operate(:update, table_name, records: records, callback: callback_class, async: async) end |
#update_queue(table_name, callback_class: nil, async: true) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/seiun/client.rb', line 23 def update_queue(table_name, callback_class: nil, async: true) @update_queue ||= {} @update_queue[table_name] ||= Seiun::Queue.new(batch_size: @batch_size) do |records| update(table_name, records, callback_class: callback_class, async: async) end end |
#upsert(table_name, records, ext_field_name, callback_class: nil, async: true) ⇒ Object
30 31 32 33 |
# File 'lib/seiun/client.rb', line 30 def upsert(table_name, records, ext_field_name, callback_class: nil, async: true) operate(:upsert, table_name, records: records, ext_field_name: ext_field_name, callback: callback_class, async: async) end |
#upsert_queue(table_name, ext_field_name, callback_class: nil, async: true) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/seiun/client.rb', line 35 def upsert_queue(table_name, ext_field_name, callback_class: nil, async: true) @upsert_queue ||= {} @upsert_queue[table_name] ||= Seiun::Queue.new(batch_size: @batch_size) do |records| upsert(table_name, records, ext_field_name, callback_class: callback_class, async: async) end end |