ec-pg 0.1.0 → 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/README.md +8 -24
- data/ec-pg-0.1.0.gem +0 -0
- data/ec-pg-0.1.1.gem +0 -0
- data/images/stand-with-palestine.webp +0 -0
- data/lib/ec/pg/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64cd8465d41750ff6dfefa8f4e9d7a5c05ecb90c65f657ac2d0670f700e5d516
|
|
4
|
+
data.tar.gz: abba235476bd2b3e624f0ba13a9c4bbe63fce55f7c410ae69b0537de0b6a0d08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a2a8e48e04b460014c0a1603fcad4117d319dbecc53680f4c5238c342c57b087332849db7814c7dfff483ef11a2b7ae6e91179b2deec1ecdd8e37bf093d6c87
|
|
7
|
+
data.tar.gz: d2c51f56fd6b3c69406ff3e363ec5f35c9344c8d96dedfd4eeb55303b70a907b3128a167ef5c0c510cc3bb199b523119547c4c54e779d9cdeea94209f60b6252
|
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<img src="images/stand-with-palestine.webp" alt="Alt Text" width="200" style="float:right">
|
|
2
|
+
|
|
1
3
|
# ec-pg
|
|
2
4
|
|
|
3
5
|
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 +13,7 @@ Multi-tenancy for Rails + PostgreSQL. Supports three isolation strategies — sc
|
|
|
11
13
|
## Installation
|
|
12
14
|
|
|
13
15
|
```ruby
|
|
14
|
-
gem 'ec-pg'
|
|
16
|
+
gem 'ec-pg'
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
## Strategies
|
|
@@ -35,18 +37,19 @@ Ec::Pg.configure do |c|
|
|
|
35
37
|
c.shared_schemas = ['public'] # always appended to search_path
|
|
36
38
|
c.number_of_shards = 4 # total shards in the cluster
|
|
37
39
|
c.rls_mode = :local # :local (per-transaction) or :session
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
|
|
41
|
+
##### BEGIN: Specific for ContextSwitcher middleware
|
|
40
42
|
# Return a hash with :shard and/or :schema keys.
|
|
41
43
|
c.get_context_method = ->(request) {
|
|
42
|
-
|
|
43
|
-
{ schema:
|
|
44
|
+
tenant = Tenant.find_by(host: reques.host)
|
|
45
|
+
{ schema: tenant.schema_identifier, shard: tenant.shard_identifier }
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
# Paths that bypass context switching (substring match)
|
|
47
49
|
c.context_switch_exclude_paths = ['health', 'status', 'metrics']
|
|
48
50
|
|
|
49
51
|
c.logger = Logger.new($stdout)
|
|
52
|
+
##### END
|
|
50
53
|
end
|
|
51
54
|
```
|
|
52
55
|
|
|
@@ -217,25 +220,6 @@ Context is stored in thread-local variables. Each thread/fiber has its own isola
|
|
|
217
220
|
|
|
218
221
|
---
|
|
219
222
|
|
|
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
223
|
|
|
240
224
|
## Development
|
|
241
225
|
|
data/ec-pg-0.1.0.gem
ADDED
|
Binary file
|
data/ec-pg-0.1.1.gem
ADDED
|
Binary file
|
|
Binary file
|
data/lib/ec/pg/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gmhawash
|
|
@@ -120,6 +120,9 @@ files:
|
|
|
120
120
|
- README.md
|
|
121
121
|
- Rakefile
|
|
122
122
|
- config/locales/en.yml
|
|
123
|
+
- ec-pg-0.1.0.gem
|
|
124
|
+
- ec-pg-0.1.1.gem
|
|
125
|
+
- images/stand-with-palestine.webp
|
|
123
126
|
- lib/ec/pg.rb
|
|
124
127
|
- lib/ec/pg/configuration.rb
|
|
125
128
|
- lib/ec/pg/context.rb
|