pgdog 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pgdog.rb +11 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7c6d2bc154cf558bc61be658c14fd0cb30ab53d44bd0beed5ccd0b0b69c0f72
4
- data.tar.gz: b861aec2cf7e56316da42e588ba434365ebe159779651d913d3b7a9038325ed6
3
+ metadata.gz: beb3501bafd5043df9608c736c8d9506576e0a15bf2dba629cf261e60453205d
4
+ data.tar.gz: 6cfd1241c4f9c1d7052e30844103f2a9d2e212cf25b1c2837cb652ecc2eb4c5e
5
5
  SHA512:
6
- metadata.gz: 85397cbe9c812c068af754822ae838e8826ebee3a0326952a2e6c8cef872b4a4ae789bfd48e4c897c6ae332198a9abab9ec54e8fd3810558f1acb18cd6bbad2b
7
- data.tar.gz: 0522ec89011c0c3259c85370a7db82231c92ff2a4f108f19e8a21146f9cc494588c319f72770cbaf873c1140702ea6df889997f4bdce093780e3f1dda78743ea
6
+ metadata.gz: ff36dd430548ddef6bc3ca62034546751ca423b3c52eb4117a3a1198f7b87e8490cbb0bae78a232726d2408b9bf0e2fbcc0945bacfbae244393b11bdc162c2a6
7
+ data.tar.gz: 91985d77df68e8ff6afd286f00a0eccf7ada653f456f8eaecfbf34f7abbd8079e4fbd13ae0c2b3b61bb8c6edea407a8f6aad20ce68f6fe4631d6b487e98ab175
data/lib/pgdog.rb CHANGED
@@ -30,6 +30,17 @@ class PgDog
30
30
  end
31
31
  end
32
32
 
33
+ # Get the number of configured shards
34
+ #
35
+ # Can only work outside of a transaction, because
36
+ # a started transaction is most likely already routed to a shard
37
+ # and the PgDog query parser won't be used.
38
+ def self.shards
39
+ PgDog.check_transaction
40
+ shards = ActiveRecord::Base.connection.execute "SHOW \"pgdog.shards\""
41
+ return shards[0]["shards"].to_i
42
+ end
43
+
33
44
  # Get currently set shard, if any.
34
45
  def self.shard
35
46
  shard = self.connection.execute "SELECT current_setting('pgdog.shard', true)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lev Kokotov