Skip to content

undefined method `publisher_config' for Circuitry:Module #78

@mayordwells

Description

@mayordwells

Trying to demo Circuitry in my app, so using the config in the example app
I created a file circuitry.rb in the initializers folder, it has the following content as copied from the example app

require 'circuitry'

Circuitry.publisher_config do |c|
  c.access_key = ENV.fetch('AWS_ACCESS_KEY')
  c.secret_key = ENV.fetch('AWS_SECRET_KEY')
  c.region     = ENV.fetch('AWS_REGION')
  c.logger     = Rails.logger

  c.async_strategy = :thread

  c.on_async_exit = proc do
    puts 'Publisher done.'
  end

  # list of topics that will be published to
  c.topic_names = %w[
    example-circuitry-topic
  ]
end

Circuitry.subscriber_config do |c|
  c.access_key = ENV.fetch('AWS_ACCESS_KEY')
  c.secret_key = ENV.fetch('AWS_SECRET_KEY')
  c.region     = ENV.fetch('AWS_REGION')

  c.async_strategy = :thread

  c.on_async_exit = proc do
    puts 'Subscriber done.'
  end

  c.queue_name = 'example-circuitry-queue'

  # list of topics that the queue should subscribe to
  c.topic_names = %w[
    example-circuitry-topic
  ]
end

created these 2 other files in the config folder
subscriber.rb

require_relative './initializers/circuitry'

Circuitry.subscribe(async: true) do |message, topic|
  puts "Received: #{topic}: #{message.inspect}"
end

and publisher.rb

require_relative './initializers/circuitry'

topic = 'example-circuitry-topic'

10.times do |n|
  # `object` can be anything that responds to `#to_json`.
  object = { foo: 'bar', fizz: 'buzz', n: n }

  Circuitry.publish(topic, object, async: true)
end

Circuitry.flush

My app is not stating up because of this error and I have no idea how to fix.

web_1        | rake aborted!
web_1        | NoMethodError: undefined method `publisher_config' for Circuitry:Module
web_1        | Did you mean?  public_send
web_1        | /conectar/config/initializers/circuitry.rb:3:in `<main>'

Any idea how to fix this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions