semian 0.28.3 → 0.28.4

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: 65071f9b9f241c4306a81f24e696220928dd7fd42fe50f9664f51212af37be27
4
- data.tar.gz: aea78d645e703f42516e8a507887184a85ef98d547312646f609d6d145c9c2ee
3
+ metadata.gz: 8fa1376f607286da6a30b6db227b4b27281228308c9c68724b356189cc97d2fb
4
+ data.tar.gz: 05161e0480da351f89ee3c3fe40cc9d4527a20e64f7830fdf671f92057675bb5
5
5
  SHA512:
6
- metadata.gz: f628d7359a24fe78fc5ae8885f81e181d1e1a6da1b2956079fdc19e48df63d78f76de29d0cf681ea8c9e6bfc8952b23ab69e86d7313a49628c52ed6b482b49b2
7
- data.tar.gz: f166272364381bdc17db8bfc6bf4b62827ae0ac7c99803b1ab6617acc80244d0163dd2a54b7f704501fd4790135fa2f7fbc90b181a8f656d05ecbff83e9bc7c6
6
+ metadata.gz: 22d2074bf889aae268ea568f4a95f43b8e27f7b02ff24f4bf4afdcddba98bdf01e9090b166bc1b0124667bce39f57f19b5933415a309779e86fe448d5b2f7a36
7
+ data.tar.gz: 0b7a495a4e7a0bf71fa87b7422c6076c0580b3e368c23d1418d1e8c92745d2ba5acf951a049ade3e2b780a30273ad08fcb30747df2de36d5535e5a002866a952
data/README.md CHANGED
@@ -83,7 +83,8 @@ To create a Semian adapter you must implement the following methods:
83
83
  1. [`include Semian::Adapter`][semian-adapter]. Use the helpers to wrap the
84
84
  resource. This takes care of situations such as monitoring, nested resources,
85
85
  unsupported platforms, creating the Semian resource if it doesn't already
86
- exist and so on.
86
+ exist and so on. Include it in an object that represents a single resource,
87
+ typically one connection — see [Thread Safety](#thread-safety).
87
88
  2. `#semian_identifier`. This is responsible for returning a symbol that
88
89
  represents every unique resource, for example `redis_master` or
89
90
  `mysql_shard_1`. This is usually assembled from a `name` attribute on the
@@ -214,6 +215,27 @@ Semian's circuit breaker implementation is thread-safe by default as of
214
215
  `v0.7.0`. If you'd like to disable it for performance reasons, pass
215
216
  `thread_safety_disabled: true` to the resource options.
216
217
 
218
+ An adapter instance represents one resource. Once that resource has been
219
+ acquired, Semian treats further access through the same instance as part of the
220
+ same session: nested or overlapping calls do not re-enter the circuit breaker
221
+ and do not take a second bulkhead ticket, so a circuit that opens elsewhere in
222
+ the process cannot interrupt a session that is already in flight and
223
+ succeeding. Every adapter that ships with Semian has this shape — the mixin is
224
+ included in a connection object, and the session is that connection's unit of
225
+ work.
226
+
227
+ This is likely to give unexpected results if the adapter instance is shared
228
+ process-wide, such as by a singleton. While any call is in flight, calls made
229
+ through the same instance from other threads are treated as part of that
230
+ session, so they are not fast-failed when the circuit has opened since that
231
+ first acquire, and they cannot contribute failures. Where calls overlap
232
+ continuously, that keeps the circuit closed while the resource is failing.
233
+ Consider introducing a "session" object as the adapterized wrapper around the
234
+ singleton instead, created per unit of work — per request, say. Circuit breaker
235
+ and bulkhead state is keyed by `semian_identifier` and held in a process-wide
236
+ registry, so short-lived adapter instances that share an identifier all share
237
+ one circuit.
238
+
217
239
  Bulkheads should be disabled (pass `bulkhead: false`) in a threaded environment
218
240
  (e.g. Puma or Sidekiq), but can safely be enabled in non-threaded environments
219
241
  (e.g. Resque and Unicorn). As described in this document, circuit breakers alone
@@ -79,11 +79,10 @@ module Semian
79
79
  end
80
80
 
81
81
  def mark_resource_as_acquired
82
- previous = @resource_acquired
83
82
  @resource_acquired = true
84
83
  yield
85
84
  ensure
86
- @resource_acquired = previous
85
+ @resource_acquired = false
87
86
  end
88
87
  end
89
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Semian
4
- VERSION = "0.28.3"
4
+ VERSION = "0.28.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.3
4
+ version: 0.28.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Francis