class Athena::Mercure::Hub::Registry

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(default_hub : AMC::Hub::Interface, hubs : Hash(String, AMC::Hub::Interface) = {} of String => AMC::Hub::Interface) #

[View source]

Instance Method Detail

def hub(name : String | Nil = nil) : AMC::Hub::Interface #

Returns the hub with the provided name, or the default one if no name was provided.


[View source]
def hubs : Hash(String, AMC::Hub::Interface) #

Returns the mapping of hub names to their related instance.


[View source]