Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `publisher_config' for Circuitry:Module #78

Open
mayordwells opened this issue Jan 1, 2019 · 3 comments
Open

undefined method `publisher_config' for Circuitry:Module #78

mayordwells opened this issue Jan 1, 2019 · 3 comments

Comments

@mayordwells
Copy link

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?

@mhuggins
Copy link
Contributor

mhuggins commented Jan 1, 2019

What version of circuitry are you using? There used to only be a single config method prior to 3.0.0. 8235ce4

@mayordwells
Copy link
Author

@mhuggins i'm using the latest version v3.2.0

@mhuggins
Copy link
Contributor

mhuggins commented Jan 2, 2019

Can you publish a small sample app on GitHub that reproduces the issue? Have never run into this, and the example code you provided works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants