Code Monkey home page Code Monkey logo

dbg-census-cpp's Introduction

DbgCensus

A self-contained C++ library for the Daybreak Game Company Census API.

Important

This library is a work in progress (aka. hot mess) and is not really ready for anything. It is primarily replacing some Qt-infected jank from leonhard-s/ps2-rich-presence with leaner, more testable variants that don't require a half-dozen Qt modules to build.

Overview

  • REST and WebSocket clients for the Daybreak Game Company Census API
  • Uses IXWebSocket for HTTP, with optional OpenSSL support
  • All requests are synchronous, choose your own poison (std::thread, std::async, QThread, etc.)
  • *No JSON parsing, bring your own (nlohmann/json, rapidjson, QJsonDocument etc.)

*The dependency on nlohmann/json is only used for tests and examples, the library output is std::string-based.

Dependencies

IXWebSocket is currently always brought in via FetchContent, everything else is provided through vcpkg. Note that vcpkg is entirely optional, this project just calls CMake's ´find_package()` to locate its dependencies.

Building

This project uses CMake and can be consumed via find_package() after installation. When including in another project via FetchContent, it is recommended to set DbgCensus_INSTALL=OFF to avoid reinstalling its headers into its install tree.

mkdir build/
cmake -S . -B build/ -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build/

# Optionally install
cmake --build build/ --target install

Testing

This project uses Google Test driven by CMake's CTest. Tests can be run with the following command:

# After building
cd build/
ctest . -C Release # replace with the desired configuration

dbg-census-cpp's People

Contributors

leonhard-s avatar

Watchers

 avatar

dbg-census-cpp's Issues

Selectively export symbols

This library is currently designed to be built statically only. Once utility libraries have been converted to header-only (see #5), it would be nice to have shared library support as well.

Test ixWebSocket https client

Since we are already building ixWebSocket locally, it makes sense to use its HTTPS client along with the WebSocket one. If it proves incomvenient, no harm done. But it's always nice to get rid of some dependencies.

Refactor URL generator to support compile time evaluation

The URL generator is meant for development convenience/safety but has limited utility at runtime. As such, we should make sure that as little actual code is executed as possible.

Wonder if the interface could be reworked to be fully consteval-able.

Implement dbg_census::urlgen::UrlBuilder

A basic builder for standard DBG Census URLs. This works with and returns plain C++ strings.

No assumptions about available query commands, endpoints, or collections are made to keep this compatible with third-party API mirrors such as Sanctuary.Census.

Reduce CI load

The current CI system stores both the build and install artifacts on every push, resulting in unneeded persistent storage usage.

Some ways to address this:

  • Only retain build artifacts for 24 hours
  • Only retain install artifacts for 7 days

Add install targets

This project is meant to be consumed via CMake, so a simple export set and config file should do nicely. Since we have no transitive dependencies, no intermediate targets file should be required.

Add intermediate OBJECT libraries for unit testing

Unit-testing internal components such as HttpClientAdapter currently requires re-compiling and -linking the underlying source files to resolve the symbols.

While this project is small enough for compile times to not matter too much, it is still cleaner to do so through virtual targets for extensibility and reliability.

Move Url generator into REST component

While this is an optional component that does not require any linking, there is no reason to model it as a separate install component or target. A different header is sufficient here.

Add subscription helper / generator

The ESS client currently takes raw JSON payloads for subscriptions. This should be expanded to generate them from scratch using the known event names and arguments.

Make Url generator header-only

This project is not complex enough to warrant 4+ different libraries for its functionality, especially if client code decides to consume them as shared libraries.

Separating the REST and WebSocket clients is sensible as these two components could be used independently, but the URL generator should be redesigned to not require a hard library in the end; it is very basic anyway.

This also gives us more room to go to town with compile-time polymorphism and constexpr. Due to the dynamic nature of the query system we are unlikely to get complete compile-time evaluation, but it is an avenue worth exploring.

Integrate vcpkg via submodule

The reliance on the global VCPKG_INSTALLATION_ROOT environment variable requires users to make changes to the CMake presets (or add their own user preset) just to be able to build the solution.

vcpkg recommends using a git submodule, which should alleviate this issue.

Support multi-config installations

The build step is already uploading the installation into a directory. To support multi-config generators, we must place the different configuration target definitions side-by-side along with their respective binaries.

  • Need to decide on a naming scheme to ensure that release and debug variants are distinct
  • Alternatively (or in addition), we must place built binaries in subdirectories according to their build type

Add payload validation hooks

The current client is designed to be agnostic to the JSON parser used. However, we may still want to further validate received responses as part of the retry check.

Create examples

We should add some usage examples to showcase the library API and verify that its interfaces are convenient.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.