Class: Kiyohime::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/kiyohime/registry.rb

Overview

A registry is a listing of services/functions which are accessible via a publish/subscribe paradigm. This services/functions are accessible through the Publisher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, store) ⇒ Registry

A registry should be provided with a name, and an underlying store. If the hiredis flag is set to true we use the hiredis wrapper around redis instead



12
13
14
15
16
# File 'lib/kiyohime/registry.rb', line 12

def initialize(name, store)
  @name = name
  @store = store
  @channel_parser = Kiyohime::Parsers::ChannelParser.new
end

Instance Attribute Details

#channel_parserObject (readonly)

Returns the value of attribute channel_parser.



8
9
10
# File 'lib/kiyohime/registry.rb', line 8

def channel_parser
  @channel_parser
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/kiyohime/registry.rb', line 8

def name
  @name
end

#pubsubObject (readonly)

Returns the value of attribute pubsub.



8
9
10
# File 'lib/kiyohime/registry.rb', line 8

def pubsub
  @pubsub
end

#storeObject (readonly)

Returns the value of attribute store.



8
9
10
# File 'lib/kiyohime/registry.rb', line 8

def store
  @store
end

Instance Method Details

#register_containers(*service_containers) ⇒ Object

Non blocking registration of services. The run block creates an event loop, this allows the process to continue and service publications via registered subscribers



30
31
32
33
34
35
36
# File 'lib/kiyohime/registry.rb', line 30

def register_containers(*service_containers)
  EM.run do
    initialise_registry
    subscribe_deregister
    service_containers.each { |service_container| register_container(service_container) }
  end
end

#register_services(*services) ⇒ Object

Non blocking registration of services. The run block creates an event loop, this allows the process to continue and service publications via registered subscribers



20
21
22
23
24
25
26
# File 'lib/kiyohime/registry.rb', line 20

def register_services(*services)
  EM.run do
    initialise_registry
    subscribe_deregister
    services.each { |service| register(service) }
  end
end