class
Athena::Mercure::Hub::Registry
- Athena::Mercure::Hub::Registry
- Reference
- Object
Overview
The [AMC::Hub::Registry][] can be used to store multiple [AMC::Hub][] instances, accessing them by unique names.
foo_hub = hub = AMC::Hub.new ENV["FOO_HUB_MERCURE_URL"], foo_token_provider, foo_token_factory
bar_hub = hub = AMC::Hub.new ENV["BAR_HUB_MERCURE_URL"], bar_token_provider, bar_token_factory
registry = AMC::Hub::Registry.new(
foo_hub,
{
"foo" => foo_hub,
"bar" => bar_hub,
} of String => AMC::Hub::Interface
)
registry.hub # => (default foo_hub)
registry.hub "bar" # => (bar_hub)
Defined in:
hub/registry.crConstructors
Instance Method Summary
-
#hub(name : String | Nil = nil) : AMC::Hub::Interface
Returns the hub with the provided name, or the default one if no name was provided.
-
#hubs : Hash(String, AMC::Hub::Interface)
Returns the mapping of hub names to their related instance.
Constructor Detail
def self.new(default_hub : AMC::Hub::Interface, hubs : Hash(String, AMC::Hub::Interface) = {} of String => AMC::Hub::Interface)
#
Instance Method Detail
Returns the hub with the provided name, or the default one if no name was provided.
def hubs : Hash(String, AMC::Hub::Interface)
#
Returns the mapping of hub names to their related instance.