Class: CelluloidIOPGListener::SuperviseSignature

Inherits:
Object
  • Object
show all
Defined in:
lib/celluloid-io-pg-listener/supervise_signature.rb

Overview

Usage:

Given a yaml config file of this format:

listening_group:
-
  listener_active: <%= ENV["LISTENER_ACTIVE"] || false %>
  type: HerokuConnectListener::SalesforceAccountClient
  as: insert_client
  args:
    database_url: <%= ENV["DATABASE_URL"] %>
      redis_url: <%= ENV["REDISTOGO_URL"] || "redis://localhost:6379/" %>
    callback_method: notify_callback
    channel: <%= ENV["SCHEMA_NAME"] %>_account_insert

Create a Supervision Container such as:

class ListeningGroup < Celluloid::Supervision::Container
  config_path = options[:config_path] || "config/settings.yml"
  config      = YAML::load(ERB.new(File.read(config_path)).result)
  supervise CelluloidIOPGListener::SuperviseSignature.new(
                type: config["type"],
                as: config["as"],
                args: config["args"]
            ).signature
end

ListeningGroup.run

Constant Summary collapse

KEYS_WITH_SYMBOL_VALUES =
%( callback_method )

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, as:, args:) ⇒ SuperviseSignature

Returns a new instance of SuperviseSignature.



37
38
39
40
41
42
43
44
45
# File 'lib/celluloid-io-pg-listener/supervise_signature.rb', line 37

def initialize(type:, as:, args:)
  @type = Kernel.const_get(type)
  @as = as.to_sym
  if has_database_url?(args)
    args.merge!(convert_database_url_to_hash(db_url: args.delete("database_url")))
  end
  @args = []
  @args << symbolize_keys(args)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



35
36
37
# File 'lib/celluloid-io-pg-listener/supervise_signature.rb', line 35

def args
  @args
end

#asObject (readonly)

Returns the value of attribute as.



34
35
36
# File 'lib/celluloid-io-pg-listener/supervise_signature.rb', line 34

def as
  @as
end

#typeObject (readonly)

Returns the value of attribute type.



33
34
35
# File 'lib/celluloid-io-pg-listener/supervise_signature.rb', line 33

def type
  @type
end

Instance Method Details

#signatureObject



47
48
49
50
51
52
53
# File 'lib/celluloid-io-pg-listener/supervise_signature.rb', line 47

def signature
  {
      type: type,
      as: as,
      args: args
  }
end