All Projects → mrbald → ufw

mrbald / ufw

Licence: Apache-2.0 license
A minimalist framework for rapid server side applications prototyping in C++ with dependency injection support.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to ufw

stashbox
A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
Stars: ✭ 120 (+531.58%)
Mutual labels:  dependency-injection, inversion-of-control
awilix-express
Awilix helpers/middleware for Express
Stars: ✭ 100 (+426.32%)
Mutual labels:  dependency-injection, inversion-of-control
waiter
Dependency injection, Inversion of control container for rust with compile time binding.
Stars: ✭ 71 (+273.68%)
Mutual labels:  dependency-injection, inversion-of-control
Fixed point
C++ Binary Fixed-Point Arithmetic
Stars: ✭ 199 (+947.37%)
Mutual labels:  benchmark, boost
zf-dependency-injection
Advanced dependency injection for laminas framework
Stars: ✭ 17 (-10.53%)
Mutual labels:  yaml, dependency-injection
Quicklib
Quick development library (AutoMapper, LinQ, IOC Dependency Injection, MemoryCache, Scheduled tasks, Config, Serializers, etc) with crossplatform support for Delphi/Firemonkey (Windows,Linux,OSX/IOS/Android) and freepascal (Windows/Linux).
Stars: ✭ 274 (+1342.11%)
Mutual labels:  yaml, dependency-injection
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (+89.47%)
Mutual labels:  dependency-injection, inversion-of-control
Typedi
Simple yet powerful dependency injection tool for JavaScript and TypeScript.
Stars: ✭ 2,832 (+14805.26%)
Mutual labels:  dependency-injection, inversion-of-control
dargo
Dependency Injection for GO
Stars: ✭ 26 (+36.84%)
Mutual labels:  dependency-injection, inversion-of-control
Components.js
🧩 A semantic dependency injection framework
Stars: ✭ 34 (+78.95%)
Mutual labels:  dependency-injection, inversion-of-control
Ut
UT: C++20 μ(micro)/Unit Testing Framework
Stars: ✭ 507 (+2568.42%)
Mutual labels:  benchmark, boost
jimple
Just a dependency injection container to NodeJS and to the browser using new ES6 features
Stars: ✭ 72 (+278.95%)
Mutual labels:  dependency-injection, inversion-of-control
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+14168.42%)
Mutual labels:  dependency-injection, inversion-of-control
Laravelyaml
Laravel ServiceProvider for using YAML configuration files
Stars: ✭ 8 (-57.89%)
Mutual labels:  yaml, dependency-injection
Inversify Express Example
The official express + inversify+ inversify-express-utils examples
Stars: ✭ 210 (+1005.26%)
Mutual labels:  dependency-injection, inversion-of-control
SierraChartZorroPlugin
A Zorro broker API plugin for Sierra Chart, written in Win32 C++.
Stars: ✭ 22 (+15.79%)
Mutual labels:  boost, asio
Qframework
Unity3D System Design Architecture
Stars: ✭ 2,326 (+12142.11%)
Mutual labels:  dependency-injection, inversion-of-control
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (+800%)
Mutual labels:  dependency-injection, inversion-of-control
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (+15.79%)
Mutual labels:  dependency-injection, inversion-of-control
boost-wintls
Native Windows TLS stream wrapper for use with boost::asio
Stars: ✭ 24 (+26.32%)
Mutual labels:  boost, asio

μFW - Micro Framework

build Join the chat at https://gitter.im/mrbald-ufw/Lobby Licence -

μFW is a minimalist framework for rapid server side applications prototyping and experimental work on Unix-like operating systems, primarily Linux and macOS. Those familiar with Spring or Guice may experience a strong deja-vu — dependency injection support was one of the →

Design Objectives

  • Minimum number of lines of code — clean concepts, compact implementations
  • Modularity in spirit of inversion of control
  • Late binding support via shared library-based plugins
  • Consistency in module configuration, lifecycle, concurrency, and logging
  • Singleton-free design with traceable dependencies
  • Structured configuration reflecting both the application topology and the concurrency model
  • Zero steady state runtime overhead
  • Hacking-friendly design

Following core C++ design principles, the rule "you don't pay for what you don't use" is adhered to where possible.

Introduction

uFW Topology

Terminology

The terminology used in the framework maps directly to the main building blocks, which are

  • entity - an identifiable building block of the application (a module)
  • application - container of entities
  • loader - an entity capable of loading other entities
  • lifecycle_participant - an entity with application managed lifecycle
  • execution context - set of rules for code execution (e.g. a specific thread, a thread pool, a strand on a thread pool, ...)
  • launcher - a binary (ufw_launcher, the entry point into an application)

Configuration

Application configuration language is hierarchical YAML. This format gives a good representation of both application bootstrap process and the runtime structure.

Lifecycle Phases

Application modules are created in the order they are defined in the configuration file and are destroyed in the reverse order. Modules can opt to participate in the structural lifecycle by extending the virtual ufw::lifecycle_participant base. The lifecycle phases lifecycle_participant-s are transitioned through are below. The order of transition among individual participants matches their declaration order in the application configuration file.

  • init() - lifecycle_participants may/should discover and cache strongly typed references to each other and fail fast if anything is missing or is of a wrong type
  • start() - lifecycle_participants may/should establish required connections, spawn threads, etc.
  • up() - lifecycle_participants may start messaging others
  • stop() - opposite of start()
  • fini() - opposite of init()

Loaders

A subset of entities capable of loading other entities is called loaders. A loader entity extends the virtual ufw::loader base. loaders are entities. loaders can load other loaders. A special "seed" loader — the default_loader, is used by the application to load entities by name (including other loaders). Whether or not an entity is loaded with a loader is specified in the config (flexibility!). entities can be registered in the application programmatically without loaders. The application registers the default_loader in directly in the constructor. The default launcher registers LIBRARY (loads shared libaries) and PLUGIN (loads entities from shared libraries) loaders before initiating the application bootstrap.

Concurrency

Application initialisation is done single-threaded in the application main thread. Once the application is up the main thread becomes the host of the default execution context. The default execution context an instance of the boost::asio::io_context accessible from entities via this.context(). All other concurrency models are incremental to the ufw.application.

Logging

Logging is a part of the framework. Modules have scoped tagged loggers (with help of macros and context-sensitive symbol lookup). The Boost.Log library was taken as Boost is already on the dependency list and the subject library is flexible and reliable. This logger is not the fastest around, but it's probably one of the cheapest to integrate with.

The logger is configured the same way as any other entity. The config part of the configuration is passed unchanged to the Boost.Log initializer. See the configuration file fragment below as an example.

Trying It

μFW comes with an example module packaged into a plugin shared library (libexample.so on Linux).

The below configuration fragment has a single instance of the example module.

---
application:

  entities:
    # ====== logger ======
    - name: LOGGER
      config: |
        [Core]
        DisableLogging=false
        LogSeverity=error

        [Sinks.Console]
        Destination=Console
        Format="%TimeStamp(format=\"%H:%M:%S.%f\")% | %Severity(format=\"%6s\")% | %ThreadPID% | %Entity% - %Tag%%Message%"
        Asynchronous=true
        AutoFlush=true

    # ====== a dynamic library ======
    - name: example_lib
      loader_ref: LIBRARY
      config:
        filename: libexample.so

    # ====== an entity -- plugin from a dynamic library ======
    - name: example_plugin
      loader_ref: PLUGIN
      config:
        library_ref: example_lib
        constructor: example_ctor
...

To run it, store the above fragment into a YAML file (say config.yaml) and run the μFW launcher as ufw_launcher -c config.yaml.

The console log should look similar to the below screenshot.

screenshot

Building Dependencies

The author's main development platforms are x86_64 Arch Linux and macOS + Homebrew. Both have quite up to date versions of all μFW dependencies. For those working in a less bleeding-edge enviroronments - below are the instructions for building the dependencies from scratch.

Boost

Use instructions from the Boost Home Page The μFW is using these modules:

  • system
  • program_options
  • log
  • boost_unit_test_framework

YamlCPP

$ git clone https://github.com/jbeder/yaml-cpp.git
$ mkdir yaml-cpp-build && cd yaml-cpp-build
$ cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ../yaml-cpp
$ make -j$(nproc) && sudo make install

CapNProto (optional - examples)

$ git clone https://github.com/sandstorm-io/capnproto.git
$ mkdir capnproto-build && cd capnproto-build
$ cmake -DCMAKE_BUILD_TYPE=Release ../capnproto/c++
$ make -j$(nproc) && sudo make install

Building

Compiling

$ git clone https://github.com/mrbald/ufw.git
$ mkdir ufw-build && cd ufw-build
$ cmake -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=$HOME/local] ../ufw
$ make -j$(nproc)

Running tests

To run all tests run

$ make unit-test

To run individual tests with verbose output run

$ make BOOST_TEST_LOG_LEVEL=all BOOST_TEST_RUN_FILTERS=ufw_app/* unit-test

Running benchmarks

$ make benchmark

Installing

$ sudo make install

Using

TODO

Hacking

TODO

References

CMake/How To Find Libraries

Markdown Cheatsheet

Draw.io

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].