Class: Sequel::SchemaSharding::Finder

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sequel/schema-sharding/finder.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#lookup(table_name, id) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/sequel/schema-sharding/finder.rb', line 18

def lookup(table_name, id)
  shard_number = shard_for_id(table_name, id)
  physical_shard = config.logical_shard_configs(table_name)[shard_number]

  conn = Sequel::SchemaSharding.connection_manager[physical_shard]
  schema = Sequel::SchemaSharding.connection_manager.schema_for(table_name, shard_number)

  Result.new(conn, schema, shard_number)
end