Module: ActiveCypher::RuntimeRegistry
- Defined in:
- lib/active_cypher/runtime_registry.rb
Constant Summary collapse
- ROLE_KEY =
:active_cypher_role- SHARD_KEY =
:active_cypher_shard
Class Method Summary collapse
- .current_role ⇒ Object
- .current_role=(value) ⇒ Object
- .current_shard ⇒ Object
- .current_shard=(value) ⇒ Object
- .fiber_store ⇒ Object
- .get(key) ⇒ Object
-
.set(key, value) ⇒ Object
── storage helpers ────────────────────────────────────────────.
- .thread_store ⇒ Object
Class Method Details
.current_role ⇒ Object
15 16 17 |
# File 'lib/active_cypher/runtime_registry.rb', line 15 def current_role get(ROLE_KEY) || thread_store[ROLE_KEY] || :writing end |
.current_role=(value) ⇒ Object
19 20 21 22 |
# File 'lib/active_cypher/runtime_registry.rb', line 19 def current_role=(value) set(ROLE_KEY, value) thread_store[ROLE_KEY] = value end |
.current_shard ⇒ Object
24 25 26 |
# File 'lib/active_cypher/runtime_registry.rb', line 24 def current_shard get(SHARD_KEY) || thread_store[SHARD_KEY] || :default end |
.current_shard=(value) ⇒ Object
28 29 30 31 |
# File 'lib/active_cypher/runtime_registry.rb', line 28 def current_shard=(value) set(SHARD_KEY, value) thread_store[SHARD_KEY] = value end |
.fiber_store ⇒ Object
44 45 46 47 |
# File 'lib/active_cypher/runtime_registry.rb', line 44 def fiber_store registry = thread_store[:active_cypher_fiber_store] ||= {} registry[Fiber.current.object_id] ||= {} end |
.get(key) ⇒ Object
40 41 42 |
# File 'lib/active_cypher/runtime_registry.rb', line 40 def get(key) fiber_store[key] end |
.set(key, value) ⇒ Object
── storage helpers ────────────────────────────────────────────
35 36 37 38 |
# File 'lib/active_cypher/runtime_registry.rb', line 35 def set(key, value) store = fiber_store store[key] = value end |
.thread_store ⇒ Object
49 50 51 |
# File 'lib/active_cypher/runtime_registry.rb', line 49 def thread_store Thread.current[:active_cypher_thread_store] ||= {} end |