ec-pg 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 6e69e45c69cb62b8cc005170eadd586bb1d9e5531255aed6c9102130f483ccb2
4
- data.tar.gz: 784dd9d174de14fd939609f611cc568f987841d325825889d5fdec9161fef105
3
+ metadata.gz: 2b9ec86d4b4b9d392a3e5e44e351d65db5ad63c235f020a0d88caea00bae9ef2
4
+ data.tar.gz: 27ebb8b0305434b3d2ac0c95a8c7c4a90a154a34bd23e26e32bb1aa2aa1be1de
5
5
  SHA512:
6
- metadata.gz: 5b0db8b630775523543fa285d1e19d12812914adac35dda60e801b48375d80c31a413c0e4eb7d245ef3bfe2016421cb49aa43f238daa0de7787ac87c55391fb6
7
- data.tar.gz: 1809e37d26dde7ec53fda58133856e62295e6702478d7ea82462965483ec634317c8ff0570aa64d93f6d820674f895197b1a49ede5891e6491df58d015fb6a84
6
+ metadata.gz: 1826c3c01d3b71359ca37f3ce7d87bb3d185393d27a16db764b01500c9f97a7596339d6efae18722784859cdf30d7c5e67e07281bdfad007bde5ca5576e19efc
7
+ data.tar.gz: 131d22a8df88213fab0833e59d3a74b74096753adadd0d4d780f04ee56305144d18c9f7c640588a4993b7b6aff6a6ad6a0f5a38066acd7003d72732d31caab59
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ <img src="images/stand-with-palestine.webp" alt="Alt Text" width="200" style="float:right">
1
2
  # ec-pg
2
3
 
3
4
  Multi-tenancy for Rails + PostgreSQL. Supports three isolation strategies — schema-per-tenant, database sharding, and row-level security (RLS) — with thread-safe context management and optional Rack middleware for automatic per-request switching.
@@ -11,7 +12,7 @@ Multi-tenancy for Rails + PostgreSQL. Supports three isolation strategies — sc
11
12
  ## Installation
12
13
 
13
14
  ```ruby
14
- gem 'ec-pg', github: 'binnablus/ec-pg'
15
+ gem 'ec-pg'
15
16
  ```
16
17
 
17
18
  ## Strategies
@@ -35,18 +36,19 @@ Ec::Pg.configure do |c|
35
36
  c.shared_schemas = ['public'] # always appended to search_path
36
37
  c.number_of_shards = 4 # total shards in the cluster
37
38
  c.rls_mode = :local # :local (per-transaction) or :session
38
-
39
- # Required when using the ContextSwitcher middleware.
39
+
40
+ ##### BEGIN: Specific for ContextSwitcher middleware
40
41
  # Return a hash with :shard and/or :schema keys.
41
42
  c.get_context_method = ->(request) {
42
- subdomain = request.host.split('.').first
43
- { schema: subdomain }
43
+ tenant = Tenant.find_by(host: reques.host)
44
+ { schema: tenant.schema_identifier, shard: tenant.shard_identifier }
44
45
  }
45
46
 
46
47
  # Paths that bypass context switching (substring match)
47
48
  c.context_switch_exclude_paths = ['health', 'status', 'metrics']
48
49
 
49
50
  c.logger = Logger.new($stdout)
51
+ ##### END
50
52
  end
51
53
  ```
52
54
 
@@ -217,25 +219,6 @@ Context is stored in thread-local variables. Each thread/fiber has its own isola
217
219
 
218
220
  ---
219
221
 
220
- ## Low-level context API
221
-
222
- ```ruby
223
- # Read
224
- Ec::Pg::Context.shard # => :shard_one or nil
225
- Ec::Pg::Context.schema # => 'acme' or nil
226
- Ec::Pg::Context.current # => { shard: :shard_one, schema: 'acme' }
227
- Ec::Pg::Context.active? # => true if any key is set
228
-
229
- # Write
230
- Ec::Pg::Context.set(shard: :shard_one, schema: 'acme')
231
- Ec::Pg::Context.delete(:shard)
232
- Ec::Pg::Context.clear!
233
-
234
- # Temporary override (block-scoped)
235
- Ec::Pg::Context.with(schema: 'other') { ... }
236
- ```
237
-
238
- ---
239
222
 
240
223
  ## Development
241
224
 
data/ec-pg-0.1.0.gem ADDED
Binary file
Binary file
data/lib/ec/pg/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ec
4
4
  module Pg
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec-pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gmhawash
@@ -120,6 +120,8 @@ files:
120
120
  - README.md
121
121
  - Rakefile
122
122
  - config/locales/en.yml
123
+ - ec-pg-0.1.0.gem
124
+ - images/stand-with-palestine.webp
123
125
  - lib/ec/pg.rb
124
126
  - lib/ec/pg/configuration.rb
125
127
  - lib/ec/pg/context.rb