ruby-trello icon indicating copy to clipboard operation
ruby-trello copied to clipboard

Add thread capabilities for async requests.

Open omarps opened this issue 10 years ago • 4 comments

Comparing with the Official Javascript Library, this gem is not async, so you can yo and wrap the requests in a Thread implementation (or even Fiber), but it would be nice, if the gem itself provides async methods to improve the performance.

omarps avatar Jan 26 '15 16:01 omarps

Hi @omarps . Are you talking about the node-trello?

I don't think that this is a good idea to bring something like that to this Gem. Node is a event-driven environment. And using threads could potentially increase the complexity of the Gem. Also it will only be helpful in worker jobs as in normal HTTP requests we usually don't have anything to postpone the response.

I think that the best approach is to create something new using event machine if that's what your talking about.

What do you think? =]

viniciusoyama avatar Feb 18 '15 18:02 viniciusoyama

Hi @viniciusoyama, I'm refering to the kind execution process that is made when you use the Trello's JavaScript API.

For example, you could launch a method to get some boards and in the callback method, start querying for the lists' cards.

I have a project that navigates thought the Board/List/Cards/Users hierarchy that works pretty well, but when I tried to migrate the logic to to a Rails Project and start using the ruby-trello gem, it takes longer than expected just to load the Boards.

That's what am I asking for some thread approach to solve this.

omarps avatar Feb 27 '15 01:02 omarps

Anyone have any ideas on how to realize this w/o breaking how the API currently works too much? If there are some good ideas here, I'd love to consider them for 2.0. This and #116 would be nice to have a discussion on for 2.0 planning.

jeremytregunna avatar Nov 03 '15 22:11 jeremytregunna

Hey @jeremytregunna can you help me with some scenarios?

With the current API, if I want to make async operations I have to open threads:

Thread.new do 
  user = Trello::Member.find("user1")
  #save things..
end

Thread.new do 
  user = Trello::Member.find("user2")
  #save things..
end

#...

For 2.0 you want something like this:

Trello::Member.find("user1") do  |user|
  #save things
end

Trello::Member.find("user1") do  |user|
  #save things
end

Is that it? Sorry I'm trying to understand what you guys want in order to help.

viniciusoyama avatar Nov 06 '15 20:11 viniciusoyama