diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..dcc57b1
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,69 @@
+name: Docs
+
+# Render the AsciiDoc user guide and publish it to GitHub Pages.
+# The live site is served from whichever repo has Pages enabled:
+# - fork: https://rigazilla.github.io/cpp17-client/
+# - upstream: https://infinispan.github.io/cpp17-client/ (once a maintainer enables Pages)
+#
+# Builds run on every push/PR that touches the docs so breakage is caught early;
+# deployment happens only on push to `main`.
+
+on:
+ push:
+ branches: [ main ]
+ paths:
+ - 'documentation/**'
+ - 'scripts/build-docs.sh'
+ - '.github/workflows/docs.yml'
+ pull_request:
+ branches: [ main ]
+ paths:
+ - 'documentation/**'
+ - 'scripts/build-docs.sh'
+ - '.github/workflows/docs.yml'
+ workflow_dispatch:
+
+# Allow one concurrent deployment; cancel in-progress runs of this workflow.
+concurrency:
+ group: pages
+ cancel-in-progress: true
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: '3.3'
+
+ - name: Install asciidoctor
+ run: gem install asciidoctor --no-document
+
+ - name: Render user guide
+ run: ./scripts/build-docs.sh
+
+ - name: Upload Pages artifact
+ if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: documentation/_build
+
+ deploy:
+ # Only publish from main; PR builds above just verify the render succeeds.
+ if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ pages: write
+ id-token: write
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.gitignore b/.gitignore
index d502ca0..7e26df3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,18 @@
# Build directories
build/
+build-*/
+build.saved/
cmake-build-*/
out/
+# Rendered documentation (see scripts/build-docs.sh)
+documentation/_build/
+
+# Tooling output / local logs
+graphify-out/
+*.log
+ctest.log.txt
+
# IDE files
.vscode/
.idea/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3279232..eedf4b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -533,6 +533,26 @@ else()
message(WARNING "Google Test not found - tests disabled")
endif()
+# Documentation
+# `cmake --build
--target docs` renders the AsciiDoc user guide to
+# documentation/_build/index.html. It just wraps scripts/build-docs.sh (the
+# single source of truth, shared with CI), so it is a no-configure convenience,
+# not part of the default build. Needs asciidoctor on PATH.
+find_program(ASCIIDOCTOR_EXECUTABLE asciidoctor)
+if(ASCIIDOCTOR_EXECUTABLE)
+ add_custom_target(docs
+ COMMAND ${CMAKE_COMMAND} -E env bash
+ ${CMAKE_SOURCE_DIR}/scripts/build-docs.sh
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Rendering user guide to documentation/_build/index.html"
+ VERBATIM
+ USES_TERMINAL
+ )
+ message(STATUS "asciidoctor found - 'docs' target enabled")
+else()
+ message(STATUS "asciidoctor not found - 'docs' target disabled (gem install asciidoctor)")
+endif()
+
# Installation
install(TARGETS hotrod-client
EXPORT hotrod-client-targets
diff --git a/README.md b/README.md
index 669ac47..c7d6c7a 100644
--- a/README.md
+++ b/README.md
@@ -1,412 +1,278 @@
-# Infinispan Hot Rod Client - C++17
+# Infinispan Hot Rod Client โ C++17
-A cross-platform C++17 implementation of the Infinispan Hot Rod protocol client.
+A cross-platform C++17 client for [Infinispan](https://infinispan.org/) using the
+Hot Rod binary protocol (version 4.0/4.1). It is a smart client: it routes keys to
+their primary owner (hash-aware), fails over automatically, and exposes every
+operation as a `std::future`.
-๐ **Smart client** - hash-aware routing, automatic failover, full CRUD +
-metadata ops, typed error handling and user-decided retry (keyed & keyless),
-and SASL authentication (SCRAM-SHA-1/256/512, PLAIN, EXTERNAL, OAUTHBEARER).
-
-## Quick Start
-
-See the complete working example in [`examples/quickstart/`](examples/quickstart/):
+## Features
-```bash
-cd examples/quickstart
-./start-server.sh # Start Infinispan 16.2
-mkdir build && cd build
-cmake .. && make
-./quickstart # Run the example
-```
+- **Full CRUD** โ `PING`, `GET`, `PUT`, `REMOVE`.
+- **Metadata and version-based (CAS) operations** โ `getWithMetadata`,
+ `putIfAbsent`, `replace`, `containsKey`, `removeWithVersion`,
+ `replaceWithVersion`.
+- **Async API** โ every operation returns a `std::future`; operations on a server
+ share one multiplexed connection.
+- **Hash-aware routing and failover** โ consistent hashing (MurmurHash3 x64_32),
+ topology awareness, automatic failover, connection pooling.
+- **Multi-server seed list** โ all hosts in a URI become seeds with startup and
+ runtime failover.
+- **Hot Rod URI** โ build a configured client from a connection string
+ (`RemoteCache::fromUri`).
+- **Security** โ SASL authentication (SCRAM-SHA-1/256/512, PLAIN, EXTERNAL,
+ OAUTHBEARER) and TLS including mutual TLS (PEM material).
+- **Typed error handling** โ `HotRodClientException` with user-decided retry for
+ keyed and keyless operations.
-Example output:
-```
-=== Hot Rod C++ Client Quickstart ===
-Connecting to Infinispan server...
-Connected successfully!
+For live status and the backlog, see **[docs/STATUS.md](docs/STATUS.md)**.
---- PUT Operations ---
-PUT: greeting = Hello, Infinispan!
-PUT: language = C++17
-PUT: version = 1.0.0
+## Installation
---- GET Operations ---
-GET: greeting = Hello, Infinispan!
-GET: language = C++17
-GET: version = 1.0.0
+**Build requirements**
---- REMOVE Operations ---
-REMOVE: language deleted successfully
+- A C++17 compiler (GCC 7+, Clang 6+, MSVC 19.20+)
+- CMake 3.15+
+- OpenSSL 1.1.1+ or 3.x
+- Google Test (for the test suite)
-=== Quickstart Complete ===
-```
+**Runtime requirements**
-The quickstart demonstrates:
-- Connecting to Infinispan
-- PUT operations (storing key-value pairs)
-- GET operations (reading values)
-- REMOVE operations (deleting entries)
-- Clean disconnect
+- Infinispan Server 16.0+ (integration suites run against `:latest`)
+- Docker (for integration tests and the quickstart example)
-A second example, `retry.cpp`, demonstrates the user-decided retry loop
-(`cache.excluding(e)` on a caught `HotRodClientException`) for both keyed
-operations and keyless `ping`.
+Build the static library (`build/libhotrod-client.a`):
-See [`examples/quickstart/README.md`](examples/quickstart/README.md) for full documentation.
+```bash
+cmake -S . -B build
+cmake --build build
+```
-## Building
+Link against it by adding `include/` to your include path and linking
+`libhotrod-client.a` (and `pthread`). See
+[`examples/quickstart/CMakeLists.txt`](examples/quickstart/CMakeLists.txt) for a
+complete consumer.
-### Requirements
+## Quick Start
-**Build Requirements**:
-- **C++17** compatible compiler (GCC 7+, Clang 6+, MSVC 19.20+)
-- **CMake** 3.15+
-- **OpenSSL** 1.1.1+ or 3.x
-- **Google Test** (for testing)
+```cpp
+#include "hotrod/RemoteCache.h"
-**Runtime Requirements**:
-- Infinispan Server 16.0+ (all integration suites run against `:latest` โ
- currently 16.3; only the quickstart example pins 16.2)
-- Docker (for integration tests and quickstart example)
+using namespace hotrod;
-### Linux (Fedora/RHEL)
+int main() {
+ RemoteCache cache("localhost", 11222, "my-cache");
+ cache.setClientIntelligence(ClientIntelligence::HASH_DISTRIBUTION_AWARE);
+ cache.connect();
-```bash
-# Install dependencies
-sudo dnf install cmake gcc-c++ openssl-devel gtest-devel
+ ByteArray key{'k'};
+ ByteArray value{'v'};
-# Build
-mkdir build && cd build
-cmake ..
-make -j$(nproc)
+ cache.put(key, value).get(); // store
+ if (auto result = cache.get(key).get()) // std::optional
+ /* use *result */;
-# Run tests
-ctest --output-on-failure
+ cache.disconnect();
+}
```
-### Linux (Ubuntu/Debian)
+A complete, runnable example (with a server launcher) lives in
+[`examples/quickstart/`](examples/quickstart/):
```bash
-# Install dependencies
-sudo apt install cmake g++ libssl-dev libgtest-dev
-
-# Build
-mkdir build && cd build
-cmake ..
-make -j$(nproc)
-
-# Run tests
-ctest --output-on-failure
+cd examples/quickstart
+./start-server.sh # start Infinispan in a container
+cmake -S . -B build && cmake --build build
+./build/quickstart
```
-### Windows (PowerShell)
+Keys and values are `ByteArray` (`std::vector`); the caller marshals its
+own types. A second example, `retry.cpp`, demonstrates the user-decided retry loop.
-```powershell
-# Install dependencies via vcpkg
-vcpkg install openssl gtest
+## Connection URI
-# Build
-mkdir build
-cd build
-cmake .. -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake
-cmake --build . --config Release
+`RemoteCache::fromUri` builds a configured (not yet connected) client from a
+connection string. Because `RemoteCache` is non-movable, it returns a
+`std::unique_ptr`:
-# Run tests
-ctest -C Release --output-on-failure
+```cpp
+// hotrod[s]://[user:password@]host1[:port1][,host2[:port2]...][?key=value&...]
+auto cache = RemoteCache::fromUri(
+ "hotrod://user:password@node1:11222,node2:11222"
+ "?sasl_mechanism=SCRAM-SHA-256&client_intelligence=hash_distribution_aware",
+ "my-cache");
+cache->connect();
```
-## Testing
+All comma-separated hosts become seed servers. The `hotrods://` scheme enables
+TLS; credentials in the userinfo enable SASL. Userinfo and query values are
+percent-decoded (RFC 3986), so a reserved character in a password is written
+encoded (for example `p@ss` โ `admin:p%40ss@host`).
-### Unit Tests
-```bash
-cd build
-./unit_tests
+| Query key | Meaning |
+|---|---|
+| `client_intelligence` | `basic`, `topology_aware`, or `hash_distribution_aware` |
+| `protocol_version` | `4.0` or `4.1` |
+| `sasl_mechanism` | SASL mechanism name |
+| `token` | bearer token for `OAUTHBEARER` |
+| `ca_file`, `sni_host_name`, `ssl_hostname_validation` | TLS server trust |
+| `client_cert_file`, `client_key_file`, `client_key_password` | mutual-TLS client identity |
-# Or via CTest
-ctest -R UnitTests --output-on-failure
-```
+An unknown parameter, a bad value, or a Java keystore key is rejected. Connection
+timeouts, `protocol_version=AUTO`, and GSSAPI are not supported yet (issue #10).
-### Integration Tests
-Requires Docker to run Infinispan server:
-```bash
-cd build
-
-# Run all integration tests (starts server automatically) โ representative subset:
-./ping_integration_tests
-./get_integration_tests
-./put_integration_tests
-./remove_integration_tests
-./topology_integration_tests # Multi-node cluster tests
-./hash_aware_routing_integration_tests # Smart routing tests
-./retryview_integration_tests # User-decided retry (keyed)
-./pingretry_integration_tests # User-decided retry (keyless ping)
-
-# Or run all via CTest
-ctest --output-on-failure
-```
+## Options
-**Note**: Integration tests use Docker Compose to manage multi-node Infinispan clusters (up to 4 nodes). Tests verify failover, rebalancing, and hash-aware routing.
+Configure these on the `RemoteCache` before `connect()`:
-## Status
+| Setter | Purpose |
+|---|---|
+| `setClientIntelligence(...)` | cluster-awareness level (default from constructor) |
+| `setProtocolVersion(...)` | `Protocol::VERSION_40` / `VERSION_41` (default 4.1) |
+| `setAuthentication(...)` | SASL credentials or mechanism |
+| `setTls(...)` | TLS transport encryption (PEM material) |
+| `setProxyToNonOwner(bool)` | owner-to-non-owner routing fallback (default `true`) |
-> ๐ **Live status lives in [docs/STATUS.md](docs/STATUS.md)** โ start there after any break.
-> Design rationale is in [docs/DECISIONS.md](docs/DECISIONS.md).
+## Cache Operations
-**Current Progress**: Full CRUD (PING/GET/PUT/REMOVE) + SCRAM auth + topology
-awareness + hash-aware routing + async multiplexing + metadata/version-based
-operations (Step 10) + typed error handling and user-decided retry, keyed and
-keyless (Step 11) + Hot Rod URI support (`RemoteCache::fromUri`, issue #9) +
-multi-server seed list with startup/runtime failover (issue #12) โ all shipped.
-**Next:** bulk operations (Step 12) or multiplexing benchmarks. See
-[docs/STATUS.md](docs/STATUS.md) for live status.
-Per-step milestone history (frozen at Step 9) is archived at
-[docs/archive/PROGRESS.md](docs/archive/PROGRESS.md).
+Every operation is asynchronous; call `.get()` to wait.
-_(Step numbers follow [`../hotrod-foundry/ROADMAP.md`](../hotrod-foundry/ROADMAP.md);
-[`docs/STATUS.md`](docs/STATUS.md) is authoritative for which steps are done โ not
-any headline count.)_
+```cpp
+cache.put(key, value).get(); // store; optional lifespan/maxIdle (seconds)
+auto v = cache.get(key).get(); // std::optional
+auto prev = cache.remove(key).get(); // std::optional
+bool present = cache.containsKey(key).get();
+
+// Metadata + version-based CAS:
+if (auto entry = cache.getWithMetadata(key).get()) {
+ int64_t version = entry->metadata.version;
+ bool replaced = cache.replaceWithVersion(key, newValue, version).get();
+}
+```
-**Test Results** โ unit and integration suites all pass (integration against live
-Infinispan via Docker). See [`docs/STATUS.md`](docs/STATUS.md) for the current
-coverage breakdown and counts.
+Pass `previousValue = true` to `put`/`putIfAbsent`/`replace`/`remove` to receive
+the prior entry. See the
+[Cache Operations guide](documentation/topics/cache-operations.adoc).
-## Features
+## Security
-### Implemented โ
-- โ **Cross-platform support** (Linux + Windows)
-- โ **Wire format primitives** (vInt, vLong, strings, byte arrays)
-- โ **Protocol 4.0 headers** (complete spec with all conditional fields)
-- โ **Client Intelligence 0x03** (HASH_DISTRIBUTION_AWARE)
-- โ **Hash-aware routing** (keys route directly to primary owner)
-- โ **Automatic failover** (primary โ backup owners โ any server)
-- โ **Topology awareness** (cluster rebalancing, updates)
-- โ **Consistent hashing** (MurmurHash3 x64_32, segment-based routing)
-- โ **Connection pooling** (one connection per server)
-- โ **Multiplexed connections** (concurrent async operations on single connection per server)
-- โ **Async operations** (all operations return `std::future` for non-blocking execution)
-- โ **PING operation** (server connectivity check)
-- โ **GET operation** (read from cache with failover)
-- โ **PUT operation** (write to cache with lifespan/maxIdle)
-- โ **REMOVE operation** (delete from cache)
-- โ **Metadata / version-based operations** (`getWithMetadata`, `putIfAbsent`,
- `replace`, `containsKey`, `removeWithVersion`, `replaceWithVersion`) (Step 10)
-- โ **Typed error handling** (`HotRodClientException` with phase / server status /
- tried nodes) + `isTransient` / `outcomeUncertain` classification (Step 11a)
-- โ **User-decided retry** (`cache.excluding(e)` bound view) for keyed ops and
- keyless `ping`, with automatic before-send failover (Step 11b/11c)
-- โ **SASL authentication** (`setAuthentication(...)`) โ end-to-end, applied to
- every connection: SCRAM family (`SCRAM-SHA-1`/`-256`/`-512`), **PLAIN**,
- **EXTERNAL** (identity from the mutual-TLS client cert), and **OAUTHBEARER**
- (bearer `token`). GSSAPI/DIGEST-MD5 throw at connect(). See
- [`documentation/topics/security.adoc`](documentation/topics/security.adoc)
-- โ **Hot Rod URI** (`RemoteCache::fromUri("hotrod[s]://...")`) โ build a client from
- a connection string (hosts, credentials, `sasl_mechanism`/`client_intelligence`/
- `protocol_version` params, and the server-auth TLS params below); timeouts and more
- in issue #10
-- โ **TLS, incl. mutual TLS** (`setTls(...)` / `hotrods://`, issue #18) โ wraps
- every connection in a TLS session (OpenSSL); PEM material only. Server-auth: PEM
- trust (`ca_file`, empty = system store), SNI, host-name validation (default on),
- min TLS 1.2. Mutual TLS: PEM client cert + key. URI keys: `ca_file`,
- `sni_host_name`, `ssl_hostname_validation`, `client_cert_file`, `client_key_file`,
- `client_key_password`. Java keystore keys (`*_store_file_name`/`*_store_type`/โฆ)
- are rejected with a pointer to the PEM key; JKS/PKCS12 and cipher tuning deferred
- (issue #10)
-- โ **Multi-server seed list** (issue #12) โ all hosts in the URI become seed
- servers with startup *and* runtime failover (ops fall back to the seed list when
- the connected server dies or no topology is known, e.g. in BASIC mode)
-- โ **Integration test framework** (GoogleTest + Docker + multi-node clusters)
-
-### Full CRUD with Smart Routing and Async Operations
```cpp
-// Connect with hash-aware routing
-RemoteCache cache("localhost", 11222, "my-cache");
-cache.setClientIntelligence(ClientIntelligence::HASH_DISTRIBUTION_AWARE);
-cache.connect();
-
-// All operations are async (return std::future) and can run concurrently
-// Multiple operations share a single multiplexed connection per server
+// SASL (defaults to SCRAM-SHA-256):
+cache.setAuthentication("username", "password");
-// CREATE/UPDATE - routes to primary owner
-auto putFuture = cache.put(key, value, lifespan, maxIdle);
+// TLS (empty ca_file = system trust store):
+cache.setTls("/etc/pki/ca.pem");
+```
-// READ - automatic failover to backup if primary fails
-auto getFuture = cache.get(key);
+All certificate material is PEM (not Java JKS/PKCS12). Mutual TLS and the
+`EXTERNAL`/`OAUTHBEARER` mechanisms are configured through `TlsConfig` and
+`Authentication`. See the
+[Security guide](documentation/topics/security.adoc) for the full details.
-// DELETE - with automatic failover
-auto removeFuture = cache.remove(key);
+## Error Handling and Retry
-// PING
-auto pingFuture = cache.ping();
+Failures surface as `HotRodClientException` (a `std::runtime_error`) from
+`future.get()`. Retry is user-decided: catch the exception, classify it, and feed
+it back as the exclusion set for the next attempt.
-// Wait for results when needed
-auto result = getFuture.get(); // blocks until complete
-if (result.has_value()) {
- ByteArray value = result.value();
+```cpp
+try {
+ cache.put(key, value).get();
+} catch (const HotRodClientException& e) {
+ if (isTransient(e)) cache.excluding(e).put(key, value).get();
+ else throw;
}
+```
-// Or fire-and-forget for max throughput
-for (int i = 0; i < 1000; i++) {
- cache.put(keys[i], values[i]); // returns immediately, executes concurrently
-}
+See the [Error Handling guide](documentation/topics/error-handling-and-retry.adoc)
+and `examples/quickstart/retry.cpp`.
+
+## Building
+
+### Linux (Fedora/RHEL)
+
+```bash
+sudo dnf install cmake gcc-c++ openssl-devel gtest-devel
+cmake -S . -B build && cmake --build build -j$(nproc)
+ctest --test-dir build --output-on-failure
```
-### Connect from a Hot Rod URI
-```cpp
-// hotrod://[user:password@]host1[:port1][,host2[:port2]...][?k=v&...]
-// Returns a configured, not-yet-connected client (RemoteCache owns a mutex, so
-// it is non-movable โ unique_ptr). Call connect() yourself.
-auto cache = RemoteCache::fromUri(
- "hotrod://user:pass@node1:11222,node2:11222"
- "?sasl_mechanism=SCRAM-SHA-256&client_intelligence=hash_distribution_aware",
- "my-cache");
-cache->connect();
+### Linux (Ubuntu/Debian)
-// Supports hotrod:// and hotrods:// (TLS). All hosts become seed servers (issue
-// #12): connect() tries each in order, and ops fall back to the seed list when the
-// connected server dies or no topology is known (e.g. BASIC mode). Credentials
-// enable SCRAM by default; sasl_mechanism (SCRAM*/PLAIN/EXTERNAL/OAUTHBEARER, with
-// token for OAUTHBEARER) / client_intelligence / protocol_version (Java "4.0"/"4.1"
-// form) are honoured. hotrods:// enables TLS (PEM material only); the
-// ca_file (PEM CA) / sni_host_name / ssl_hostname_validation params and the mutual-
-// TLS client_cert_file / client_key_file / client_key_password params map to
-// setTls(...). The Java keystore keys (trust_store_file_name, key_store_*, โฆ) are
-// rejected with a pointer to the PEM key. Userinfo and query values are percent-
-// decoded (RFC 3986), so a reserved character in a password is written encoded โ
-// e.g. a password of p@ss is "...://admin:p%40ss@host". Timeouts and other
-// parameters throw for now (see issue #10).
-//
-// // Server-auth TLS from a URI (private CA):
-// auto c = RemoteCache::fromUri("hotrods://cache:11222?ca_file=/etc/pki/ca.pem");
-// // Mutual TLS (client cert + key):
-// auto m = RemoteCache::fromUri("hotrods://cache:11222?ca_file=/etc/pki/ca.pem"
-// "&client_cert_file=/etc/pki/client.pem"
-// "&client_key_file=/etc/pki/client-key.pem");
-// // or programmatically:
-// RemoteCache cache("cache", 11222);
-// cache.setTls("/etc/pki/ca.pem"); // ca_file; empty = system trust store
-// cache.connect();
+```bash
+sudo apt install cmake g++ libssl-dev libgtest-dev
+cmake -S . -B build && cmake --build build -j$(nproc)
+ctest --test-dir build --output-on-failure
```
-### Future
+### Windows (PowerShell)
-> ๐ **The full, authoritative backlog lives in
-> [docs/STATUS.md โ ๐ Backlog](docs/STATUS.md#-backlog-the-whole-list)**, and
-> the 1โ3 immediate items in
-> [โญ Next steps](docs/STATUS.md#-next-steps-start-here). This is just a summary.
+```powershell
+vcpkg install openssl gtest
+cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake
+cmake --build build --config Release
+ctest --test-dir build -C Release --output-on-failure
+```
-- โ **Step 10 โ Metadata / version-based operations** (shipped): `getWithMetadata`,
- `replaceWithVersion`, `removeWithVersion`, `putIfAbsent`, `replace`, `containsKey`
-- โ **Step 11 โ Error handling** (shipped): ERROR response parsing, typed exception,
- user-decided retry (keyed + keyless)
-- โ **TLS, incl. mutual TLS** (shipped, issue #18): `hotrods://` + `setTls(...)`, PEM only
-- **Step 12 โ Bulk operations** (next): `GET_ALL`, `PUT_ALL`, `BULK_GET`
-- Also: multiplexing benchmarks, GSSAPI SASL (Kerberos) + PKCS12/JKS keystores (issue #10)
+## Testing
-## Project Structure
+```bash
+# Unit tests (fast, no server):
+./build/unit_tests
-```
-cpp17-client/
-โโโ CMakeLists.txt # Build configuration
-โโโ README.md # This file
-โโโ LICENSE # Apache 2.0
-โโโ include/hotrod/ # Public API headers
-โ โโโ Types.h # Type definitions
-โ โโโ Codec.h # Wire format primitives
-โ โโโ HeaderCodec.h # Protocol 4.0 headers
-โ โโโ Connection.h # TCP connection
-โ โโโ RemoteCache.h # High-level API (with hash-aware routing)
-โ โโโ TopologyInfo.h # Cluster tracking
-โ โโโ ConsistentHash.h # Smart routing
-โ โโโ MurmurHash3.h # Hash function
-โโโ src/ # Implementation
-โ โโโ codec/ # Encoding/decoding
-โ โโโ transport/ # Network I/O
-โ โโโ topology/ # Cluster tracking
-โ โโโ hash/ # MurmurHash3 + consistent hashing
-โ โโโ operations/ # Hot Rod operations (with failover)
-โโโ tests/ # Test suite
-โ โโโ unit/ # unit tests (gtest)
-โ โโโ integration/ # integration tests (multi-node clusters, Docker)
-โโโ documentation/ # AsciiDoc user guide (index.adoc + topics/)
-โโโ examples/ # Usage examples
-โ โโโ quickstart/ # Simple GET/PUT/REMOVE + retry + auth examples
-โโโ scripts/ # Test infrastructure
-โ โโโ start_cluster.sh # Start multi-node cluster
-โ โโโ add_cluster_node.sh # Add node dynamically
-โ โโโ remove_cluster_node.sh # Remove node for failover tests
-โโโ test-configs/ # Server configurations
- โโโ docker-compose-cluster.yml # Multi-node setup
- โโโ infinispan-cluster.xml # No-auth config
+# Integration tests (require Docker; start Infinispan automatically):
+ctest --test-dir build --output-on-failure
```
-## Development
+Integration tests use Docker Compose to manage multi-node Infinispan clusters and
+verify failover, rebalancing, and hash-aware routing. See
+[docs/STATUS.md](docs/STATUS.md) for the current coverage breakdown.
-> ๐ **Working on this project?** Read [docs/WORKFLOW.md](docs/WORKFLOW.md) โ the
-> per-session workflow (how to re-orient after a break, what to update before you
-> stop, and which protocol sources are authoritative). It's built for
-> intermittent, solo work.
+## Documentation
-This implementation follows the **hotrod-foundry** incremental approach:
+The user guide lives in [`documentation/`](documentation/) (AsciiDoc). Render it
+to self-contained HTML with:
-1. **Test-driven development** - Test vectors โ Unit tests โ Implementation
-2. **Java reference** - Study Java implementation for each step (MANDATORY) โ it is the authoritative source for **behavior and semantics** (what each op does, statuses, edge cases)
-3. **Byte-level validation** - Compare with test vectors and the Kaitai wire-format schema (authoritative for **byte layout**); if the two disagree, stop and investigate
-4. **Cross-platform** - Linux + Windows support required
-5. **Infrastructure-first** - Steps 0-5 (foundation), then operations
+```bash
+./scripts/build-docs.sh # โ documentation/_build/index.html
+./scripts/build-docs.sh --serve # render + serve at http://localhost:8000
+./scripts/build-docs.sh --watch # rebuild on save (needs entr)
+# or, via CMake:
+cmake --build build --target docs
+```
-### Roadmap
+On push to `main` the guide is published to GitHub Pages by
+[`.github/workflows/docs.yml`](.github/workflows/docs.yml).
-See [hotrod-foundry/ROADMAP.md](../hotrod-foundry/ROADMAP.md) for the complete step-by-step plan.
+## Project Structure
-### Java Reference
+```
+cpp17-client/
+โโโ CMakeLists.txt # Build configuration (library, tests, docs target)
+โโโ include/hotrod/ # Public API headers (RemoteCache.h, HotRodURI.h, ...)
+โโโ src/ # Implementation (codec, transport, topology, hash, operations, auth)
+โโโ tests/ # unit/ (gtest) and integration/ (Docker, multi-node clusters)
+โโโ documentation/ # AsciiDoc user guide (index.adoc + topics/)
+โโโ examples/quickstart/ # GET/PUT/REMOVE + retry + auth examples
+โโโ scripts/ # build-docs.sh + test cluster infrastructure
+โโโ test-configs/ # Server configurations (compose + XML)
+โโโ docs/ # STATUS.md, DECISIONS.md, WORKFLOW.md
+```
-The **authoritative source for protocol behavior and semantics** โ study it
-first for each step (see workflow above).
+## Status and Contributing
-- Local: `/home/rigazilla/git/infinispan/client/hotrod-client/`
-- Public: https://github.com/infinispan/infinispan/tree/main/client/hotrod-client
+Live status is in **[docs/STATUS.md](docs/STATUS.md)**; design rationale and dated
+history are in **[docs/DECISIONS.md](docs/DECISIONS.md)**. If you are picking this
+up after a break, start with **[docs/WORKFLOW.md](docs/WORKFLOW.md)** โ the
+per-session workflow built for intermittent, solo work. When you change project
+source, update `docs/STATUS.md` in the same commit (a pre-commit hook enforces it).
## References
- **Infinispan Project**: https://infinispan.org/
-- **Hot Rod Foundry**: ../hotrod-foundry/
-- **Java Client Source** (authoritative for behavior/semantics): local `/home/rigazilla/git/infinispan/client/hotrod-client/` ยท public https://github.com/infinispan/infinispan/tree/main/client/hotrod-client
-- **Protocol Specification**: https://infinispan.org/docs/stable/titles/hotrod_protocol/
-- **Wire-format schema (Kaitai, protocol 4.0/4.1)**: https://github.com/rigazilla/hotrod-dissector/tree/main/schemas โ an independent, machine-readable encoding of the protocol; use it to double-check byte layouts against the Java client.
+- **Java client source** (authoritative for behavior/semantics): https://github.com/infinispan/infinispan/tree/main/client/hotrod-client
+- **Protocol specification**: https://infinispan.org/docs/stable/titles/hotrod_protocol/
+- **Wire-format schema** (Kaitai, protocol 4.0/4.1): https://github.com/rigazilla/hotrod-dissector/tree/main/schemas
## License
-Apache 2.0 (matching Infinispan project)
-
-## Contributing
-
-**Start with [docs/WORKFLOW.md](docs/WORKFLOW.md)** โ the per-session workflow.
-In short, following the hotrod-foundry porting guidelines:
-- One step at a time (complete step N before step N+1)
-- Update [docs/STATUS.md](docs/STATUS.md) before you stop each session (next steps + date)
-- Log design decisions in [docs/DECISIONS.md](docs/DECISIONS.md) as you make them
-- Validate against test vectors
-- Ensure cross-platform compatibility
-
-## Implementation Milestones
-
-- โ **v0.1.0** (2026-06-11): Foundation complete (Steps 0-5)
-- โ **v0.2.0** (2026-06-12): PING operation complete (Step 6)
-- โ **v0.3.0** (2026-06-12): GET operation complete (Step 7)
-- โ **v0.4.0** (2026-06-12): PUT operation complete (Step 8)
-- โ **v0.5.0** (2026-06-12): REMOVE operation complete (Step 9) - **Full CRUD!**
-- โ **v0.6.0** (2026-06-17): Topology awareness (Step 4)
-- โ **v0.7.0** (2026-06-17): Hash-aware routing with failover - **Smart Client!**
-- โ **v0.8.0** (2026-09-20): Metadata / version-based operations (Step 10)
-- โ **v0.9.0** (2026-09-25): Typed error handling + user-decided retry, keyed &
- keyless (Step 11)
-- โ **2026-10** (issue-based): Hot Rod URI `fromUri` (#9) + multi-server seed list
- with startup/runtime failover (#12)
-- ๐ฏ **v0.10.0** (upcoming): Bulk operations (Step 12)
-
----
-
-**Maintained by**: rigazilla
-**Status**: Active development
-**Current Step**: Step 11 (error handling + user-decided retry, keyed & keyless)
-complete; since then Hot Rod URI `fromUri` (#9) and multi-server seed list +
-failover (#12) shipped. Next: bulk operations (Step 12). โ
+Apache 2.0 (matching the Infinispan project).
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index ab96da6..f011e42 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -1423,3 +1423,44 @@ identity (`client.pem`/`client.key`) and the server truststore bundle
**Deferred:** OAUTHBEARER integration (needs a token issuer/realm โ Keycloak or a
static-JWT public key + pre-minted token); it remains unit-only. See STATUS backlog.
+
+## 2026-12-02 โ Docs: mirror the Go single-book layout + publish to GitHub Pages (issue #26)
+
+**Decision:** Align the user guide and README with the sibling Hot Rod clients by
+mirroring the **Go** client's documentation model, and publish the rendered guide
+to **GitHub Pages**. Document **shipped features only** (per AGENTS.md: STATUS.md
+is authoritative; no stubs for unshipped features). This commit lands the
+*infrastructure* only (phase 1 of 3):
+- `scripts/build-docs.sh` โ the single source of truth for rendering: runs
+ `asciidoctor` to `documentation/_build/index.html`, copies `css/`/`js/` when
+ present, and offers `--serve` (python http.server) / `--watch` (entr) for a
+ local edit loop. Works from a fresh clone with no CMake configure.
+- CMake `docs` target wrapping the script (`cmake --build --target docs`),
+ gated on `find_program(asciidoctor)` so it is a no-op when asciidoctor is absent.
+- `.github/workflows/docs.yml` โ renders on every push/PR touching the docs
+ (catches breakage early) and deploys to Pages only on push to `main`, via
+ `actions/upload-pages-artifact` + `actions/deploy-pages`.
+
+**Why Go, not Java:** the C++ docs are *already* the Go single-book layout
+(`index.adoc` + flat `topics/`, same filenames for the six shared topics), so
+convergence is polish + content, not a restructure. The Java guide uses a heavier
+three-tier `titles/`โ`stories/`โ`proc_/con_/ref_ topics/` structure built for
+monorepo reuse โ a poor fit for a standalone repo.
+
+**Why Pages (vs Go's approach):** the Go client only attaches a `docs.zip` to
+releases and relies on infinispan.org for a browsable page โ there is no live
+GitHub-hosted HTML. Pages gives a always-current browsable URL
+(`https://.github.io/cpp17-client/`), strictly better for a standalone
+repo. Enable Pages on the `rigazilla` fork for an immediate preview; the same
+workflow serves upstream once a maintainer enables Pages there.
+
+**Alternatives considered:** release-zip only (Go parity, but no live page โ
+rejected); Doxygen API reference alongside the guide (deferred to a follow-up to
+keep this focused); Java three-tier layout (rejected, see above).
+
+**Shared build command (CI == local):** both the `docs` target and the workflow
+call `scripts/build-docs.sh`, so "renders locally" means "renders on Pages".
+
+**Remaining (phases 2โ3, tracked in #26):** adopt the Go conventions
+(`:brandname:`, docinfo jsTree TOC, `AI-CODE.md`, `[source,cpp]`), reorder
+chapters to Go order, flesh out the stub topics, and restructure `README.md`.
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 92cd82f..f12c711 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -4,7 +4,7 @@
> If any other doc disagrees with this file, this file wins. Point-in-time
> snapshots live in [`archive/`](archive/) and are historical only.
>
-> **Last updated:** 2026-11-13
+> **Last updated:** 2026-12-02
---
@@ -41,6 +41,8 @@ _The 1โ3 concrete things to do next. Keep this short and current._
(two `TODO`s in `src/operations/RemoteCache.cpp`).
_Recently shipped (detail in "Working and shipped" + [`DECISIONS.md`](DECISIONS.md)):
+Docs aligned with the Go/Java clients (#26) โ Go single-book layout, local render
++ GitHub Pages, all topic chapters fleshed out, README restructured (2026-12-02);
Docker integration coverage for mutual TLS + SASL PLAIN + SASL EXTERNAL
(2026-11-13), non-SCRAM SASL (PLAIN/EXTERNAL/OAUTHBEARER) (#10, 2026-11-12), mutual TLS (PEM
client cert/key) + PEM-honest TLS URI keys (`ca_file`,
@@ -242,6 +244,7 @@ full list (Steps 10โ12, benchmarks, TLS, code TODOs).
| Hot Rod URI parser | `include/hotrod/HotRodURI.h` (pure); factory `RemoteCache::fromUri` |
| Authentication (SASL/SCRAM) | `include/hotrod/Authentication.h`, `AuthCodec.h`, `SaslAuthenticator.h`; `src/auth/SaslAuthenticator.cpp`, `SCRAM.cpp` |
| User guide (AsciiDoc) | `documentation/index.adoc` + `documentation/topics/` |
+| Render the user guide | `scripts/build-docs.sh` (also `cmake --build --target docs`); `--serve`/`--watch` for a local loop. Published to GitHub Pages by `.github/workflows/docs.yml` |
| Retry API (bound view) | `include/hotrod/RetryView.h`, `RetryContext.h`; routing helpers in `ServerSelection.h` |
| Async transport core | `src/transport/MultiplexedConnection.cpp` |
| Operations (CRUD, metadata/CAS, ping) | `src/operations/RemoteCache.cpp` |
diff --git a/documentation/AI-CODE.md b/documentation/AI-CODE.md
new file mode 100644
index 0000000..49663d8
--- /dev/null
+++ b/documentation/AI-CODE.md
@@ -0,0 +1,83 @@
+# Documentation Instructions
+
+These conventions keep the C++17 client user guide consistent with the sibling
+Infinispan Hot Rod clients (Go, Java). They are adapted from the Go client's
+`documentation/AI-CODE.md`.
+
+## Content Organization
+
+Documentation is written in AsciiDoc in the `documentation/` directory, as a
+single book:
+
+- **`index.adoc`** โ the master/book file. Sets attributes (`:brandname:`, TOC,
+ highlight.js, docinfo) and pulls in each chapter with `include::topics/*.adoc`.
+ The include order *is* the book order.
+- **`topics/*.adoc`** โ one headless fragment per chapter (starts at `==`, no
+ document title or attributes of its own; it renders only via `index.adoc`).
+- **`docinfo/`, `css/`, `js/`** โ the jsTree collapsible-TOC assets injected via
+ `:docinfo: shared-head`.
+
+Render locally with `scripts/build-docs.sh` (or `cmake --build --target
+docs`); see the repository `README.md`.
+
+## Scope: document shipped features only
+
+`docs/STATUS.md` is the single source of truth for what has shipped. Do **not**
+document a feature the client does not implement yet, and do not leave misleading
+stubs. Add a chapter when its feature lands. Chapters that exist in the Go/Java
+guides but not here yet (near caching, listeners, queries, transactions,
+counters, multimap, typed caches/marshalling, bulk operations, cache
+administration) are deferred, tracked in the STATUS.md backlog.
+
+## Writing Style
+
+### Voice and Tense
+- **Active voice**, present tense, second person ("you").
+- Never use first person ("we", "I").
+- No contractions ("do not", not "don't").
+- American English spelling.
+
+### Formatting
+- One sentence per line (hard wrap at sentence boundaries, not at column width).
+- File paths, function names, type names, and class names: backticks (`` ` ``).
+- Numbers below 10: spell out ("four"); 10 and above: numerals ("12").
+- Avoid Latin abbreviations (use "for example" not "e.g.", "that is" not "i.e.").
+- Use the `{brandname}` attribute in prose and headings instead of writing
+ "Infinispan" literally.
+
+### Code Blocks
+Use `[source,cpp]` for C++ examples and `[source,shell]` for CLI commands:
+
+```asciidoc
+[source,cpp]
+----
+auto cache = RemoteCache::fromUri("hotrod://admin:password@localhost:11222");
+cache.connect();
+----
+```
+
+### Admonitions
+```asciidoc
+[NOTE]
+====
+Note content.
+====
+```
+Use `NOTE`, `TIP`, `WARNING`, `IMPORTANT` as appropriate.
+
+## Terminology
+
+- **Cache** โ the remote data structure; do not use "map" or "store" interchangeably.
+- **Hot Rod** โ two words, both capitalized; the binary protocol name.
+- **SASL** โ the authentication framework; mechanism names are uppercase
+ (`SCRAM-SHA-256`, `PLAIN`, `EXTERNAL`, `OAUTHBEARER`).
+- **TLS** / **mutual TLS** โ not "SSL"; certificate material is PEM.
+- **Put/Get/Remove** โ use these verbs consistently for cache operations.
+
+## When Creating New Documentation
+1. Confirm the feature has shipped (`docs/STATUS.md`); if not, do not document it.
+2. Add a chapter as a new `topics/.adoc` fragment and wire it into
+ `index.adoc` at the position matching the Go client's chapter order.
+3. Include working C++ code examples drawn from `examples/` or the public API in
+ `include/hotrod/`.
+4. Mark any intentionally incomplete section with a `// TODO:` comment.
diff --git a/documentation/css/toc.css b/documentation/css/toc.css
new file mode 100644
index 0000000..6ecdf57
--- /dev/null
+++ b/documentation/css/toc.css
@@ -0,0 +1,35 @@
+#tocheader {
+ text-align: center;
+ padding: 0.5em 0;
+ margin-bottom: 0.5em;
+}
+#tocheader img {
+ max-width: 80%;
+ height: auto;
+}
+#toc {
+ overflow-x: hidden;
+}
+#tocsearch {
+ font-family: 'FontAwesome';
+ width: 80%;
+}
+#toctreecollapse, #toctreeexpand {
+ padding: 0 0.3em;
+}
+#toctree {
+ font-size: 0.9em;
+}
+.jstree-children {
+ padding-left: 0;
+}
+.jstree-default .jstree-node {
+ margin-left: 0;
+}
+.jstree-anchor {
+ white-space: normal;
+}
+.jstree-default .jstree-anchor,
+.jstree-default-small .jstree-anchor {
+ height: auto;
+}
diff --git a/documentation/docinfo/docinfo.html b/documentation/docinfo/docinfo.html
new file mode 100644
index 0000000..ef08f01
--- /dev/null
+++ b/documentation/docinfo/docinfo.html
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/documentation/index.adoc b/documentation/index.adoc
index f48cb59..8775916 100644
--- a/documentation/index.adoc
+++ b/documentation/index.adoc
@@ -1,8 +1,15 @@
-= Infinispan Hot Rod C++17 Client Guide
+:brandname: Infinispan
+
+= {brandname} Hot Rod C++17 Client Guide
:toc: left
:toclevels: 3
+:source-highlighter: highlight.js
+:highlightjs-theme: github
+:icons: font
+:docinfo: shared-head
+:docinfodir: docinfo
-This guide covers the Infinispan Hot Rod C++17 client for the Hot Rod binary
+This guide covers the {brandname} Hot Rod C++17 client for the Hot Rod binary
protocol. The client speaks protocol 4.0/4.1, routes keys to their primary owner
(hash-aware), fails over automatically, and exposes every operation as a
`std::future`.
@@ -17,10 +24,10 @@ include::topics/connecting.adoc[]
include::topics/security.adoc[]
-include::topics/cache-operations.adoc[]
-
include::topics/client-intelligence.adoc[]
+include::topics/cache-operations.adoc[]
+
include::topics/error-handling-and-retry.adoc[]
include::topics/building-and-testing.adoc[]
diff --git a/documentation/js/toc.js b/documentation/js/toc.js
new file mode 100644
index 0000000..80adae8
--- /dev/null
+++ b/documentation/js/toc.js
@@ -0,0 +1,25 @@
+$(document).ready(function() {
+ $('#toctitle').before('
');
+ $('ul.sectlevel1').wrap('');
+ var toctree = $('#toctree');
+ toctree.jstree({
+ "core" : {
+ "themes" : {"variant" : "small", "icons" : false}
+ },
+ "plugins" : [ "search", "wholerow", "state" ]
+ }).on("activate_node.jstree", function (e, data) {
+ location.href = data.node.a_attr.href;
+ });
+ toctree.before('');
+ var searchTimeout = false;
+ var tocsearch = $('#tocsearch');
+ tocsearch.keyup(function () {
+ if (searchTimeout) { clearTimeout(searchTimeout); }
+ searchTimeout = setTimeout(function () {
+ toctree.jstree(true).search(tocsearch.val());
+ }, 250);
+ });
+ tocsearch.after('');
+ $('#toctreeexpand').click(function() { toctree.jstree('open_all'); });
+ $('#toctreecollapse').click(function() { toctree.jstree('close_all'); });
+});
diff --git a/documentation/topics/cache-operations.adoc b/documentation/topics/cache-operations.adoc
index 7f78330..8171c83 100644
--- a/documentation/topics/cache-operations.adoc
+++ b/documentation/topics/cache-operations.adoc
@@ -1,25 +1,92 @@
== Cache Operations
-NOTE: This chapter is a stub. See `include/hotrod/RemoteCache.h` for the full,
-current operation set.
-
Keys and values are `ByteArray`. Every operation is asynchronous and returns a
-`std::future`.
+`std::future`; call `.get()` to wait for the result. A failed operation throws a
+`HotRodClientException` from `.get()` (see
+xref:_error_handling_and_retry[Error Handling and Retry]).
=== Basic operations
[source,cpp]
----
-cache.put(key, value).get(); // store
+cache.put(key, value).get(); // store (returns previous entry if requested)
auto v = cache.get(key).get(); // std::optional
-bool removed = cache.remove(key).get(); // delete
-cache.ping().get(); // connectivity check
+auto prev = cache.remove(key).get(); // std::optional
+bool present = cache.containsKey(key).get(); // bool
+cache.ping().get(); // connectivity check (keyless)
+----
+
+`get` returns `std::nullopt` when the key is absent:
+
+[source,cpp]
+----
+if (auto value = cache.get(key).get()) {
+ // key found; use *value
+} else {
+ // key absent
+}
+----
+
+=== Expiration
+
+`put`, `putIfAbsent`, `replace`, and `replaceWithVersion` accept a `lifespan` and
+a `maxIdle`, both in seconds. A value of `0` means immortal (no lifespan) or no
+maximum idle time:
+
+[source,cpp]
----
+// Store with a 60-second lifespan and a 10-second max-idle.
+cache.put(key, value, 60, 10).get();
+----
+
+=== Returning the previous value
+
+The write operations take a `previousValue` flag. When it is `true`, the returned
+future carries the entry that was present before the write, as an
+`EntryWithMetadata` (value plus version and expiration metadata):
+
+[source,cpp]
+----
+if (auto previous = cache.put(key, value, 0, 0, /*previousValue=*/true).get()) {
+ ByteArray& oldValue = previous->value;
+ int64_t version = previous->metadata.version;
+}
+----
+
+`putIfAbsent` returns the existing entry that prevented the store (when the key was
+already present), and `replace` returns the replaced entry (when the key existed).
+Both return `std::nullopt` otherwise.
=== Metadata and version-based (CAS) operations
-The client also implements `getWithMetadata`, `putIfAbsent`, `replace`,
-`containsKey`, `removeWithVersion`, and `replaceWithVersion` (Step 10). The
-version returned by `getWithMetadata` is the input to the conditional
-version-based writes. See STATUS.md and the header for exact signatures and
-return types.
+`getWithMetadata` returns the value together with the entry version and expiration
+metadata. The version is the input to the conditional, version-based writes, which
+implement optimistic locking (compare-and-swap):
+
+[source,cpp]
+----
+if (auto entry = cache.getWithMetadata(key).get()) {
+ int64_t version = entry->metadata.version;
+
+ // Replace only if nobody else changed the entry in the meantime.
+ bool replaced = cache.replaceWithVersion(key, newValue, version).get();
+
+ // Or remove only if unchanged.
+ bool removed = cache.removeWithVersion(key, version).get();
+}
+----
+
+`replaceWithVersion` and `removeWithVersion` return `true` when the operation took
+effect, and `false` when the version did not match (the entry was modified) or the
+key did not exist.
+
+.Operation summary
+[cols="1,2",options="header"]
+|===
+| Operation | Returns
+| `get` | `std::optional`
+| `put`, `putIfAbsent`, `replace`, `remove` | `std::optional`
+| `getWithMetadata` | `std::optional`
+| `containsKey`, `removeWithVersion`, `replaceWithVersion` | `bool`
+| `ping` | `void`
+|===
diff --git a/documentation/topics/client-intelligence.adoc b/documentation/topics/client-intelligence.adoc
index 6ff71ce..878857a 100644
--- a/documentation/topics/client-intelligence.adoc
+++ b/documentation/topics/client-intelligence.adoc
@@ -1,18 +1,60 @@
== Client Intelligence
-NOTE: This chapter is a stub. See `include/hotrod/Types.h` (`ClientIntelligence`)
-and `include/hotrod/RemoteCache.h`.
+Client intelligence controls how much cluster awareness the client uses when it
+routes operations and reacts to topology changes.
-Client intelligence controls how much cluster awareness the client uses:
+=== Intelligence levels
-* `BASIC` -- talk only to the seed server; no topology or routing.
-* `TOPOLOGY_AWARE` -- learn the cluster membership and fail over across it.
-* `HASH_DISTRIBUTION_AWARE` -- additionally route each key straight to its primary
- owner via consistent hashing (MurmurHash3 x64_32).
+[cols="1,3",options="header"]
+|===
+| Level | Behavior
+| `BASIC`
+| Talk only to the seed server. No topology updates and no routing.
+
+| `TOPOLOGY_AWARE`
+| Learn the cluster membership from the server and fail over across all members.
+
+| `HASH_DISTRIBUTION_AWARE`
+| In addition to topology awareness, route each key straight to its primary owner
+ using consistent hashing (MurmurHash3 x64_32), avoiding an extra server hop.
+|===
+
+Set the level before `connect()`:
[source,cpp]
----
cache.setClientIntelligence(ClientIntelligence::HASH_DISTRIBUTION_AWARE);
----
-Set it before `connect()`.
+From a URI, use the `client_intelligence` parameter with the value `basic`,
+`topology_aware`, or `hash_distribution_aware`.
+
+TIP: `HASH_DISTRIBUTION_AWARE` gives the lowest latency for keyed operations
+because it sends each request directly to the node that owns the key. It is the
+recommended level against a clustered {brandname} server.
+
+=== Hash-aware routing
+
+Under `HASH_DISTRIBUTION_AWARE`, the client computes the segment for a key and
+sends the request to that segment's primary owner. If none of a key's owners can
+be reached, the `proxyToNonOwner` setting (default `true`) decides what happens:
+the request either falls through to another server that proxies it to the owner,
+or selection stops and a transient `HotRodClientException` with
+`ownersExhausted = true` is raised so the caller can decide. See
+xref:_error_handling_and_retry[Error Handling and Retry].
+
+=== Inspecting the topology
+
+After `connect()`, the client tracks the cluster topology. Read the current
+topology identifier safely at any time with `getTopologyId()`:
+
+[source,cpp]
+----
+VInt topologyId = cache.getTopologyId();
+----
+
+`getTopologyId()` takes the internal lock and returns a point-in-time value. The
+`getTopology()` and `getConsistentHash()` accessors expose richer internal state
+for testing and debugging, but they return references to state the background
+read loop mutates, so do not read them concurrently with live operations or
+topology churn.
diff --git a/documentation/topics/connecting.adoc b/documentation/topics/connecting.adoc
index d8e2f12..79daf09 100644
--- a/documentation/topics/connecting.adoc
+++ b/documentation/topics/connecting.adoc
@@ -1,13 +1,20 @@
-== Connecting
+== Connecting to {brandname}
-NOTE: This chapter is a stub. See `include/hotrod/RemoteCache.h` for the full API
-and `examples/quickstart/` for working code.
+You create a `RemoteCache`, configure it with setters, then call `connect()`.
+All settings must be applied **before** `connect()`; once connected, the client
+discovers the rest of the cluster from the server's topology updates and pools one
+connection per member.
-You create a `RemoteCache` for a seed server and a cache name, tune it with
-setters, then `connect()`:
+=== Creating a client for a seed server
+
+Construct a `RemoteCache` with a host, a port, and a cache name:
[source,cpp]
----
+#include "hotrod/RemoteCache.h"
+
+using namespace hotrod;
+
RemoteCache cache("localhost", 11222, "my-cache");
cache.setClientIntelligence(ClientIntelligence::HASH_DISTRIBUTION_AWARE);
cache.setAuthentication("username", "password"); // optional; see Security
@@ -16,7 +23,86 @@ cache.connect();
cache.disconnect();
----
-All settings (client intelligence, protocol version, authentication) must be
-configured **before** `connect()`. Once connected, the client discovers the rest
-of the cluster from the server's topology updates and pools a connection per
-member.
+The port defaults to `11222` (the {brandname} Hot Rod port). The cache name is
+optional in the constructor and can be set later with `setCacheName(...)`.
+
+=== Creating a client from a Hot Rod URI
+
+`RemoteCache::fromUri` builds a configured (but not yet connected) client from a
+connection string, mirroring the Java client's `HotRodURI`. The grammar is:
+
+----
+hotrod[s]://[user:password@]host1[:port1][,host2[:port2]...][?key=value&...]
+----
+
+[source,cpp]
+----
+auto cache = RemoteCache::fromUri(
+ "hotrod://user:password@localhost:11222?client_intelligence=hash_distribution_aware",
+ "my-cache");
+cache->connect();
+----
+
+Because `RemoteCache` owns a mutex and is non-movable, `fromUri` returns a
+`std::unique_ptr`. The cache name is passed as the second argument;
+the URI path is not used for it.
+
+The `hotrods://` scheme enables TLS, and credentials in the userinfo enable SASL
+authentication. See xref:_security[Security] for the TLS and SASL query
+parameters.
+
+.Supported URI query parameters
+[cols="1,2",options="header"]
+|===
+| Key | Meaning
+| `client_intelligence` | `basic`, `topology_aware`, or `hash_distribution_aware`
+| `protocol_version` | `4.0` or `4.1`
+| `sasl_mechanism` | SASL mechanism name (for example `SCRAM-SHA-256`, `PLAIN`)
+| `token` | bearer token for the `OAUTHBEARER` mechanism
+| `ca_file`, `sni_host_name`, `ssl_hostname_validation` | TLS server trust (see Security)
+| `client_cert_file`, `client_key_file`, `client_key_password` | mutual-TLS client identity (see Security)
+|===
+
+An unknown parameter, a bad value, or a Java keystore key is rejected with a
+`HotRodClientException`. Connection timeouts, `protocol_version=AUTO`, and GSSAPI
+are not supported yet.
+
+=== Client options
+
+Configure these on the `RemoteCache` before `connect()`:
+
+[cols="1,2",options="header"]
+|===
+| Setter | Purpose
+| `setClientIntelligence(...)` | cluster-awareness level (see xref:_client_intelligence[Client Intelligence])
+| `setProtocolVersion(...)` | `Protocol::VERSION_40` or `Protocol::VERSION_41` (default `4.1`)
+| `setAuthentication(...)` | SASL credentials or mechanism (see xref:_security[Security])
+| `setTls(...)` | TLS transport encryption (see xref:_security[Security])
+| `setProxyToNonOwner(bool)` | owner-to-non-owner routing fallback (default `true`)
+|===
+
+=== Multiple servers and failover
+
+A URI may list several comma-separated hosts, and all of them become seed
+servers:
+
+[source,cpp]
+----
+auto cache = RemoteCache::fromUri("hotrod://node1:11222,node2:11222,node3:11222",
+ "my-cache");
+cache->connect();
+----
+
+At startup, `connect()` tries each seed in order; if none is reachable it throws a
+single `HotRodClientException` listing every seed. At runtime, when the learned
+topology is empty or every known server is unreachable, operations fall back to
+the seed list. The configured seeds are never discarded โ they are the permanent
+fallback.
+
+=== Connection lifecycle
+
+`connect()` opens the seed connection (running the SASL and TLS handshakes if
+configured) and starts the background read loop. `isConnected()` reports the
+current state, and `disconnect()` closes every pooled connection. An operation
+issued before `connect()` or after `disconnect()` fails rather than silently
+reconnecting.
diff --git a/documentation/topics/error-handling-and-retry.adoc b/documentation/topics/error-handling-and-retry.adoc
index 4d54f4c..6b7ffe7 100644
--- a/documentation/topics/error-handling-and-retry.adoc
+++ b/documentation/topics/error-handling-and-retry.adoc
@@ -1,31 +1,81 @@
== Error Handling and Retry
-NOTE: This chapter is a stub. The full design lives in
-`docs/ERROR_HANDLING_DESIGN.md`; a runnable example is
-`examples/quickstart/retry.cpp`.
+Server errors and transport failures surface as `HotRodClientException`, thrown
+from `future.get()`. It derives from `std::runtime_error`, so existing
+`catch (const std::runtime_error&)` handlers still work.
-Server errors and transport failures surface as `HotRodClientException` (still
-catchable as `std::runtime_error`). It carries pure data: a `FailurePhase`
-(`BeforeSend` / `AfterSend` / `ServerError`), the server status, the nodes tried,
-and an `ownersExhausted` flag. Two free helpers classify a failure:
+=== The exception carries pure data
+
+`HotRodClientException` holds the raw facts about a failure and nothing that
+captures client internals, so it is safe to copy, log, and store:
+
+[cols="1,3",options="header"]
+|===
+| Field | Meaning
+| `phase`
+| `FailurePhase::BeforeSend` (request never left the client โ safe to retry),
+ `AfterSend` (request was sent but no usable response came back โ the outcome is
+ ambiguous), or `ServerError` (the server replied with an `ERROR` status).
+
+| `serverStatus`
+| The Hot Rod status or `ERROR` code, when the server sent one.
+
+| `triedNodes`
+| Every node the operation attempted, accumulated across retries.
+
+| `ownersExhausted`
+| For a keyed operation, `true` when every owner of the key has been tried.
+|===
+
+=== Classifying a failure
+
+Two free helpers derive a verdict from the exception, rather than baking one in:
* `isTransient(e)` -- is a retry potentially useful?
* `outcomeUncertain(e)` -- might the operation have taken effect despite the error?
-Retry is **user-decided**, not automatic. On a caught exception, feed it back as
-the exclusion set for the next attempt via the bound-view API:
+=== Retry is user-decided
+
+The client does not retry automatically. On a caught exception, decide whether to
+retry and feed the exception back as the exclusion set for the next attempt with
+the bound-view API `excluding(e)`, which avoids the nodes the failed attempt
+already tried:
[source,cpp]
----
+#include "hotrod/RemoteCache.h"
+#include "hotrod/HotRodClientException.h"
+
+using namespace hotrod;
+
try {
cache.put(key, value).get();
} catch (const HotRodClientException& e) {
if (isTransient(e)) {
cache.excluding(e).put(key, value).get(); // retry, avoiding tried nodes
} else {
- throw;
+ throw; // futile โ give up
}
}
----
The same `excluding(e)` pattern works for keyless operations such as `ping()`.
+
+=== Non-idempotent operations
+
+For an operation that is not safe to repeat blindly, check `outcomeUncertain(e)`
+before retrying. When the outcome is ambiguous (`AfterSend`), the first attempt may
+already have applied, so a plain retry could double-apply. Confirm the current
+state (for example with `getWithMetadata`) before deciding, or use a version-based
+operation so the retry is conditional.
+
+=== proxyToNonOwner does not replace the catch block
+
+`setProxyToNonOwner(true)` (the default) only widens *connection selection* so a
+key whose owners are unreachable can still be served through another node. It does
+not make retry automatic: a failure after the request is sent (a dropped
+connection, a server `ERROR`, a command timeout) still comes back to you as a
+`HotRodClientException`. You must still catch it and decide whether to retry.
+
+TIP: A complete, runnable example โ keyed, keyless, and non-idempotent retry
+loops โ is `examples/quickstart/retry.cpp`.
diff --git a/documentation/topics/getting-started.adoc b/documentation/topics/getting-started.adoc
index c38b69d..322b67d 100644
--- a/documentation/topics/getting-started.adoc
+++ b/documentation/topics/getting-started.adoc
@@ -1,12 +1,46 @@
== Getting Started
-NOTE: This chapter is a stub. For a complete, runnable example today see
-`examples/quickstart/` and `README.md` in the repository root.
+The Hot Rod C++17 client is a static library (`hotrod-client`) that connects your
+application to a {brandname} server over the Hot Rod binary protocol.
-The Hot Rod C++17 client is a static library (`hotrod-client`) built with CMake.
-It requires a C++17 compiler, CMake 3.15+, and OpenSSL 1.1.1+ or 3.x.
+=== Prerequisites
-A minimal program:
+* A C++17 compiler (GCC, Clang, or MSVC).
+* CMake 3.15 or later.
+* OpenSSL 1.1.1 or 3.x (used for SASL authentication and TLS).
+* A running {brandname} server. The `examples/quickstart/` directory includes a
+ `start-server.sh` helper that runs one in a container.
+
+=== Building the library
+
+Build the static library with CMake:
+
+[source,shell]
+----
+cmake -S . -B build
+cmake --build build
+----
+
+This produces `build/libhotrod-client.a`. The public headers live under
+`include/hotrod/`.
+
+=== Linking against the library
+
+Point your build at the `include/` directory and link the static library. A
+minimal CMake consumer looks like this:
+
+[source,cmake]
+----
+add_executable(myapp main.cpp)
+target_include_directories(myapp PRIVATE /path/to/cpp17-client/include)
+target_link_libraries(myapp /path/to/cpp17-client/build/libhotrod-client.a pthread)
+----
+
+See `examples/quickstart/CMakeLists.txt` for a complete, working consumer.
+
+=== Quick start
+
+A minimal program stores a value, reads it back, and disconnects:
[source,cpp]
----
@@ -18,14 +52,42 @@ int main() {
RemoteCache cache("localhost", 11222, "my-cache");
cache.connect();
- cache.put(ByteArray{'k'}, ByteArray{'v'}).get();
- auto value = cache.get(ByteArray{'k'}).get(); // std::optional
+ ByteArray key{'k'};
+ ByteArray value{'v'};
+
+ cache.put(key, value).get(); // store
+ auto result = cache.get(key).get(); // std::optional
+ if (result) {
+ // use *result
+ }
cache.disconnect();
return 0;
}
----
-Keys and values are `ByteArray` (a `std::vector`); the caller marshals
-its own types. Every operation returns a `std::future`; call `.get()` to block
-for the result.
+=== Keys, values, and the async model
+
+Keys and values are `ByteArray` (an alias for `std::vector`). The client
+does not marshal application types for you: convert your keys and values to bytes
+before calling an operation, and convert them back when you read them. For
+example, to use `std::string` keys and values:
+
+[source,cpp]
+----
+std::string k = "greeting";
+std::string v = "Hello, Infinispan!";
+
+ByteArray key(k.begin(), k.end());
+ByteArray value(v.begin(), v.end());
+cache.put(key, value).get();
+
+if (auto bytes = cache.get(key).get()) {
+ std::string back(bytes->begin(), bytes->end());
+}
+----
+
+Every operation is asynchronous and returns a `std::future`. Call `.get()` to
+block until the result arrives, or hold the future and do other work first. A
+failed operation throws when you call `.get()` (see
+xref:_error_handling_and_retry[Error Handling and Retry]).
diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh
new file mode 100755
index 0000000..3080889
--- /dev/null
+++ b/scripts/build-docs.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+#
+# Render the Hot Rod C++17 client user guide to self-contained HTML.
+#
+# This is the single source of truth for "how the docs are built" โ the CMake
+# `docs` target and the GitHub Pages workflow (.github/workflows/docs.yml) both
+# call this script, so "looks right locally" means "looks right on Pages".
+#
+# Usage:
+# scripts/build-docs.sh [--out DIR] [--serve [PORT]] [--watch]
+#
+# (no flags) Render once to documentation/_build/index.html
+# --out DIR Output directory (default: documentation/_build)
+# --serve [PORT] Render, then serve the output over HTTP (default port 8000)
+# --watch Rebuild on every change under documentation/ (needs `entr`)
+#
+# Requires: asciidoctor (gem install asciidoctor). --serve needs python3.
+set -euo pipefail
+
+# Resolve repo root from this script's location, so it works from any CWD.
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
+DOC_SRC="${ROOT}/documentation"
+OUT="${DOC_SRC}/_build"
+SERVE=0
+PORT=8000
+WATCH=0
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --out) OUT="$2"; shift 2 ;;
+ --serve) SERVE=1; shift
+ if [[ $# -gt 0 && "$1" =~ ^[0-9]+$ ]]; then PORT="$1"; shift; fi ;;
+ --watch) WATCH=1; shift ;;
+ -h|--help)
+ grep '^#' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
+ *) echo "unknown argument: $1" >&2; exit 2 ;;
+ esac
+done
+
+if ! command -v asciidoctor >/dev/null 2>&1; then
+ echo "error: asciidoctor not found. Install it with: gem install asciidoctor" >&2
+ exit 1
+fi
+
+render() {
+ mkdir -p "${OUT}"
+ asciidoctor -o "${OUT}/index.html" "${DOC_SRC}/index.adoc"
+ # Copy the TOC assets when present (added by the conventions-polish commit);
+ # rendering still works without them (index.adoc falls back to a plain TOC).
+ for asset in css js; do
+ if [[ -d "${DOC_SRC}/${asset}" ]]; then
+ rm -rf "${OUT:?}/${asset}"
+ cp -r "${DOC_SRC}/${asset}" "${OUT}/"
+ fi
+ done
+ echo "built: ${OUT}/index.html"
+}
+
+render
+
+if [[ "${WATCH}" == "1" ]]; then
+ if ! command -v entr >/dev/null 2>&1; then
+ echo "error: --watch needs \`entr\` (e.g. dnf install entr)" >&2
+ exit 1
+ fi
+ echo "watching ${DOC_SRC} โ Ctrl-C to stop"
+ # -d: exit (and the loop re-runs) when a watched dir changes too.
+ while true; do
+ find "${DOC_SRC}" -name '*.adoc' -o -name '*.css' -o -name '*.js' \
+ | entr -d "${BASH_SOURCE[0]}" --out "${OUT}" || true
+ done
+fi
+
+if [[ "${SERVE}" == "1" ]]; then
+ echo "serving ${OUT} at http://localhost:${PORT}/ โ Ctrl-C to stop"
+ exec python3 -m http.server "${PORT}" --directory "${OUT}"
+fi