Git Product home page Git Product logo

nim-chronos's Introduction

Chronos - An efficient library for asynchronous programming

Github action License: Apache License: MIT Stability: experimental

Introduction

Chronos is an efficient async/await framework for Nim. Features include:

  • Asynchronous socket and process I/O
  • HTTP server with SSL/TLS support out of the box (no OpenSSL needed)
  • Synchronization primitivies like queues, events and locks
  • Cancellation
  • Efficient dispatch pipeline with excellent multi-platform support
  • Exceptional error handling features, including raises tracking

Getting started

Install 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")

Documentation

See the user guide.

Projects using chronos

  • libp2p - Peer-to-Peer networking stack implemented in many languages
  • presto - REST API framework
  • Scorper - Web framework
  • 2DeFi - Decentralised file system
  • websock - WebSocket library with lots of features

chronos is available in the Nim Playground

Submit a PR to add yours!

TODO

  • Multithreading Stream/Datagram servers

Contributing

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.

License

Licensed and distributed under either of

or

at your option. These files may not be copied, modified, or distributed except according to those terms.

nim-chronos's People

Contributors

cheatfate avatar arnetheduck avatar stefantalpalaru avatar menduist avatar zah avatar dryajov avatar yglukhov avatar jangko avatar araq avatar swader avatar bung87 avatar narimiran avatar alexm-status avatar diegomrsantos avatar mratsim avatar kdeme avatar etan-status avatar derekdai avatar emilivanichkovv avatar sinkingsugar avatar yyoncho avatar bauerj avatar iffy avatar michaelsbradleyjr avatar pietroppeter avatar schnouki avatar gpicron avatar markspanbroek avatar rockcavera avatar tersec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.