Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:00:55+00:00 2026-06-11T17:00:55+00:00

Maybe this is the wrong approach, but I’m trying to parallelize em-hiredis puts and

  • 0

Maybe this is the wrong approach, but I’m trying to parallelize em-hiredis puts and lookups in Goliath with EM::Synchrony::Multi or EM::Synchrony::FiberIterator. However, I can’t seem to access basic values initialized in the config. I keep getting method_missing errors.

Here’s the basic watered down version of what I’m trying to do:

/lib/config/try.rb

config['redisUri'] = 'redis://localhost:6379/0'
config['redis_db'] ||= EM::Hiredis.connect
config['user_agent'] = "MyCrawler Mozilla/5.0 Compat etc."

Here’s the basic Goliath Setup

/try.rb

require "goliath"
require "em-hiredis"
require "em-synchrony/fiber_iterator"
require "em-synchrony/em-hiredis"
require "em-synchrony/em-multi"

class Try < Goliath::API
  use Goliath::Rack::Params
  use Goliath::Rack::DefaultMimeType

  def response(env)
    case env['REQUEST_PATH']
    when "/start" then
      start_crawl()
      body = "STARTING"
      [200, {}, body]
    end 
  end 

  def start_crawl
    urls = ["http://www.example.com/",
      "http://www.example.com/photos/",
      "http://www.example.com/video/",
    ]

    EM::Synchrony::FiberIterator.new(urls, 3).each do |url|
      p "#{user_agent}"
      redis_db.sadd 'test_queue', url
    end

    # multi = EM::Synchrony::Multi.new
    # urls.each_with_index do |url, index|
    #  p "#{user_agent}"
    #  multi.add index, redis_db.sadd('test_queue', url)
    # end
  end
end

However, I keep getting errors where Goliath doesn’t know what user_agent is or redis_db which were initialized in the config.

[936:INFO] 2012-09-21 23:47:10 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones.
/Users/ewu/.rvm/gems/ruby-1.9.3-p194@crawler/gems/goliath-1.0.0/lib/goliath/api.rb:143:in `method_missing': undefined local variable or method `user_agent' for #<Try:0x007ff5a431c4e0 @opts={}> (NameError)
from ./lib/try.rb:27:in `block in start_crawl'
from /Users/ewu/.rvm/gems/ruby-1.9.3-p194@crawler/gems/em-synchrony-1.0.2/lib/em-synchrony/fiber_iterator.rb:10:in `call'
from /Users/ewu/.rvm/gems/ruby-1.9.3-p194@crawler/gems/em-synchrony-1.0.2/lib/em-synchrony/fiber_iterator.rb:10:in `block (2 levels) in each'
...
...
...

Ideally I’d be able to get FiberIterator working, because I have additional conditionals to check for:

EM::Synchrony::FiberIterator.new(urls, 3).each do |new_url}
  is_member = redis_db.sismember('crawled_urls', new_url)
  is_member += redis_db.sismember('queued_urls', new_url)
  if is_member == 0
    redis_db.lpush 'crawl_queue', new_url
    redis_db.sadd 'queued_urls', new_url
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:00:56+00:00Added an answer on June 11, 2026 at 5:00 pm

    I don’t think your config file is getting loaded. The name of try.rb needs to match the name of the robojin.rb file in the config directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like an odd problem. Maybe it's also the wrong approach. But I
Maybe I am trying to approach this the wrong way... In my main view
Maybe I'm thinking about this the wrong way but here's the idea: Class A
Maybe it's wrong but I always use this query for my app: cme_only =
Sorry if this is on the wrong site ( maybe superuser ) but I'm
Maybe i'm going about this wrong, and if i am please tell me because
I may be approaching this problem from the wrong angle but what I'm thinking
This may be the wrong place but this is new to me. I did
Maybe this is a poor question, but, I can't find a tutorial or even
Maybe this is something very easy to do it but so far it's taking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.