FakeRiak.RiakPBC (fake_riak v0.2.1)

Copy Markdown View Source

The Protocol Buffers (PBC) side of the fake Riak endpoint.

Every message is framed as <<length::32-big, msg_code::8, payload>> where length counts the code byte plus the protobuf payload. Supported messages:

CodeRequestReply
1RpbPingReq2 RpbPingResp
7RpbGetServerInfoReq8 RpbGetServerInfoResp
9RpbGetReq10 RpbGetResp (empty when absent)
11RpbPutReq12 RpbPutResp
13RpbDelReq14 RpbDelResp (always succeeds)
255RpbStartTls255, then a TLS handshake

Any other code gets an RpbErrorResp (0) and the connection stays open. Objects are stored as their raw RpbContent.value in the same bucketed FakeRiak.SimpleStore space the HTTP API uses, so the two APIs see each other's writes. Vector clocks are a static opaque token (clients only ever echo them back) and siblings are never returned.

This module is not wired to a listener itself: FakeRiak.Riak detects PBC framing on the first byte of a connection and delegates here, passing its own dispatch state through untouched (requests are independent, so no state of our own is needed).

Summary

Functions

Wrap a message code and protobuf payload in a PBC frame.

Functions

frame(code, payload)

@spec frame(0..255, iodata()) :: binary()

Wrap a message code and protobuf payload in a PBC frame.