semian-postgres 0.1.2 → 0.1.3

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: e0fabd3e61200a72004737d848c2c7ae4fcaf30bd9c4ea14d8f32ba3d83081c6
4
- data.tar.gz: 8ae29280943dbb4a11400125b6062ecb87a3cac1973616f45df9832ceb108fc6
3
+ metadata.gz: 73cf137c03d806d9aff6b4970a36696fc4c4e5a59adef59b4dc3bf59047e7be5
4
+ data.tar.gz: f894ad4f3eef28d25809fd216c7092378970553ff29d3f555603abb7113e1576
5
5
  SHA512:
6
- metadata.gz: b682ea171fb1937e87b8ee5fee7f081c38e5432818c009e640bf2937dc933b9d647959a44792bbaf2ee722d217a07c7b7f1193bbf5986dfe17f474d54cac1e29
7
- data.tar.gz: 2c921e8d3b2161db048f7182a2091c63a7f9e29aa641a17796040793786a06322d64e4836a07225cf7c8c39c8c87149cab32a77f071f42a5d32de84a230b2ed0
6
+ metadata.gz: 4f1e0d14332077e7da7572b26592b7d3eeb181c79c2f7f1beadb10b339190d7892d862eb736b3d1fbcc3d18e86dc8647c29d18894f91269ddf7dc2845e528da1
7
+ data.tar.gz: 170989c401d813e9f084f99c4a9b89e55988b1f6dcf5ce84ec0ac6f7e95d55066c5fdefdfb7df321f428a30464eddcac7f4013df283bbb5023746cfe86fe1977
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Manuel Schönlaub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # semian-postgres
2
+
3
+ ![CI Workflow](https://github.com/mschoenlaub/semian-postgres/actions/workflows/ci.yml/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/semian-postgres.svg)](https://badge.fury.io/rb/semian-postgres)
5
+
6
+ This library provides a Postgres adapter for [Semian](https://github.com/Shopify/semian) by wrapping the [pg gem](https://rubygems.org/gems/pg)
7
+ Semian is a resiliency toolkit for Ruby applications that provides a way to protect your application from external failures by limiting the number of resources that can be used at a time.
8
+ You can read more about Semian [here](https://github.com/Shopify/semian)).
9
+
10
+ ## Usage
11
+
12
+ Add the gem to your `Gemfile` and require it in your application.
13
+
14
+ ```ruby
15
+ gem 'semian-pg', require: %w(semian semian/pg)
16
+ ```
17
+
18
+
19
+ ## Configuration
20
+
21
+ The adapter is configured by a callback function, which would be ideally defined in some sort of initialization file.
22
+ For Rails applications these would usually live in the `config/initializers/` directory.
23
+
24
+
25
+ ### Minimal example
26
+ The following example configures an adapter to open the circuit after three unsuccessful
27
+ connection attempts and close it after each successful attempt.
28
+
29
+ Bulkheading is disabled, because this is not supported with servers that have a thread-oriented model, such as [Puma](https://github.com/puma/puma)
30
+
31
+ ```ruby
32
+ require "semian"
33
+ require "semian/postgres"
34
+
35
+ SEMIAN_PARAMETERS = {
36
+ circuit_breaker: true,
37
+ success_threshold: 1,
38
+ error_threshold: 3,
39
+ error_timeout: 3,
40
+ bulkhead: false,
41
+ }
42
+
43
+ Semian::PG.semian_configuration = proc do |host, port|
44
+ if host == "localhost" && port == 5432
45
+ return SEMIAN_PARAMETERS
46
+ end
47
+ end
48
+
49
+ conn = PG.connect(host: "example.com", port: 5432)
50
+ conn.exec("SELECT 1")
51
+ ```
52
+
53
+
54
+ ## Development
55
+ Semian, and by extension semian-postgres, currently depends on Linux for **Bulkheading**.
56
+
57
+ The development environment is based on `docker-compose`, spinning up containers for Postgres and Toxiproxy.
58
+ Additionally a `dev` container is spun up. The `Gemfile` contains `ruby-debug-ide` to support remote debugging from the IDE.
59
+
60
+ A typical development workflow would be to run the tests in the `dev` container
61
+ ```bash
62
+ docker compose up -d
63
+ docker compose exec dev bin/setup
64
+ docker compose exec dev rake rubocop spec
65
+ ```
66
+
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/mschoenlaub/semian-postgres).
71
+
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Semian
4
4
  module PG
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Schönlaub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: semian
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.16.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 0.18.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 0.16.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.18.0
41
47
  description:
42
48
  email:
43
49
  - manuel.schonlaub@prodigygame.com
@@ -45,6 +51,8 @@ executables: []
45
51
  extensions: []
46
52
  extra_rdoc_files: []
47
53
  files:
54
+ - LICENSE.txt
55
+ - README.md
48
56
  - lib/semian/pg.rb
49
57
  - lib/semian/pg/version.rb
50
58
  homepage: https://github.com/mschoenlaub/semian-postgres
@@ -54,6 +62,7 @@ metadata:
54
62
  homepage_uri: https://github.com/mschoenlaub/semian-postgres
55
63
  source_code_uri: https://github.com/mschoenlaub/semian-postgres
56
64
  changelog_uri: https://github.com/mschoenlaub/semian-postgres/main/CHANGELOG.md
65
+ github_repo: ssh://github.com/mschoenlaub/semian-postgres
57
66
  rubygems_mfa_required: 'true'
58
67
  post_install_message:
59
68
  rdoc_options: []