Chronos - An efficient library for asynchronous programming
Chronos is an efficient async/await framework for Nim. Features include:
raises
trackingInstall chronos
using nimble
:
nimble install chronos
or add a dependency to your .nimble
file:
requires "chronos"
and start using it:
import chronos/apps/http/httpclient
proc retrievePage(uri: string): Future[string] {.async.} =
# Create a new HTTP session
let httpSession = HttpSessionRef.new()
try:
# Fetch page contents
let resp = await httpSession.fetch(parseUri(uri))
# Convert response to a string, assuming its encoding matches the terminal!
bytesToString(resp.data)
finally: # Close the session
await noCancel(httpSession.closeWait())
echo waitFor retrievePage(
"https://raw.githubusercontent.com/status-im/nim-chronos/master/README.md")
See the user guide.
chronos
chronos
is available in the Nim Playground
Submit a PR to add yours!
When submitting pull requests, please add test cases for any new features or fixes and make sure nimble test
is still able to execute the entire test suite successfully.
chronos
follows the Status Nim Style Guide.
Licensed and distributed under either of
or
at your option. These files may not be copied, modified, or distributed except according to those terms.