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.
- checksums.yaml +4 -4
- data/lib/pgdog.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb3501bafd5043df9608c736c8d9506576e0a15bf2dba629cf261e60453205d
|
4
|
+
data.tar.gz: 6cfd1241c4f9c1d7052e30844103f2a9d2e212cf25b1c2837cb652ecc2eb4c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)"
|