semian-postgres 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0fabd3e61200a72004737d848c2c7ae4fcaf30bd9c4ea14d8f32ba3d83081c6
4
- data.tar.gz: 8ae29280943dbb4a11400125b6062ecb87a3cac1973616f45df9832ceb108fc6
3
+ metadata.gz: 8b3f590389eb04c069b23932de9ed4d57b7343f5f71e306746111814eb2d94dc
4
+ data.tar.gz: '09016c97548d22b802c8e12061a08c48a552d69263b0ca564228adcb32aee514'
5
5
  SHA512:
6
- metadata.gz: b682ea171fb1937e87b8ee5fee7f081c38e5432818c009e640bf2937dc933b9d647959a44792bbaf2ee722d217a07c7b7f1193bbf5986dfe17f474d54cac1e29
7
- data.tar.gz: 2c921e8d3b2161db048f7182a2091c63a7f9e29aa641a17796040793786a06322d64e4836a07225cf7c8c39c8c87149cab32a77f071f42a5d32de84a230b2ed0
6
+ metadata.gz: 9207ee1fbe5c3083e7c102b5da1188e8205987cc158078f5f59e2d05e56ea71894ca138a933948edeaa14ce992aa6aca0d37504d1537045adbfbdeee7ca110e4
7
+ data.tar.gz: 2e3997214743e12cd5aab9c0fd39a0abbd5b2def53a63a0e100354f6cb03f3abf69a380654ba06bd6bc4736b6bda662ae89139ca2d885eefd6df51815828ef0e
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.4'
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.4
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: 2024-01-24 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.20.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.20.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
@@ -53,7 +61,8 @@ licenses:
53
61
  metadata:
54
62
  homepage_uri: https://github.com/mschoenlaub/semian-postgres
55
63
  source_code_uri: https://github.com/mschoenlaub/semian-postgres
56
- changelog_uri: https://github.com/mschoenlaub/semian-postgres/main/CHANGELOG.md
64
+ changelog_uri: https://github.com/mschoenlaub/semian-postgres/blob/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: []