Skip to content

Commit 8d63b3b

Browse files
committed
readme improvements
1 parent c62aa1c commit 8d63b3b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88

99
Curly is an efficient thread-ready parallel HTTP client built on top of libcurl.
1010

11-
With Curly you can run one or multiple HTTP requests in parallel while either only blocking the calling thread or not blocking at all.
11+
With Curly you can run one or multiple HTTP requests in parallel and you control how and when you want to block.
1212

1313
Some highlights are:
1414

15-
* Automatic TCP connection re-use (especially valuable for HTTPS connections).
15+
* Automatic TCP connection re-use (a big performance benefit for HTTPS connections).
1616
* Uses HTTP/2 multiplexing when possible (multiple requests in-flight on one TCP connection).
1717
* Any number of threads can start any number of requests and choose their blocking / nonblocking behavior.
18-
* Gzip'ed response bodies are transparently uncompressed.
18+
* Gzip'ed response bodies are transparently uncompressed using [Zippy](https://github.com/guzba/zippy).
19+
* Control how many requests are allowed in-flight at the same time.
1920

2021
By choosing what blocks and doesn't block, you can manage your program's control flow however makes sense for you.
2122

22-
## Examples
23+
### Getting started
24+
```nim
25+
import curly
2326
24-
NOTE! While these examples include `let curl = newCurl()`, it is strongly suggested that you reuse a single or small number of long-lived Curly instances instead of creating new instances frequently.
27+
let curl = newCurly() # Best to start with a single long-lived instance
28+
```
2529

2630
### A simple request
2731
```nim
28-
let curl = newCurly()
29-
3032
let response = curl.post("https://...", headers, body) # blocks until complete
3133
```
3234

3335
### Multiple requests in parallel
3436
```nim
35-
let curl = newCurly()
36-
3737
var batch: RequestBatch
3838
batch.post("https://...", headers, body)
3939
batch.get("https://...")
@@ -42,22 +42,20 @@ for (response, error) in curl.makeRequests(batch): # blocks until all are comple
4242
if error == "":
4343
echo response.code
4444
else:
45+
# Something prevented a response from being received, maybe a connection
46+
# interruption, DNS failure, timeout etc. Error here contains more info.
4547
echo error
4648
```
4749

4850
### A single non-blocking request
4951
```nim
50-
let curl = newCurly()
51-
5252
curl.startRequest("GET", "https://...") # doesn't block
5353
5454
# do whatever
5555
```
5656

5757
### Multiple non-blocking requests
5858
```nim
59-
let curl = newCurly()
60-
6159
var batch: RequestBatch
6260
batch.get(url1)
6361
batch.get(url2)
@@ -83,6 +81,7 @@ else:
8381
let answer = curl.pollForResponse() # checks if a request has completed
8482
if answer.isSome:
8583
if answer.get.error == "":
84+
echo answer.get.response.request.url
8685
echo answer.get.response.code
8786
else:
8887
echo answer.get.error
@@ -92,7 +91,9 @@ Check out the [examples/](https://github.com/guzba/curly/tree/master/examples) f
9291

9392
## Configuration
9493

95-
When you create a Curly instance, you can optionally specify `maxInFlight` which will let you control the maximum HTTP requests that will be actively running at any time. This means you can queue 100,000 requests and know that only say 100 of them will be in-flight at a time.
94+
When you create a Curly instance, you can optionally specify `maxInFlight`. This value lets you control the maximum HTTP requests that will be actively running at any time. The default `maxInFlight` value is 16.
95+
96+
Controlling `maxInFlight` is useful because it means you can queue up 100,000 requests and know that only say 100 of them will be in-flight at a time.
9697

9798
## Queue management
9899

@@ -110,7 +111,7 @@ It is a great starting point to simply have `let curl* = newCurly()` at the top
110111

111112
## Production tested
112113

113-
I have been using Curly in a production web server to make 20k+ HTTPS requests per minute on a tiny VM for a while now without any trouble.
114+
I am using Curly in a production web server to make 20k+ HTTPS requests per minute on a tiny VM for a while now without any trouble.
114115

115116
Both the blocking and non-blocking Curly APIs are used and confirmed working in a very multi-threaded production environment.
116117

0 commit comments

Comments
 (0)