NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
387 stars 49 forks source link

Is it possible to support nonvoting_replica_tags? #254

Closed extem closed 4 years ago

extem commented 4 years ago

Is it possible to support "nonvoting_replica_tags" as an option for table_config?

no_brainer/config.rb #line 14-15 
    :table_options          => { :default => ->{ {:shards => 1, :replicas => 1, :write_acks => :majority} },
                                 :valid_keys => [:shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags, :write_acks, :durability] },

no_brainer/document/table_config.rb #line 9
VALID_TABLE_CONFIG_OPTIONS = [:name, :durability, :shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags, :write_acks]

no_brainer/document/table_config.rb #line 81
      NoBrainer.run { rql_table.reconfigure(c.slice(:shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags)) }

NoBrainer is a very nice library. It works perfectly with Rails6. Thank you very much.

nviennot commented 4 years ago

Hello Hiroyuki, I've pushed a commit to add this missing feature. Can you let me know if it works? I can't seem to easily write a test case for it.

extem commented 4 years ago

Thank you for your support!

I downloaded and tested it. gem 'nobrainer', :path=>".......Downloads/nobrainer-master" bundle install

Sample that adds nonvoting_replica to all tables.

ex)
options = { shards: 1, replicas: { main_db_server: 1, sub1_db_server: 1}, primary_replica_tag: 'main_db_server', nonvoting_replica_tags:[sub1_db_server] }
NoBrainer::System::TableStatus.to_a.each do |table|
    NoBrainer.run do |r|
        r.db(table.db).table(table.name).reconfigure(options)
    end
end

It worked perfectly!

Nonvoting_replica is useful during development because it works even when it becomes a single primary replica.

nviennot commented 4 years ago

Super, I'll make a release