Protocol Buffers v3 binary wire codec (varint, zigzag, fixed32/64, length-delimited), homoiconic schema & .proto emitter, and gRPC framing.
Pure-Veko binary Protocol Buffers (proto3) wire codec, homoiconic schema DSL, .proto IDL generator, and gRPC over HTTP/2 service router (grpc_proto, grpc_proto/proto).
grpc_proto implements the binary Protocol Buffers wire format and gRPC Length-Prefixed-Message HTTP/2 transport framing in pure Veko with deterministic ORO single-owner memory and zero external C dependencies:
grpc_proto/proto:int64, uint64, int32, uint32, bool, enum), ZigZag signed integers (sint64, sint32), 64-bit little-endian (fixed64, sfixed64, IEEE-754 double), 32-bit little-endian (fixed32, sfixed32), length-delimited bytes/str/sub-messages, packed repeated scalar slices, and forward-compatible unknown-field skipping.pb/define-message) built over Veko quote [...] blocks with nested message composition (pb/with-subschema) and .proto file emission (pb/to-proto3-idl).grpc_proto:1B compressed_flag + 4B big-endian length + payload) with optional RFC 8878 Zstandard (compress/zstd) payload compression and multi-frame server-streaming buffers.0..16), grpc-timeout header parsing/formatting, percent-encoded grpc-message trailers, unary and server-streaming RPC service registry (new-server, register-unary, register-server-stream, dispatch-rpc), and a direct net/http2 handler/client adapter.veko pkg add grpc_proto@1.0.0Import the modules in .vk source files:
use [
grpc = grpc_proto
pb = grpc_proto/proto
]Each field on the wire begins with a base-128 LEB128 varint key encoding (field_number << 3) | wire_type:
| Wire Type | ID | Proto3 Types | Encoding |
|---|---|---|---|
WIRE-VARINT | 0 | int32, int64, uint32, uint64, sint32, sint64, bool, enum | Base-128 LEB128 (sint* uses (n << 1) ^ (n >> 63) ZigZag) |
WIRE-I64 | 1 | fixed64, sfixed64, double | 8-byte little-endian |
WIRE-LEN | 2 | string, bytes, nested message, packed repeated scalars | Varint byte length followed by raw payload bytes |
WIRE-I32 | 5 | fixed32, sfixed32 | 4-byte little-endian |
Per proto3 canonical rules, scalar fields equal to their type's zero value (0, 0.0, false, '', empty bytes) are omitted during serialization and restored as explicit defaults during pb/decode-msg. Packed repeated numeric fields serialize under a single WIRE-LEN span while pb/decode-msg accepts both packed (WIRE-LEN) and unpacked wire representations. Unknown field tags encountered on the wire are skipped cleanly via pb/skip-field.
Every gRPC request and response message on an HTTP/2 DATA stream uses a 5-byte prefix:
+--------------------+-------------------------------------------+--------------------+
| Compressed-Flag 1B | Message-Length 4B (uint32 big-endian) | Message Payload |
+--------------------+-------------------------------------------+--------------------+
| 0x00 or 0x01 | N bytes | Protobuf / Zstd |
+--------------------+-------------------------------------------+--------------------+Unary calls carry a single 5-byte-framed message; server-streaming responses concatenate zero or more 5-byte-framed messages followed by grpc-status and percent-encoded grpc-message HTTP/2 metadata.
grpc_proto/protoWIRE-VARINT, WIRE-I64, WIRE-LEN, WIRE-I32encode-tag [field_num i64, wire_type i64] i64push-tag [mut out bytes, field_num i64, wire_type i64] i64read-tag [buf bytes, off i64] WireTagpush-varint [mut out bytes, v i64] i64 / read-varint [buf bytes, off i64] bits/VarintValzigzag-encode [n i64] i64 / zigzag-decode [u i64] i64push-sint64 [mut out bytes, n i64] i64 / read-sint64 [buf bytes, off i64] bits/VarintValpush-fixed64 [mut out bytes, v i64] i64 / read-fixed64 [buf bytes, off i64] FixedI64Valpush-double [mut out bytes, x f64] i64 / read-double [buf bytes, off i64] FixedF64Valpush-fixed32 [mut out bytes, v i64] i64 / read-fixed32 [buf bytes, off i64] FixedI64Val / read-sfixed32 [buf bytes, off i64] FixedI64Valpush-len-bytes [mut out bytes, payload bytes] i64 / push-len-str [mut out bytes, s str] i64 / read-len-bytes [buf bytes, off i64] LenSliceencode-packed-varints [vals block] bytes / decode-packed-varints [payload bytes] block[i64]encode-packed-sint64s [vals block] bytes / decode-packed-sint64s [payload bytes] block[i64]skip-field [buf bytes, off i64, wire_type i64] i64define-message [name str, spec block] MessageSchemaregister-subschema [mut parent MessageSchema, child MessageSchema] enumwith-subschema [parent MessageSchema, child MessageSchema] MessageSchemawith-package [schema MessageSchema, pkg_name str] MessageSchemaencode-msg [schema MessageSchema, val map] bytesdecode-msg [schema MessageSchema, wire_bytes bytes] mapto-proto3-idl [schema MessageSchema] strgrpc_protoSTATUS-OK (0), STATUS-CANCELLED (1), STATUS-UNKNOWN (2), STATUS-INVALID-ARGUMENT (3), STATUS-DEADLINE-EXCEEDED (4), STATUS-NOT-FOUND (5), STATUS-ALREADY-EXISTS (6), STATUS-PERMISSION-DENIED (7), STATUS-RESOURCE-EXHAUSTED (8), STATUS-FAILED-PRECONDITION (9), STATUS-ABORTED (10), STATUS-OUT-OF-RANGE (11), STATUS-UNIMPLEMENTED (12), STATUS-INTERNAL (13), STATUS-UNAVAILABLE (14), STATUS-DATA-LOSS (15), STATUS-UNAUTHENTICATED (16), status-name [code i64] str, grpc-error [code i64, message str] GrpcStatusencode-frame [payload bytes /compressed flag bool = false /zstd use_zstd bool = false] bytesencode-stream-frames [payloads block[bytes] /compressed flag bool = false /zstd use_zstd bool = false] bytesdecode-frame-at [wire bytes, off i64 /zstd auto_zstd bool = true] FrameStepdecode-frames [wire bytes] block[GrpcFrame]parse-timeout-ns [spec str] i64 / format-timeout-ns [ns i64] strencode-grpc-message [msg str] str / decode-grpc-message [enc str] strnew-server [] GrpcServerregister-unary [mut srv GrpcServer, service str, method str, req_schema pb/MessageSchema, resp_schema pb/MessageSchema, handler fn[GrpcContext, map -> any]] enumregister-server-stream [mut srv GrpcServer, service str, method str, req_schema pb/MessageSchema, resp_schema pb/MessageSchema, handler fn[GrpcContext, map -> any]] enumdispatch-rpc [srv GrpcServer, path str, wire_body bytes, metadata map[str]] GrpcResponsebuild-request-body [req_schema pb/MessageSchema, req_map map /zstd use_zstd bool = false] bytesdecode-unary-response [resp GrpcResponse, resp_schema pb/MessageSchema] mapdecode-stream-response [resp GrpcResponse, resp_schema pb/MessageSchema] blockhttp2-handler [srv GrpcServer] fn[h2/Message -> h2/Message]from-http2-message [msg h2/Message] GrpcResponsehttp2-invoke [mut conn h2/H2Conn, authority str, service str, method str, req_schema pb/MessageSchema, req_map map, metadata map[str]] GrpcResponse.protouse [
grpc = grpc_proto
pb = grpc_proto/proto
]
telemetry_event = (pb/define-message 'TelemetryEvent' (quote [
1 trace_id str,
2 span_id i64,
3 latency_us sint64,
4 ok bool,
5 tags repeated str
])) \ pb/with-package 'veko.telemetry.v1'
wire = pb/encode-msg telemetry_event {
trace_id = '4bf92f3577b34da6'
span_id = 9001
latency_us = -350
ok = true
tags = ['edge' 'ca-west']
}
decoded = pb/decode-msg telemetry_event wire
print decoded.latency_us
print (pb/to-proto3-idl telemetry_event)use [
grpc = grpc_proto
pb = grpc_proto/proto
]
ping_req = pb/define-message 'PingReq' (quote [ 1 target str, 2 count i64 ])
ping_resp = pb/define-message 'PingResp' (quote [ 1 seq i64, 2 reply str ])
mut srv = grpc/new-server
_ = grpc/register-server-stream mut srv 'veko.net.Health' 'WatchPing' ping_req ping_resp fn [ctx, req] [
mut out = []
mut i = 0
while i < req.count [
push mut out { seq = i, reply = (str/join ['pong:' req.target] '') }
i = i + 1
]
out
]
req_body = grpc/build-request-body ping_req { target = 'node-a', count = 3 }
resp = grpc/dispatch-rpc srv '/veko.net.Health/WatchPing' req_body {}
items = grpc/decode-stream-response resp ping_resp
print (len items)https://veko-lang.org/pkg/grpc_proto/1.0.0.vkp01f021960ddbd7143cf6a3a3df721a15b6bee19cbb68ad0a6cea052081f1f79445135de8ec0e99de4d6486abb3880374d712fe3332ff5519d64db6048fbc013fed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70{"name":"grpc_proto","version":"1.0.0","tier":2.0,"tier_label":"Tier 2: Distributed & Wire Protocols","category":"Protobuf & HTTP/2 gRPC","description":"Protocol Buffers v3 binary wire codec (varint, zigzag, fixed32/64, length-delimited), homoiconic schema & .proto emitter, and gRPC framing.","modules":["grpc_proto","grpc_proto/proto"],"homepage":"https://veko-lang.org/packages/grpc_proto"}| Bundle Entry Path | Size | Leaf SHA-256 Digest |
|---|---|---|
| README.md | 8 KB | e086b1dc390b7bf22bd51446ea77cd9960101c6fa3cc101137a5509a5f678295 |
| examples/demo.vk | 6 KB | dc5409bab719c1585a91c591c4a09fbd664620f3843be6bb74288d8f83e313b6 |
| mod.vk | 17 KB | 633c86ddcea94dbc59e82a76676ea7ac6abcb1b075f6c85bfd1547ff7ac57e61 |
| proto.vk | 24 KB | 1fb2e782c47c35c93c5811781a4656144dd770ebfcbce955c3ccf415b7039d4d |