C++20 Microservice Bootstrapping Framework
Ichor, Greek Mythos for ethereal fluid that is the blood of the gods/immortals, is a C++ framework/middleware for microservices. Ichor allows re-usable services and components to be used in multiple microservices, greatly supporting the workflow for large teams. It also supports reasoning in multithreaded environments, reducing the chances for data races.
TL;DR: Node.js-style event loops with coroutines and dependency injection, except it's C++.
Ichor borrows from the concept of Fearless Concurrency and offers thread confinement.
Excellent question! Please see this page to get a more in-depth answer.
Multithreading is hard. There exist plenty of methods trying to make it easier, ranging from the actor framework, static analysis a la rust, software transaction memory and traditional manual lock-wrangling.
Thread confinement is one such approach. Instead of having to protect resources, Ichor attempts to make it well-defined on which thread an instance of a C++ class runs and pushes you to only access and modify memory from that thread. Thereby removing the need to think about atomics/mutexes, unless you use threads not managed by, or otherwise trying to circumvent, Ichor. In which case, you're on your own.
To support software lifecycles measured in decades, engineers try to encapsulate functionality. Using the Dependency Injection approach allows engineers to insulate updates to parts of the code.
There exist many Dependency Injection libraries for C++ already, but where those usually only provide Dependency Injection, Ichor also provides service lifecycle management and thread confinement. If a dependency goes away at runtime, e.g. a network client, then all the services depending on it will be cleaned up at that moment.
The minimal example requires a main function, which initiates at least one event loop, a framework logger and one service and quitting the program gracefully using ctrl+c.
The realtime example shows a trivial program running with realtime priorities and shows some usage of Ichor priorities.
More examples can be found in the examples directory.
brew install llvm
, ASAN in combination with boost beast may result in false positives)For build instructions and required dependencies, please see GettingStarted.
Documentation can be found in the docs directory.
The framework provides several core features and optional services behind cmake feature flags:
Optional services:
Feel free to make issues/pull requests, and I'm sometimes online on Discord: https://discord.gg/r9BtesB
Business inquiries can be sent to michael AT volt-software.nl
By default, Ichor uses a mutex when inserting/extracting events from its queue. Because non-voluntary user-space scheduling requires lock-free data-structures, this is not possible.
Ichor used to have full support for the polymorphic allocators, but as not all compilers support it yet (looking at you libc++) as well as having a negative impact on developer ergonomy, it has been removed. Instead, Ichor now recommends usage with mimalloc:
it does not suffer from blowup, has bounded worst-case allocation times (wcat), bounded space overhead (~0.2% meta-data, with low internal fragmentation), and has no internal points of contention using only atomic operations.
What is necessary to implement before using Ichor on these platforms:
The same goes for Wind River. Freestanding implementations might be necessary for Baremetal support, but that would stray rather far from my expertise.
To add support for -fno-rtti
while providing the functionality of std::any
and realtime mutexes (at least on linux).
The real-time extensions to mutexes (PTHREAD_MUTEX_ADAPTIVE_NP/PTHREAD_PRIO_INHERIT/PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) are either not a standard extension or not exposed by the standard library equivalents.
Ichor is licensed under the MIT license.