-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
zig-cache/ | ||
.zig-cache/ | ||
zig-out/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,32 @@ | ||
## :lizard: :raised_back_of_hand: **zig backoff** | ||
# zig-backoff | ||
|
||
[![CI][ci-shd]][ci-url] | ||
[![LC][lc-shd]][lc-url] | ||
|
||
### Zig implementation of the [exponential backoff algorithm](https://en.wikipedia.org/wiki/Exponential_backoff). | ||
### Zig implementation of [exponential backoff algorithm](https://en.wikipedia.org/wiki/Exponential_backoff). | ||
|
||
### :rocket: Usage | ||
|
||
1. Add `backoff` as a dependency in your `build.zig.zon`. | ||
- Add `backoff` dependency to `build.zig.zon`. | ||
|
||
<details> | ||
```sh | ||
zig fetch --save https://github.com/tensorush/zig-backoff/archive/<git_tag_or_commit_hash>.tar.gz | ||
``` | ||
|
||
<summary><code>build.zig.zon</code> example</summary> | ||
- Use `backoff` dependency in `build.zig`. | ||
|
||
```zig | ||
.{ | ||
.name = "<name_of_your_package>", | ||
.version = "<version_of_your_package>", | ||
.dependencies = .{ | ||
.backoff = .{ | ||
.url = "https://github.com/tensorush/zig-backoff/archive/<git_tag_or_commit_hash>.tar.gz", | ||
.hash = "<package_hash>", | ||
}, | ||
}, | ||
} | ||
``` | ||
|
||
Set `<package_hash>` to `12200000000000000000000000000000000000000000000000000000000000000000`, and Zig will provide the correct found value in an error message. | ||
|
||
</details> | ||
|
||
2. Add `backoff` as a module in your `build.zig`. | ||
|
||
<details> | ||
|
||
<summary><code>build.zig</code> example</summary> | ||
|
||
```zig | ||
const backoff = b.dependency("backoff", .{}); | ||
exe.addModule("Backoff", backoff.module("Backoff")); | ||
``` | ||
|
||
</details> | ||
```zig | ||
const backoff_dep = b.dependency("backoff", .{ | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
const backoff_mod = backoff_dep.module("Backoff"); | ||
<compile>.root_module.addImport("Backoff", backoff_mod); | ||
``` | ||
|
||
<!-- MARKDOWN LINKS --> | ||
|
||
[ci-shd]: https://img.shields.io/github/actions/workflow/status/tensorush/zig-backoff/ci.yaml?branch=main&style=for-the-badge&logo=github&label=CI&labelColor=black | ||
[ci-url]: https://github.com/tensorush/zig-backoff/blob/main/.github/workflows/ci.yaml | ||
[lc-shd]: https://img.shields.io/github/license/tensorush/zig-backoff.svg?style=for-the-badge&labelColor=black&kill_cache=1 | ||
[lc-url]: https://github.com/tensorush/zig-backoff/blob/main/LICENSE.md | ||
[lc-shd]: https://img.shields.io/github/license/tensorush/zig-backoff.svg?style=for-the-badge&labelColor=black | ||
[lc-url]: https://github.com/tensorush/zig-backoff/blob/main/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
.{ | ||
.name = "backoff", | ||
.version = "0.1.0", | ||
.paths = .{""}, | ||
.minimum_zig_version = "0.13.0", | ||
.paths = .{ | ||
"src/", | ||
"build.zig", | ||
"build.zig.zon", | ||
"LICENSE", | ||
"README.md", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters