ikod / dlang-requests

dlang http client library inspired by python-requests
Boost Software License 1.0
154 stars 32 forks source link

newbie Q: sync blocking normal func call (std.socket) v.s. async non-blocking fiber call (vibe.d) #123

Closed mw66 closed 4 years ago

mw66 commented 4 years ago

In this section, it's said:

https://github.com/ikod/dlang-requests/blob/master/README.md#vibed

You can safely use dlang-requests with vibe.d. When dlang-requests is compiled with support for vibe.d sockets (--config=vibed), 
each call to dlang-requests API can block only the current fiber, not the thread:

Does this means: -- with std.socket: the network IO is normal (sync) function call which will block the current calling thread. -- with vibe.d: the network IO is wrapped async fiber call (via vibe.d), so, it can block only the current fiber, not the current thread.

If yes, I think this is very import library usage guide to the (new) user (like me), and this section should be moved to the top, as an subsection of right here: Library configurations, and emphasize this important difference.

https://github.com/ikod/dlang-requests/blob/master/README.md#library-configurations

Thanks.

mw66 commented 4 years ago

and another newbie Q:

When dlang-requests is compiled with support for vibe.d sockets (--config=vibed)

where to specify this build option --config=vibed? I'm using dub.

Maybe this info should also be put in the doc.

ikod commented 4 years ago

In this section, it's said:

https://github.com/ikod/dlang-requests/blob/master/README.md#vibed

You can safely use dlang-requests with vibe.d. When dlang-requests is compiled with support for vibe.d sockets (--config=vibed), 
each call to dlang-requests API can block only the current fiber, not the thread:

Does this means: -- with std.socket: the network IO is normal (sync) function call which will block the current calling thread. -- with vibe.d: the network IO is wrapped async fiber call (via vibe.d), so, it can block only the current fiber, not the current thread.

Yes, you are correct. In "vibed" mode requests use vibe "non-blocling" sockets.

If yes, I think this is very import library usage guide to the (new) user (like me), and this section should be moved to the top, as an subsection of right here: Library configurations, and emphasize this important difference.

Ok, thanks! Will add few lines.

https://github.com/ikod/dlang-requests/blob/master/README.md#library-configurations

Thanks.

ikod commented 4 years ago

and another newbie Q:

When dlang-requests is compiled with support for vibe.d sockets (--config=vibed)

where to specify this build option --config=vibed? I'm using dub.

I your dub.file just insert few lines

"dependencies": {
    "requests": "~>1"
},
"subConfigurations": {
    "requests": "vibed"
}

But you also have actually write vibe application, not just mention this dependency and mode.

Maybe this info should also be put in the doc.