penthouse 0.4.2 → 0.5.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793411262ca8ce30ae1f03de55a78f76d4f4d9a2
|
4
|
+
data.tar.gz: 28306b0b4536d295809080968dfd0a2fd7621318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ce8d5d39cdc76572d89a91ea895986fbd90d9fb59021f6f5a9fd65a7dc76f49121752c69a49d63fceaa48f0da2132547573c8b3df0f472668adc7e0b7140ee
|
7
|
+
data.tar.gz: 5948007a8f5c28089a94e3f48d60f55110b5f67c4b2cc9bf2fb7b7372f5047930253610d0b1d3ec66e5594a2470ebaea70b3df375a273257a0237e27d6832513
|
@@ -14,14 +14,15 @@ module Penthouse
|
|
14
14
|
module Tenants
|
15
15
|
class OctopusSchemaTenant < SchemaTenant
|
16
16
|
|
17
|
-
# ensures we're on the
|
18
|
-
# with the tenant name
|
17
|
+
# ensures we're on the correct Octopus shard, then just updates the schema
|
18
|
+
# name with the tenant name
|
19
|
+
# @param shard [String, Symbol] The shard to execute within, usually master
|
19
20
|
# @param block [Block] The code to execute within the schema
|
20
21
|
# @yield [SchemaTenant] The current tenant instance
|
21
22
|
# @return [void]
|
22
|
-
def call(&block)
|
23
|
-
Octopus.using(
|
24
|
-
super
|
23
|
+
def call(shard: :master, &block)
|
24
|
+
Octopus.using(shard) do
|
25
|
+
super(&block)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -1,29 +1,26 @@
|
|
1
1
|
#
|
2
|
-
# The
|
3
|
-
# shard per tenant, allowing for each tenant to have their own
|
4
|
-
# isolated from other tenants in terms of data and performance.
|
2
|
+
# The OctopusShardTenant class relies upon Octopus [1], it switches to a
|
3
|
+
# different shard per tenant, allowing for each tenant to have their own
|
4
|
+
# database, 100% isolated from other tenants in terms of data and performance.
|
5
5
|
#
|
6
6
|
# [1]: (https://github.com/thiagopradi/octopus)
|
7
7
|
#
|
8
8
|
|
9
|
-
require_relative './
|
10
|
-
require 'octopus'
|
11
|
-
require_relative './migratable'
|
9
|
+
require_relative './octopus_schema_tenant'
|
12
10
|
|
13
11
|
module Penthouse
|
14
12
|
module Tenants
|
15
|
-
class OctopusShardTenant <
|
16
|
-
include Migratable
|
13
|
+
class OctopusShardTenant < OctopusSchemaTenant
|
17
14
|
|
18
15
|
attr_accessor :shard
|
19
16
|
private :shard=
|
20
17
|
|
21
18
|
# @param identifier [String, Symbol] An identifier for the tenant
|
22
19
|
# @param shard [String, Symbol] the configured Octopus shard to use for this tenant
|
23
|
-
|
24
|
-
|
20
|
+
# @param tenant_schema [String] your tenant's schema name within the Postgres shard, typically just 'public' as the shard should be dedicated
|
21
|
+
def initialize(identifer, shard:, tenant_schema: "public", **options)
|
25
22
|
self.shard = shard
|
26
|
-
|
23
|
+
super(identifier, tenant_schema: tenant_schema, **options)
|
27
24
|
end
|
28
25
|
|
29
26
|
# switches to the relevant Octopus shard, and processes the block
|
@@ -31,9 +28,7 @@ module Penthouse
|
|
31
28
|
# @yield [ShardTenant] The current tenant instance
|
32
29
|
# @return [void]
|
33
30
|
def call(&block)
|
34
|
-
|
35
|
-
block.yield(self)
|
36
|
-
end
|
31
|
+
super(shard: shard, &block)
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
data/lib/penthouse/version.rb
CHANGED