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 +4 -4
- data/README.md +23 -1
- data/lib/semian/adapter.rb +1 -2
- data/lib/semian/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8fa1376f607286da6a30b6db227b4b27281228308c9c68724b356189cc97d2fb
|
|
4
|
+
data.tar.gz: 05161e0480da351f89ee3c3fe40cc9d4527a20e64f7830fdf671f92057675bb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/semian/adapter.rb
CHANGED
data/lib/semian/version.rb
CHANGED