Questions tagged [eventmachine]

EventMachine is a fast, reactor pattern library for Ruby programs. It provides non-blocking IO APIs with transparent internal buffers and standard reactor features (such as defer, next_tick and timers). (note to future editors: Eventmachine itself does not use Fibers, and the core does not use threads for any IO, timers or core infrastructure).

EventMachine is a fast, reactor pattern library for Ruby programs.

627 questions
12
votes
3 answers

Issues serving Jekyll to localhost, eventmachine 1.2.7 has an error when installing

Not sure what to do to specifically fix this problem, googled and nothing solved my question. When I try to: bundle exec jekyll serve I get told: Could not find eventmachine-1.2.7 in any of the sources Run `bundle install` to install missing…
timoweaver
  • 121
  • 1
  • 3
12
votes
1 answer

What is the best way to read files in an EventMachine-based app?

In order not to block the reactor I would like to read files asynchronously, but I've found no obvious way of doing it using EventMachine. I've tried a few different approaches, but none of them feels right: Just read the file, it'll block the…
Theo
  • 131,503
  • 21
  • 160
  • 205
12
votes
7 answers

Detect if application was started as HTTP server or not (rake task, rconsole etc)

I'm using EventMachine and Monetarily to start e TCP server along with my rails application. This is started from config/initializers/momentarily.rb. My problem is that it starts also when I run rake tasks, like db:migrate. I only want it to start…
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
11
votes
4 answers

Why is EventMachine's defer slower than a Ruby Thread?

I have two scripts which use Mechanize to fetch a Google index page. I assumed EventMachine will be faster than a Ruby thread, but it's not. EventMachine code costs: "0.24s user 0.08s system 2% cpu 12.682 total" Ruby Thread code costs: "0.22s user…
allenwei
  • 4,047
  • 5
  • 23
  • 26
11
votes
1 answer

Why is rails not fully supporting writing evented code out out the box

After Node.js came out, it was the one thing that popularized evented programming. But, Ruby does have EventMachine which supports writing evented code. The requirements for supporting eventing in rails are: 1. Evented server (thin, rainbows) which…
Pratik Khadloya
  • 12,509
  • 11
  • 81
  • 106
11
votes
1 answer

Rails app and goliath api and database/models sharing

I'm trying to create async api with Goliath framework. Service should write to mysql, add messages to RabbitMQ and receive responses back. There also should be a separate admin application built with Rails. I have several questions about that: Is…
gayavat
  • 18,910
  • 11
  • 45
  • 55
9
votes
2 answers

I can't install eventmachine gem on mac m1

I got a new m1 mac and I can't install eventmachine gem, full log below. I tried these solutions: Install gem eventmachine 1.2.7 with ssl on m1 eventmachine does not compile with ruby 3.0.0preview1 on macOS · Issue #932 ·…
Shining Love Star
  • 5,734
  • 5
  • 39
  • 49
9
votes
4 answers

using the postgresql gem async

I'm using Goliath (which is powered by eventmachine) and the postgres gem pg, currently I'm using the pg gem in a blocking way: conn.exec('SELECT * FROM products') (for example) and I'm wondering whether there is a better way to connect to a…
errorhandler
  • 1,757
  • 3
  • 22
  • 29
9
votes
2 answers

Thin EventMachine Sinatra vs. Rails

I have been looking into the possibility of backgrounding some jobs with EventMachine. In Sinatra this appears to work great but Rails 3 appears to execute all ticks before rendering a view. When I run the following code under the thin webserver it…
Bruce Hauman
  • 146
  • 1
  • 5
8
votes
2 answers

Multiple Ruby EventMachines in one process: possible?

I have a situation where I want to run multiple EventMachines in Ruby - does anyone have experience with this? (I may write a test case to do it myself if not. Stay tuned). Let's be clear: I want to instantiate two threads myself, and call…
Matt
  • 10,434
  • 1
  • 36
  • 45
8
votes
1 answer

Multiple servers in a single EventMachine reactor

Is it possible to run multiple servers within a single event machine? What I mean is that multiple services can be used concurrently by a single client connection. For example, a login server authenticates a user and then a user can use both a chat…
david
  • 238
  • 2
  • 9
8
votes
3 answers

Integrating WebSockets with Rails using Rack and Event Machine

I have created an Asynchronous version of Rails 3 that I would like to integrate with a WebSocket implementation. I am using EventMachine, Ruby 1.9, Fibers and various em-flavoured libraries as documented by the wickedly good Ilya Grigorik. I have…
Toby Hede
  • 36,755
  • 28
  • 133
  • 162
8
votes
2 answers

How to hand-over a TCP listening socket with minimal downtime?

While this question is tagged EventMachine, generic BSD-socket solutions in any language are much appreciated too. Some background: I have an application listening on a TCP socket. It is started and shut down with a regular System V style init…
Stéphan Kochen
  • 19,513
  • 9
  • 61
  • 50
8
votes
2 answers

How should I handle this use case using EventMachine?

I have an application that reacts to messages sent by clients. One message is reload_credentials, that the application receives any time a new client registers. This message will then connect to a PostgreSQL database, do a query for all the…
Geo
  • 93,257
  • 117
  • 344
  • 520
7
votes
3 answers

Communicating between two processes on heroku (what port to use)

I have a Procfile like so: web: bundle exec rails server -p $PORT em: script/eventmachine The em process fires up an eventmachine with start_server (port ENV['PORT']) and my web process occasionally needs to communicate with it. My…
Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
1
2
3
41 42