eventmachine

Asynchronously iterating over the response of a request using Thin and Sinatra

不打扰是莪最后的温柔 提交于 2019-12-03 16:15:28
If your response in Sinatra returns an 'eachable' object, Sinatra's event loop will 'each' your result and yield the results in a streaming fashion as the HTTP response. However, if there are concurrent requests to Sinatra, it will iterate through all the elements of one response before handling another request. If we have a cursor to the results of some DB query, that means we have to wait for all the data to be available before handling a concurrent query. I've looked at the async-sinatra gem and http://macournoyer.com/blog/2009/06/04/pusher-and-async-with-thin/ , thinking these would solve

using the postgresql gem async

梦想与她 提交于 2019-12-03 06:22:59
问题 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 postgres database? 回答1: The pg library provides full support for PostgreSQL's asynchronous API. I've added an example of how to use it to the samples/ directory: #!/usr/bin/env ruby require 'pg' # This is a example of how to use the asynchronous API to

Ruby IMAP IDLE concurrency - how to tackle?

走远了吗. 提交于 2019-12-03 04:06:37
I'm trying to build a (private, for now) web application that will utilize IMAP IDLE connections to show peoples emails as they arrive. I'm having a hard time figuring out how to hack this together - and how it would fit together with my Heroku RoR server. I've written a basic script for connecting to an IMAP server and idling, looks something like this (simplified): imap = Net::IMAP.new server, port, usessl imap.login username, password imap.select "INBOX" imap.add_response_handler do |response| if resp.kind_of(Net::IMAP::UntaggedResponse) && resp.name == "EXISTS" # New mail recieved. Ping

EventMachine vs Node.js

微笑、不失礼 提交于 2019-12-03 01:06:22
问题 I'm going to develop a collaborative site, and one of the features will be collaborative editing with realtime changes. i.e. when two or more users are editing the same doc, they can see each other changes as soon as they happen. I have some experience with Ruby on Rails, so I was thinking about using EventMachine, but with all this hype around Node.js, I am know considering using it instead. So, what would be the main benefits of using Node.js instead of EventMachine? tl;dr What are the main

EventMachine vs Node.js

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 16:23:16
I'm going to develop a collaborative site, and one of the features will be collaborative editing with realtime changes. i.e. when two or more users are editing the same doc, they can see each other changes as soon as they happen. I have some experience with Ruby on Rails, so I was thinking about using EventMachine, but with all this hype around Node.js, I am know considering using it instead. So, what would be the main benefits of using Node.js instead of EventMachine? tl;dr What are the main differences between EventMachine and Node.js (besides the language)? EventMachine has nothing to do

Why Sinatra request takes EM thread?

不问归期 提交于 2019-12-02 14:06:53
问题 Sinatra app receives requests for long running tasks and EM.defer them, launching them in EM's internal pool of 20 threads. When there are more than 20 EM.defer running, they are stored in EM's threadqueue by EM.defer. However, it seems Sinatra won't service any requests until there is an EM thread available to handle them. My question is, isn't Sinatra suppose to use the reactor of the main thread to service all requests? Why am I seeing an add on the threadqueue when I make a new request?

Why Sinatra request takes EM thread?

不打扰是莪最后的温柔 提交于 2019-12-02 04:33:06
Sinatra app receives requests for long running tasks and EM.defer them, launching them in EM's internal pool of 20 threads. When there are more than 20 EM.defer running, they are stored in EM's threadqueue by EM.defer. However, it seems Sinatra won't service any requests until there is an EM thread available to handle them. My question is, isn't Sinatra suppose to use the reactor of the main thread to service all requests? Why am I seeing an add on the threadqueue when I make a new request? Steps to reproduce: Access /track/ Launch 30 /sleep/ reqs to fill the threadqueue Access /ping/ and

thin rails server/eventmachine on windows does not work with custom certificate

时光怂恿深爱的人放手 提交于 2019-12-02 04:30:26
问题 After building my own eventmachine/thin with SSL support on windows (Install OpenSSL with Ruby for eventmachine on Windows 7 x86) I got another problem with SSL certificate: when I use build-in self-signed one thin works fine but it does not respond to any request while using corporate certificate Here is my path for obtaining the certificate: I generated private key with puttygen (ssl-private.key) I generated CSR using following command: openssl req -out ssl.csr -key ssl-private.key -new I

thin rails server/eventmachine on windows does not work with custom certificate

徘徊边缘 提交于 2019-12-02 01:52:41
After building my own eventmachine/thin with SSL support on windows ( Install OpenSSL with Ruby for eventmachine on Windows 7 x86 ) I got another problem with SSL certificate: when I use build-in self-signed one thin works fine but it does not respond to any request while using corporate certificate Here is my path for obtaining the certificate: I generated private key with puttygen (ssl-private.key) I generated CSR using following command: openssl req -out ssl.csr -key ssl-private.key -new I sent CSR to CA and received P7B file I converted P7B using following command: openssl pkcs7 -inform

Install OpenSSL with Ruby for eventmachine on Windows 7 x86

ⅰ亾dé卋堺 提交于 2019-12-01 05:31:33
Install OpenSSL with Ruby for eventmachine on Windows 7 x86. I want to install eventmachine gem on Windows 7 x86 SP1. I have installed rubyinstaller-2.1.5.exe from http://rubyinstaller.org/downloads/ I have also installed DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe . I run command: gem install eventmachine --platform=ruby As for now this is to use eventmachine-1.0.4 . I got following console output: Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing eventmachine: ERROR: Failed to build gem native extension. C:/Ruby21