tqcq 7b1b6128e6
CI / build-and-test (clang) (push) Successful in 5m48s
CI / build-and-test (gcc) (push) Successful in 7m51s
CI / cross-arch-test (armv7, arm-linux-gnueabihf) (push) Successful in 7m15s
CI / crash-dump-smoke (push) Successful in 1m50s
CI / format-check (push) Successful in 16s
CI / doxygen-build (push) Successful in 15s
CI / pdf-build (push) Successful in 4m41s
CI / cross-arch-test (aarch64, aarch64-linux-gnu) (push) Successful in 8m12s
feat(abi): dual-track exported API surface (ELF version script, PE dllexport)
2026-09-15 19:40:29 +08:00
2026-09-09 23:58:52 +08:00

Teles — Cross-Platform C++14 Framework

Teles is a comprehensive C++14 framework: concurrency, networking, TLS, HTTP, gRPC, Redis, reactive streams, filesystem, logging, crash minidumps and more behind one consistent, portable API (Windows / macOS / Linux, no Boost). All third-party libraries ({fmt}, mpark::variant, ghc::filesystem, nlohmann/json, miniz, mbedtls, nghttp2, libbacktrace) are encapsulated behind teles:: APIs — users never interact with upstream namespaces directly.

Full per-module reference: docs/modules/.

Quick Start

cmake -B build -DCMAKE_BUILD_TYPE=Release   # static library by default
cmake --build build
cd build && ctest --output-on-failure       # with -DTELES_BUILD_TESTS=ON

Consume via CMake:

find_package(teles REQUIRED)                # or: add_subdirectory(teles)
target_link_libraries(my_app PRIVATE teles::teles)
Option Default Description
TELES_BUILD_TESTS OFF Google Test unit tests + rapidcheck property tests
TELES_BUILD_FUZZ OFF libFuzzer/AFL++ fuzz targets
TELES_BUILD_SHARED OFF Shared library instead of static
TELES_INSTALL OFF install targets (headers + library + CMake package)

Compilers: GCC 7+, Clang 7+, MSVC 2019+ (full C++14).

Usage

#include <teles/teles.h>          // umbrella, or individual module headers

Errors are Results, not exceptions

using namespace teles;

Result<int, Error> ParsePort(StringView s) {
    if (s.empty()) {
        return Err(Error::InvalidArgument("empty port")
                        .WithCause(Error::System(errno, "strtol failed")));
    }
    return Ok(8080);
}

auto r = ParsePort("8080").Map([](int p) { return p + 1; });
// r.IsOk() / r.Value() / r.Error().ToChainString(); Map/AndThen/OrElse/Inspect

Library code never throws; TELES_FATAL aborts on unrecoverable states.

Strings & formatting

using namespace teles;

auto parts = str::Split("a,b,c", ',');              // {"a", "b", "c"}
auto text = str::StrCat("x = ", 42, ", ok = ", true); // "x = 42, ok = 1"
str::ToSnakeCase("HTTPServer");                    // "http_server"
str::utf8::Length("héllo");                        // 5 code points

TELES_ENUM(Color, Red, Green, Blue);                // Names/Count/ToString/TryParse
std::string name = format::ToString(Color::Green);  // "Green"

Concurrency — strict global lifecycle

using namespace teles;
using namespace teles::concurrency;

ThreadPoolConfig cfg;
cfg.coreThreads = 4;
cfg.rejectionPolicy = RejectionPolicy::CallerRuns;
ThreadPool pool(cfg);
int v = pool.Submit([] { return 42; }).Get();       // Future<int>

if (teles::Init(argc, argv) != teles::InitStatus::kOk)
    return 1;                    // help/version exits 0; parse/init failure 1
CpuPool()->Submit([] { return 1; });   // global pools exist ONLY between Init
IoPool()->Submit([] { return 2; });    // and Shutdown — accessors abort
teles::Shutdown();                     // outside the gate (no lazy init)

Channel<int> ch(8);              // Go-style: Send / Recv / TryRecv / SendFor
Mutex<int> mtx(0);
mtx.With([](int& x) { ++x; });   // lambda runs under the lock

Networking — signals, not callbacks

using namespace teles;
using namespace teles::io;

concurrency::EventLoop loop;                        // epoll / IOCP reactor
std::thread loop_thread([&] { loop.Run(); });

auto conn = std::make_shared<TcpConnection>(&loop);
conn->OnData.Connect([](TcpConnection* c, const uint8_t* data, size_t len) {
    // bytes are valid only during the callback — copy if needed
});
auto ok = conn->Connect("example.com", 80).Get();  // Future -> Result<void>
conn->Write(request, sizeof(request) - 1);          // buffered; OnWritable on drain
conn->Close();

loop.Stop();
loop_thread.join();

TLS (TlsConnection over mbedtls), UDP, HTTP, and gRPC-over-HTTP/2 are built on the same signal-driven model — see docs/modules/io.md.

Reactive streams

using namespace teles::reactive;

auto sub = FlowableRange(1, 5)
                .Filter([](int x) { return x % 2 == 1; })
                .Map<int>([](int x) { return x * x; })   // 1, 9, 25
                .Subscribe([](int v) { /* ... */ });
// sub is RAII — cancelled at scope exit

Crash minidumps + one-command analysis

using namespace teles::system;

CrashHandlerConfig crash;
crash.dump_dir = "/var/log/myapp";   // created recursively at install time
InstallCrashHandler(crash);           // SIGSEGV/SIGABRT/... -> <app>-crash-<epoch>-<pid>.dmp

Analyze with the built-in CLI — zero flags, zero external tools:

build/teles dump myapp-crash-1-12345.dmp                    # binaries still on this machine?
build/teles dump myapp-crash-1-12345.dmp --bin ./myapp      # binary elsewhere / renamed
build/teles symbols build/myapp --out symbols               # stage once, analyze many:
build/teles dump myapp-crash-1-12345.dmp --symbols symbols  #   symbol-server layout

Modules

Module What it gives you Reference
core Optional/Variant/StringView/Span, literals, try-macros, hash, bitops docs/modules/core.md
error Error + Result<T,E> with functional combinators docs/modules/error.md
str locale-independent string ops, UTF-8 codec, encodings docs/modules/str.md
format enum name tables (TELES_ENUM), null-safe ToString docs/modules/format.md
memory allocators: pool / arena / tracking / aligned docs/modules/memory.md
log leveled, categorized logging with sinks docs/modules/log.md
concurrency thread pools, futures, channels, sync primitives, timers docs/modules/concurrency.md
event Signal/Connection — the callback backbone docs/modules/event.md
sync Mutex<T>, RwLock, atomics with teles memory orders include/teles/sync/
fs paths, file ops, streaming I/O, mmap, temp dirs, glob docs/modules/fs.md
io EventLoop, TCP/UDP, TLS, X.509, async file I/O docs/modules/io.md
net interfaces and change notification docs/modules/net.md
http HTTP server/client over the signal model include/teles/http/
rpc gRPC over HTTP/2 (teles proto stubs) include/teles/rpc/
redis RedisClient — in-house RESP2/RESP3, Future-first, pub/sub docs/modules/redis.md
reactive Flowable<T> — operators, backpressure, subjects docs/modules/reactive.md
serialization JSON wrapper + TELES_SERIALIZABLE docs/modules/serialization.md
config multi-provider priority-merged configuration docs/modules/config.md
system signals, crash diagnostics, minidumps, process info docs/modules/system.md
resilience retry / circuit breaker / rate limiting docs/modules/resilience.md
cli gflags-style options + command-tree dispatch (the teles binary: dump, symbols, proto) docs/modules/cli.md
hash, encoding, uuid, time, math, algo, range, container supporting toolbox docs/modules/

Dependencies

Everything is vendored via CPM from committed tarballs in third_party/archives/ — a clean checkout configures and builds with zero network. No Boost, no OpenSSL (TLS is mbedtls), no asio.

Conventions

  • Classes/types PascalCase, methods PascalCase, members snake_case_, namespaces lowercase, constants k-prefixed, macros TELES_*.
  • Platform code is suffix-split (*_posix.cpp / *_win.cpp) — zero #ifdef _WIN32 branches in library sources.
  • No exceptions in library code; failures are Result<T, Error>.
  • Teles dogfoods its own primitives (sync, sleep, sockets); tools/check_layering.py (ctest teles_layering) enforces it and keeps raw OS primitives confined to the internal src/base/ layer.
  • Tests are platform-independent: teles API + ghc::filesystem only, no platform headers or raw syscalls in tests/.

Testing

cmake -B build -DTELES_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failure

Google Test (unit) + rapidcheck (property). The sanitizer matrix (ASan + UBSan + TSan + LSan) runs on x86_64 CI.

S
Description
No description provided
Readme
59 MiB
Languages
C++ 96.5%
CMake 1.4%
Python 1%
Shell 0.7%
C 0.3%