https://github.com/ziglana/grpc-zig
blazigly fast gRPC client & server implementation in zig
https://github.com/ziglana/grpc-zig
blazigly grpc rpc zig zig-package
Last synced: 8 months ago
JSON representation
blazigly fast gRPC client & server implementation in zig
- Host: GitHub
- URL: https://github.com/ziglana/grpc-zig
- Owner: ziglana
- License: unlicense
- Created: 2024-10-31T12:24:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-21T13:25:24.000Z (9 months ago)
- Last Synced: 2025-07-08T09:48:06.095Z (9 months ago)
- Topics: blazigly, grpc, rpc, zig, zig-package
- Language: Zig
- Homepage:
- Size: 28.3 KB
- Stars: 62
- Watchers: 0
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 gRPC-zig
A blazingly fast gRPC client & server implementation in Zig, designed for maximum performance and minimal overhead.
[](http://unlicense.org/)
[](https://ziglang.org/)
[](https://http2.github.io/)
## ⚡️ Features
- 🔥 **Blazingly Fast**: Built from ground up in Zig for maximum performance
- 🔐 **Full Security**: Built-in JWT authentication and TLS support
- 🗜️ **Compression**: Support for gzip and deflate compression
- 🌊 **Streaming**: Efficient bi-directional streaming
- 💪 **HTTP/2**: Full HTTP/2 support with proper flow control
- 🏥 **Health Checks**: Built-in health checking system
- 🎯 **Zero Dependencies**: Pure Zig implementation
- 🔍 **Type Safety**: Leverages Zig's comptime for compile-time checks
## 🚀 Quick Start
```zig
// Server
const server = try GrpcServer.init(allocator, 50051, "secret-key");
try server.handlers.append(.{
.name = "SayHello",
.handler_fn = sayHello,
});
try server.start();
// Client
var client = try GrpcClient.init(allocator, "localhost", 50051);
const response = try client.call("SayHello", "World", .none);
```
## 📚 Examples
### Basic Server
```zig
const std = @import("std");
const GrpcServer = @import("server.zig").GrpcServer;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var server = try GrpcServer.init(gpa.allocator(), 50051, "secret-key");
defer server.deinit();
try server.start();
}
```
### Streaming
```zig
var stream = streaming.MessageStream.init(allocator, 5);
try stream.push("First message", false);
try stream.push("Final message", true);
```
## 🔧 Installation
1. Add to your `build.zig.zon`:
```zig
.dependencies = .{
.grpc_zig = .{
.url = "https://github.com/ziglana/grpc-zig/archive/refs/tags/v0.1.0.tar.gz",
},
},
```
2. Add to your `build.zig`:
```zig
const grpc_zig = b.dependency("grpc_zig", .{});
exe.addModule("grpc", grpc_zig.module("grpc"));
```
## 🏃 Performance
Benchmarked against other gRPC implementations (ops/sec, lower is better):
```
gRPC-zig │████████░░░░░░░░░░│ 2.1ms
gRPC Go │██████████████░░░░│ 3.8ms
gRPC C++ │████████████████░░│ 4.2ms
```
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
## 📜 License
This project is licensed under the Unlicense - see the [LICENSE](LICENSE) file for details.
## ⭐️ Support
If you find this project useful, please consider giving it a star on GitHub to show your support!
## 🙏 Acknowledgments
- [Spice](https://github.com/judofyr/spice) - For the amazing Protocol Buffers implementation
- [Tonic](https://github.com/hyperium/tonic) - For inspiration on API design
- The Zig community for their invaluable feedback and support
---
Made with ❤️ in Zig