firepear / petrel

It's like SQLite, but for networking
MIT License
20 stars 1 forks source link

Petrel

This module is pre-v1; breaking changes will be flagged in release notes

SQLite embeds serverless relational databases into programs. Petrel lets you do the same with networking and RPC.

See the Release notes for updates.

Build/test status GoReportCard link (client)

Contents

Server

Signal handling

Embedding a Petrel server in your code gets you handlers for SIGINT and SIGTERM, for free. At the moment, Petrel does not handle pidfiles.

Client

Wire protocol

The Petrel wire protocol has a fixed 10-byte header, two run-length encoded data segments, and an optional 44-byte HMAC segment.

Seqence number    uint32 (4 bytes)
Protocol version  uint8  (1 byte)
Request length    uint8  (1 byte)
Payload length    uint32 (4 bytes)
------------------------------------
Request text      Per request length
Payload text      Per payload length
------------------------------------
HMAC              44 bytes, optional

There is no need for messages to specify whether HMAC is included or not, as that is set between the client and server at connection time.