Skip to content

An RPC solution that is agnostic on serialization formats, transports and coroutine libraries. With remote RAII object management support. A major rewrite of https://github.com/edwardbr/rpc

License

Notifications You must be signed in to change notification settings

edwardbr/Canopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

120 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Canopy

Canopy

License C++ CMake Platform

A Modern C++ Remote Procedure Call Library for High-Performance Distributed Systems

Canopy enables type-safe communication across execution contexts including in-process calls, inter-process communication, remote machines, embedded devices, and secure enclaves (SGX).

Note this is in Beta including the documentation and is in active development


Key Features

  • πŸ”’ Type-Safe: Full C++ type system integration with compile-time verification
  • 🌐 Transport Agnostic: Local, TCP, SPSC, SGX Enclave, and custom transports
  • πŸ“¦ Format Agnostic: JSON, YAS binary, Protocol Buffers support
  • πŸ”„ Bi-Modal Execution: Same code runs in both blocking and coroutine modes
  • πŸ›‘οΈ SGX Enclave Support: Secure computation in Intel SGX enclaves
  • πŸ“Š Comprehensive Telemetry: Sequence diagrams, console output, HTML animations
  • πŸ”§ Coroutine Library Agnostic: libcoro, libunifex, cppcoro, Asio (see 13-coroutine-libraries.md)
  • πŸ§ͺ AddressSanitizer Support: Full ASan integration with 972 tests passing (100% memory safety validated)

Documentation

Comprehensive documentation is available in the documents/ directory:

Getting Started

  1. Introduction - What is Canopy and its key features
  2. Core Concepts - Zones, services, smart pointers, proxies, and stubs
  3. IDL Guide - Interface Definition Language syntax and usage
  4. Transports - Local, TCP, SPSC, and SGX enclave transports
  5. Building Canopy - Build configuration and CMake presets
  6. Getting Started Tutorial - Step-by-step tutorials

Advanced Topics

  1. Bi-Modal Execution - Blocking and coroutine modes
  2. Error Handling - Error codes and handling patterns
  3. Telemetry - Debugging and visualization
  4. Memory Management - Reference counting and lifecycle
  5. Zone Hierarchies - Complex distributed topologies
  6. API Reference - Quick reference for main APIs
  7. Coroutine Libraries - Coroutine library support and porting
  8. Examples - Working examples and demos
  9. Best Practices - Design guidelines and troubleshooting
  10. Migration Guide - Upgrading from older versions

Serialization


Quick Start

Prerequisites

  • C++17 Compiler: Clang 10+, GCC 9.4+, or Visual Studio 2019+
  • CMake: 3.24 or higher
  • Build System: Ninja (recommended)
  • Node.js: 18+ (for llhttp code generation)
  • OpenSSL: Development headers (libssl-dev on Linux, OpenSSL SDK on Windows)

Build

# Clone and configure
git clone https://github.com/edwardbr/Canopy.git
cd Canopy

# Choose Blocking
cmake --preset Debug

# Or Coroutines
cmake --preset Coroutine_Debug

# Or with AddressSanitizer (memory safety testing)
cmake --preset Debug_ASAN
cmake --preset Coroutine_Debug_ASAN

# Build core library
cmake --build build_debug --target rpc

# Run tests
ctest --test-dir build_debug --output-on-failure

# Run individual tests with ASan (recommended)
tests/scripts/run_asan_tests.sh

Build Options

# Execution mode
CANOPY_BUILD_COROUTINE=ON    # Enable async/await support (requires C++20)

# Features
CANOPY_BUILD_ENCLAVE=ON      # SGX enclave support
CANOPY_BUILD_TEST=ON         # Test suite
CANOPY_BUILD_DEMOS=ON        # Demo applications

# Development
CANOPY_USE_LOGGING=ON        # Comprehensive logging
CANOPY_USE_TELEMETRY=ON      # Debugging and visualization
CANOPY_DEBUG_GEN=ON          # Code generation debugging

# Memory Safety
CANOPY_DEBUG_ADDRESS=ON      # AddressSanitizer (detect memory errors)
CANOPY_DEBUG_THREAD=ON       # ThreadSanitizer (detect data races)
CANOPY_DEBUG_UNDEFINED=ON    # UndefinedBehaviorSanitizer

Hello World Example

calculator.idl:

namespace calculator {
    [inline] namespace v1 {
        [status=production]
        interface i_calculator {
            int add(int a, int b, [out] int& result);
        };
    }
}

Usage:

#include "generated/calculator/calculator.h"

// Create service and connect to calculator zone
auto root_service = std::make_shared<rpc::service>("root", rpc::zone{1});
rpc::shared_ptr<calculator::v1::i_calculator> calc;

auto error = CO_AWAIT root_service->connect_to_zone<...>(
    "calc_zone", rpc::zone{2}, nullptr, calc, setup_callback);

// Make RPC call
int result;
error = CO_AWAIT calc->add(5, 3, result);
std::cout << "5 + 3 = " << result << std::endl;  // Output: 5 + 3 = 8

Supported Transports

Transport Description Requirements
Local In-process parent-child communication None
TCP Network communication between machines Coroutines
SPSC Single-producer single-consumer queues Coroutines
SGX Enclave Secure enclave communication SGX SDK
Custom User-defined transport implementations Custom implementation

See 04-transports.md for details.


Requirements

Supported Platforms

  • Windows: Visual Studio 2019+
  • Linux: Ubuntu 18.04+, CentOS 8+
  • Embedded: Any platform with C++17 support

Compilers

  • Clang: 10.0+
  • GCC: 9.4+
  • MSVC: Visual Studio 2019+

Dependencies

Git submodules manage external dependencies:

  • YAS: Serialization framework
  • libcoro: Coroutine support (when CANOPY_BUILD_COROUTINE=ON)
  • range-v3: Range library support
  • spdlog: Logging framework

Project Structure

canopy/
β”œβ”€β”€ rpc/                    # Core RPC library
β”œβ”€β”€ generator/              # IDL code generator
β”œβ”€β”€ transports/             # Transport implementations (local, tcp, spsc, sgx)
β”œβ”€β”€ tests/                  # Test suite
β”œβ”€β”€ demos/                  # Example applications
β”œβ”€β”€ telemetry/              # Telemetry and logging
β”œβ”€β”€ cmake/                  # CMake build configuration modules
β”‚   β”œβ”€β”€ Canopy.cmake        # Main build configuration
β”‚   β”œβ”€β”€ Linux.cmake         # Linux-specific settings
β”‚   β”œβ”€β”€ Windows.cmake       # Windows-specific settings
β”‚   β”œβ”€β”€ SGX.cmake           # SGX enclave support
β”‚   └── CanopyGenerate.cmake # IDL code generation
β”œβ”€β”€ documents/              # Comprehensive documentation
β”œβ”€β”€ submodules/             # External dependencies
└── CMakeLists.txt          # Build configuration

Development Setup

Code Formatting

This project uses cmake-format for CMake files and clang-format for C++ files.

Install cmake-format (version 0.6.13 required):

pip install cmake-format==0.6.13

VSCode Setup:

  1. Open the project in VSCode
  2. Install recommended extensions when prompted (or manually install cheshirekow.cmake-format)
  3. The workspace settings will automatically use .cmake-format.yaml for formatting
  4. Format-on-save is enabled by default

Manual formatting:

# Check CMake formatting
git ls-files -- \*.cmake \*CMakeLists.txt | xargs cmake-format --check

# Apply CMake formatting
git ls-files -- \*.cmake \*CMakeLists.txt | xargs cmake-format -i

# Apply C++ formatting
clang-format -i <file>

Contributing

Canopy is actively maintained.

  • Performance optimizations
  • New transport implementations
  • Platform ports
  • Documentation improvements

License

Copyright (c) 2026 Edward Boggis-Rolfe. All rights reserved.

See LICENSE for details.


Acknowledgments

SHA3 Implementation: Credit to brainhub/SHA3IUF


For technical questions and detailed API documentation, see the documents directory.

About

An RPC solution that is agnostic on serialization formats, transports and coroutine libraries. With remote RAII object management support. A major rewrite of https://github.com/edwardbr/rpc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •