Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgv/roundrobin
https://github.com/dgv/roundrobin
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dgv/roundrobin
- Owner: dgv
- License: mit
- Created: 2024-06-06T02:46:28.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-20T01:52:39.000Z (6 months ago)
- Last Synced: 2024-07-21T04:29:36.783Z (5 months ago)
- Language: Zig
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# roundrobin
### usage
`zig fetch -save https://github.com/dgv/roundrobin/archive/refs/heads/main.zip````zig
const print = @import("std").debug.print;
const roundrobin = @import("roundrobin").RoundRobin;pub fn main() !void {
var ips = [_]std.net.Address{
try std.net.Address.parseIp("100.123.10.20", 0),
try std.net.Address.parseIp("100.123.20.30", 0),
try std.net.Address.parseIp("100.123.40.50", 0),
try std.net.Address.parseIp("100.123.60.70", 0),
};
const rr = try roundrobin.init(&ips);
_ = rr.next(); // "100.123.10.20:0"
_ = rr.next(); // "100.123.20.30:0"
_ = rr.next(); // "100.123.40.50:0"
_ = rr.next(); // "100.123.60.70:0"
_ = rr.next(); // "100.123.10.20:0"
print("{?}\n", .{rr.next()} ); // "100.123.20.30:0"
}
```