Class: Octoball

Inherits:
Object
  • Object
show all
Includes:
AssociationShardChecker, CurrentShardTracker::ClassMethods, RelationProxyIsARelation, ShardedCollectionProxyCreate, UsingShard
Defined in:
lib/octoball/log_subscriber.rb,
lib/octoball/version.rb,
lib/octoball/association.rb,
lib/octoball/persistence.rb,
lib/octoball/using_shard.rb,
lib/octoball/relation_proxy.rb,
lib/octoball/connection_adapters.rb,
lib/octoball/connection_handling.rb,
lib/octoball/current_shard_tracker.rb,
lib/octoball/association_shard_check.rb

Overview

Implementation courtesy of db-charmer.

Defined Under Namespace

Modules: AssociationShardCheck, AssociationShardChecker, ConnectionHandlerSetCurrentShard, ConnectionHandlingAvoidAutoLoadProxy, ConnectionHasCurrentShard, CurrentShardTracker, LogSubscriber, RelationCurrentShard, RelationProxyIsARelation, ShardedCollectionAssociation, ShardedCollectionProxy, ShardedCollectionProxyCreate, ShardedPersistence, ShardedSingularAssociation, UsingShard Classes: MismatchedShards, RelationProxy

Constant Summary collapse

VERSION =
'0.1.6.1'

Class Method Summary collapse

Methods included from UsingShard

#using

Methods included from AssociationShardChecker

#has_and_belongs_to_many, #has_many

Methods included from RelationProxyIsARelation

#===

Methods included from ShardedCollectionProxyCreate

#create

Class Method Details

.current_roleObject



6
7
8
# File 'lib/octoball/using_shard.rb', line 6

def self.current_role
  ActiveRecord::Base.current_role || ActiveRecord::Base.writing_role
end

.using(shard, &block) ⇒ Object



2
3
4
# File 'lib/octoball/using_shard.rb', line 2

def self.using(shard, &block)
  ActiveRecord::Base.connected_to(role: current_role, shard: shard&.to_sym, &block)
end