Module: Takagi::EventBus::Scope
- Defined in:
- lib/takagi/event_bus/scope.rb
Overview
Message scope levels for clustering support
LOCAL: Message stays on this instance only CLUSTER: Message delivered to all instances in cluster GLOBAL: Message delivered to cluster + external CoAP subscribers
Constant Summary collapse
- LOCAL =
This instance only - never leaves process
:local- CLUSTER =
All instances in cluster - distributed via CoAP OBSERVE
:cluster- GLOBAL =
Cluster + external CoAP subscribers - published to /.well-known/core
:global- DEFAULT =
Default scope if not specified
LOCAL- ALL =
All valid scope values
[LOCAL, CLUSTER, GLOBAL].freeze
Class Method Summary collapse
-
.distributed?(scope) ⇒ Boolean
Check if scope requires cluster distribution.
-
.external?(scope) ⇒ Boolean
Check if scope allows external CoAP subscribers.
-
.local_only?(scope) ⇒ Boolean
Check if scope is local-only.
-
.normalize(scope) ⇒ Symbol
Normalize scope value.
-
.valid?(scope) ⇒ Boolean
Check if scope is valid.
Class Method Details
.distributed?(scope) ⇒ Boolean
Check if scope requires cluster distribution
55 56 57 |
# File 'lib/takagi/event_bus/scope.rb', line 55 def self.distributed?(scope) scope == CLUSTER || scope == GLOBAL end |
.external?(scope) ⇒ Boolean
Check if scope allows external CoAP subscribers
62 63 64 |
# File 'lib/takagi/event_bus/scope.rb', line 62 def self.external?(scope) scope == GLOBAL end |
.local_only?(scope) ⇒ Boolean
Check if scope is local-only
69 70 71 |
# File 'lib/takagi/event_bus/scope.rb', line 69 def self.local_only?(scope) scope == LOCAL end |
.normalize(scope) ⇒ Symbol
Normalize scope value
45 46 47 48 49 50 |
# File 'lib/takagi/event_bus/scope.rb', line 45 def self.normalize(scope) return DEFAULT if scope.nil? scope_sym = scope.to_sym valid?(scope_sym) ? scope_sym : DEFAULT end |
.valid?(scope) ⇒ Boolean
Check if scope is valid
38 39 40 |
# File 'lib/takagi/event_bus/scope.rb', line 38 def self.valid?(scope) ALL.include?(scope) end |