Sha256: cab9fa78ed121b4764f6bfc99162b3d3c00645daa7c1c1d67fac0cdac80c1b08
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
# # The OctopusShardTenant class relies upon Octopus [1], it switches to a # different shard per tenant, allowing for each tenant to have their own # database, 100% isolated from other tenants in terms of data and performance. # # [1]: (https://github.com/thiagopradi/octopus) # require_relative './octopus_schema_tenant' module Penthouse module Tenants class OctopusShardTenant < OctopusSchemaTenant attr_accessor :shard private :shard= # @param identifier [String, Symbol] An identifier for the tenant # @param shard [String, Symbol] the configured Octopus shard to use for this tenant # @param tenant_schema [String] your tenant's schema name within the Postgres shard, typically just 'public' as the shard should be dedicated def initialize(identifier, shard:, tenant_schema: "public", **options) self.shard = shard super(identifier, tenant_schema: tenant_schema, **options) end # switches to the relevant Octopus shard, and processes the block # @param block [Block] The code to execute within the connection to the shard # @yield [ShardTenant] The current tenant instance # @return [void] def call(&block) super(shard: shard, &block) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems