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

  • SEARCH
  • Home
  • 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 7171799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:29:11+00:00 2026-05-28T15:29:11+00:00

What is a good way to provide an easy to use object-style interface to

  • 0

What is a good way to provide an easy to use object-style interface to an HTTP API, while still allowing asynchronous HTTP requests to be made? For example, given the following code:

user = User.find(1) # /api/v1/users/1
f = user.foo # /api/v1/users/1/foo
b = user.bar # /api/v1/users/1/bar

Calls to the foo and bar methods could logically be called in parallel, but if possible I’d like to let the calling user have a clean way to declare their intent for parallel calls without getting into the details of the underlying HTTP lib.

I don’t think invisibly automating the parallelization is a good idea, so that the calling code is explicit about its expectations. But, I do think something like the following block syntax could be extremely useful for front-end developers to be able to use when they know that a set of requests do not depend on each other.

# possible implementation?
user = User.find(1)
User.parallel do
  f = user.foo
  b = user.bar
end

Is this possible? How can I accomplish this using Ruby 1.9.2?

  • 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-05-28T15:29:11+00:00Added an answer on May 28, 2026 at 3:29 pm

    Transparent parallelization is generally accomplished through something called a future. In ruby, both the lazy and promise gems have implementations of futures. Here’s an example with the promise gem:

    require 'future'
    user = User.find(1)
    f = future{user.foo}
    b = future{user.bar}
    

    A future will run the computation in a block in a background thread, and any attempt to operate on f or b will block unless the background thread has already run to completion.

    As a library designer, so long as your library is threadsafe, this should be fine in many cases, though it probably doesn’t scale all that well in ruby.

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

Sidebar

Related Questions

Is there a good way to provide an auto-increment style index column (from 1..x)
Could someone provide me with a good way of importing a whole directory of
Originally I thought to ask if there would be an easy way to provide
I'm working on an app to provide an easy way for people to track
Is there a good way to get the debug information that Django provides when
Is there any good way to deal with the class renaming refactor from Resharper
Is there a good way for displaying unicode text in opengl under Windows? For
What is a good way to remove the code from display pages when developing
Is there a good way to create a form in VB6 that can easily
Does anyone have a good way to build MSI (vdproj) projects using MsBuild or

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.