Skip to content

fox0430/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retry

A simple retry interface in Nim.

Examples

import std/httpclient
import pkg/retry

var client = newHttpClient()

retry:
  discard client.getContent("https://nim-lang.org")
# Please call the `asyncBackend` flag: -d:asyncBackend=asyncdispatch

import std/[asyncdispatch, httpclient]
import pkg/retry

proc getContentAsync(url: string): Future[string] {.async.} = 
  var client = newAsyncHttpClient()

  retryAsync:
    return await client.getContent(url)

discard waitFor getContentAsync("https://nim-lang.org")
import std/[httpclient, logging]
import pkg/retry

let myPolicy = RetryPolicy(
  delay: 100,
  maxDelay: 1000,
  backoff: BackOff.exponential,
  exponent: 2,
  maxRetries: 3,
  jitter: true,
  failLog: true,
  logLevel: Level.lvlError,
  customFailLog: "Custom log: currentRetry: $1, maxRetries: $2, duration: $3")

var client = newHttpClient()

retry myPolicy:
  discard client.getContent("https://nim-lang.org")

Documents

https://fox0430.github.io/retry/retry.html

License

MIT license

About

A simple retry interface in Nim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages