├── jsonv ├── debian │ ├── compat │ ├── docs │ ├── libjsonv1.0.0.dirs │ ├── source │ │ └── format │ ├── libjsonv-dev.dirs │ ├── libjsonv1.0.0.install │ ├── libjsonv-dev.install │ ├── changelog │ ├── control │ ├── rules │ └── copyright ├── src │ ├── jsonv-tests │ │ ├── data │ │ │ ├── json_checker │ │ │ │ ├── fail29.json │ │ │ │ ├── fail30.json │ │ │ │ ├── fail31.json │ │ │ │ ├── fail16.json │ │ │ │ ├── fail33.json │ │ │ │ ├── fail2.json │ │ │ │ ├── fail24.json │ │ │ │ ├── fail8.json │ │ │ │ ├── fail19.json │ │ │ │ ├── fail23.json │ │ │ │ ├── fail28.json │ │ │ │ ├── fail20.json │ │ │ │ ├── fail5.json │ │ │ │ ├── fail6.json │ │ │ │ ├── fail7.json │ │ │ │ ├── fail11.json │ │ │ │ ├── fail12.json │ │ │ │ ├── fail14.json │ │ │ │ ├── fail21.json │ │ │ │ ├── pass-but-fail-strict-4.json │ │ │ │ ├── fail15.json │ │ │ │ ├── fail17.json │ │ │ │ ├── fail22.json │ │ │ │ ├── fail3.json │ │ │ │ ├── pass-but-fail-strict-27.json │ │ │ │ ├── fail26.json │ │ │ │ ├── fail32.json │ │ │ │ ├── pass-but-fail-strict-9.json │ │ │ │ ├── pass-but-fail-strict-25.json │ │ │ │ ├── pass2.json │ │ │ │ ├── fail10.json │ │ │ │ ├── pass-but-fail-strict-13.json │ │ │ │ ├── pass-but-fail-strict-18.json │ │ │ │ ├── pass-but-fail-strict-1.json │ │ │ │ ├── pass3.json │ │ │ │ ├── README.md │ │ │ │ └── pass1.json │ │ │ ├── merges │ │ │ │ ├── numbers_add.json │ │ │ │ ├── booleans.json │ │ │ │ ├── numbers_mixed.json │ │ │ │ ├── decimal_add.json │ │ │ │ ├── nulls.json │ │ │ │ ├── strings_append.json │ │ │ │ ├── numbers_coerce.json │ │ │ │ ├── boolean_integer.json │ │ │ │ ├── strings_append_coerce.json │ │ │ │ ├── array_appends.json │ │ │ │ ├── type_mixing.json │ │ │ │ ├── object_mix_extra.json │ │ │ │ ├── object_simple.json │ │ │ │ └── object_keyshare.json │ │ │ ├── diffs │ │ │ │ ├── integer_same.json │ │ │ │ ├── numbers_mixed_same.json │ │ │ │ ├── string_same.json │ │ │ │ ├── different_kinds.json │ │ │ │ ├── arrays_same.json │ │ │ │ ├── arrays_different.json │ │ │ │ ├── objects_same.json │ │ │ │ ├── arrays_different_left_longer.json │ │ │ │ ├── arrays_different_right_longer.json │ │ │ │ ├── objects_different_keys.json │ │ │ │ ├── objects_different_values.json │ │ │ │ ├── arrays_different_recursive.json │ │ │ │ └── objects_different_recursive.json │ │ │ └── paths.json │ │ ├── optional_tests.cpp │ │ ├── stopwatch.cpp │ │ ├── demangle_tests.cpp │ │ ├── chrono_io.hpp │ │ ├── chrono_io.cpp │ │ ├── filesystem_util.hpp │ │ ├── algorithm_compare_tests.cpp │ │ ├── util_validate_tests.cpp │ │ ├── kind_tests.cpp │ │ ├── test.cpp │ │ ├── main.cpp │ │ ├── tokenizer_tests.cpp │ │ ├── functional_tests.cpp │ │ ├── unicode_tests.cpp │ │ ├── util_diff_tests.cpp │ │ └── algorithm_map_tests.cpp │ ├── jsonv │ │ ├── functional.cpp │ │ ├── array.hpp │ │ ├── object.hpp │ │ ├── detail.hpp │ │ ├── algorithm_compare.cpp │ │ ├── demangle.cpp │ │ ├── algorithm_traverse.cpp │ │ ├── detail │ │ │ ├── regex.hpp │ │ │ └── token_patterns.hpp │ │ ├── char_convert.hpp │ │ └── algorithm_map.cpp │ └── json-benchmark │ │ ├── jsonv_benchmark.cpp │ │ ├── jq_benchmark.cpp │ │ ├── jansson_benchmark.cpp │ │ ├── jsoncpp_benchmark.cpp │ │ ├── core.cpp │ │ └── core.hpp ├── doc │ ├── meme.jpg │ ├── conversions.png │ └── conversions.dot ├── config │ ├── make-doxygen │ ├── travisci_ecdsa.enc │ ├── travisci_ecdsa.pub │ ├── upload-coverage │ └── publish-doxygen ├── msvc │ └── vs2015 │ │ ├── jsonv-tests │ │ ├── packages.config │ │ └── jsonv-tests.vcxproj.user │ │ ├── jsonv │ │ └── packages.config │ │ └── JsonVoorhees.sln ├── libjsonv.pc.in ├── AUTHORS ├── appveyor.yml ├── include │ └── jsonv │ │ ├── extract.hpp │ │ ├── forward.hpp │ │ ├── serialization_optional.hpp │ │ ├── demangle.hpp │ │ ├── detail │ │ ├── nested_exception.hpp │ │ └── scope_exit.hpp │ │ └── string_view.hpp ├── installer │ └── arch │ │ ├── v0.3.0 │ │ └── PKGBUILD │ │ ├── v0.3.1 │ │ └── PKGBUILD │ │ ├── v0.4.0 │ │ └── PKGBUILD │ │ ├── v0.4.1 │ │ └── PKGBUILD │ │ ├── v0.5.0 │ │ └── PKGBUILD │ │ ├── v0.5.1 │ │ └── PKGBUILD │ │ ├── v1.0.0 │ │ └── PKGBUILD │ │ └── git │ │ └── PKGBUILD └── .gitignore ├── rtb ├── exchange │ ├── README.md │ └── multibidder_communicator.hpp ├── DSL │ ├── README.md │ ├── campaign_dsl.hpp │ ├── generic_dsl.hpp │ └── rapid_mapper.hpp ├── core │ ├── core.hpp │ ├── bid_request.hpp │ ├── user_info.hpp │ ├── banker.hpp │ ├── algos.hpp │ └── logger.cpp ├── common │ ├── decision_router.hpp │ ├── type_algo.hpp │ ├── perf_timer.hpp │ └── split_string.hpp ├── messaging │ └── shared_io_service.hpp ├── client │ ├── empty_key_value_client.hpp │ └── empty_asio_client_adapter.hpp └── datacache │ └── any_str_ops.hpp ├── tests ├── main.cpp ├── CMakeLists.txt └── vanilla_all.cpp ├── examples ├── campaign │ ├── campaigns.json │ ├── curl_win.sh │ ├── curl_campaign.sh │ ├── serialization.hpp │ ├── config.hpp │ ├── CMakeLists.txt │ └── slavebanker_service_test.cpp ├── bidder │ ├── etc │ │ └── config.cfg │ ├── BID_REQUEST_BANNER.json │ ├── mock_exchange │ │ └── data.json.template │ ├── generator │ │ └── campaign_budget.py │ ├── CMakeLists.txt │ ├── config.hpp │ ├── serialization.hpp │ └── bidder_caches.hpp ├── UI │ └── CampaignBudgetsCDN │ │ ├── images │ │ └── vanilla.jpg │ │ ├── scripts │ │ ├── app.js │ │ └── services.js │ │ ├── styles │ │ └── mystyles.css │ │ └── index.html ├── README.md ├── loader │ ├── curl_loader.sh │ ├── ico_curl_loader.sh │ ├── config.hpp │ └── CMakeLists.txt ├── multiexchange │ ├── CMakeLists.txt │ ├── multiexchange_config.hpp │ └── multiexchange_status.hpp ├── bidder_experimental │ ├── ICO_BID_REQUEST_BANNER.json │ ├── config.hpp │ └── CMakeLists.txt ├── REQUEST__SHORT_NOROOT_STRING.json ├── etc │ └── config.cfg └── curl.sh ├── docker ├── vanilla-base.Dockerfile ├── vanilla-runtime.Dockerfile ├── vanilla-prod.Dockerfile ├── vanilla-deps.Dockerfile ├── vanilla-dev.Dockerfile ├── build-vanilla.sh └── build-boost.sh ├── CRUD ├── service │ ├── spin_lock.hpp │ ├── header.hpp │ ├── request.hpp │ ├── mime_types.cpp │ ├── CMakeLists.txt │ ├── request_handler.hpp │ ├── mime_types.hpp │ └── connection_manager.hpp ├── CMakeLists.txt ├── README.md └── handlers │ └── crud_matcher.hpp ├── docker_swarm ├── docker-compose.yaml ├── swarm-persist-with-haproxy.yaml ├── swarm-persist-with-traefik.yaml └── scatter.sh ├── CONTRIBUTING.md ├── benchmarks ├── main.cpp └── audit_benchmarks.cpp ├── parsers ├── CMakeLists.txt └── jsmn.h ├── rapidjson └── internal │ ├── swap.h │ └── strfunc.h └── .gitignore /jsonv/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /jsonv/debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /jsonv/debian/libjsonv1.0.0.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /jsonv/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /jsonv/debian/libjsonv-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | -------------------------------------------------------------------------------- /jsonv/debian/libjsonv1.0.0.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.so.* 2 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail29.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail30.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail31.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail16.json: -------------------------------------------------------------------------------- 1 | [\naked] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail33.json: -------------------------------------------------------------------------------- 1 | ["mismatch"} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail2.json: -------------------------------------------------------------------------------- 1 | ["Unclosed array" -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail24.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail8.json: -------------------------------------------------------------------------------- 1 | ["Extra close"]] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail19.json: -------------------------------------------------------------------------------- 1 | {"Missing colon" null} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail23.json: -------------------------------------------------------------------------------- 1 | ["Bad value", truth] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail28.json: -------------------------------------------------------------------------------- 1 | ["line\ 2 | break"] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail20.json: -------------------------------------------------------------------------------- 1 | {"Double colon":: null} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail5.json: -------------------------------------------------------------------------------- 1 | ["double extra comma",,] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail6.json: -------------------------------------------------------------------------------- 1 | [ , "<-- missing value"] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail7.json: -------------------------------------------------------------------------------- 1 | ["Comma after the close"], -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail11.json: -------------------------------------------------------------------------------- 1 | {"Illegal expression": 1 + 2} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail12.json: -------------------------------------------------------------------------------- 1 | {"Illegal invocation": alert()} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail14.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot be hex": 0x14} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail21.json: -------------------------------------------------------------------------------- 1 | {"Comma instead of colon", null} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-4.json: -------------------------------------------------------------------------------- 1 | ["extra comma",] -------------------------------------------------------------------------------- /rtb/exchange/README.md: -------------------------------------------------------------------------------- 1 | # exchange 2 | Exchange related implemention goes here 3 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail15.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \x15"] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail17.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \017"] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail22.json: -------------------------------------------------------------------------------- 1 | ["Colon instead of comma": false] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail3.json: -------------------------------------------------------------------------------- 1 | {unquoted_key: "keys must be quoted"} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-27.json: -------------------------------------------------------------------------------- 1 | ["line 2 | break"] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail26.json: -------------------------------------------------------------------------------- 1 | ["tab\ character\ in\ string\ "] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail32.json: -------------------------------------------------------------------------------- 1 | {"Comma instead if closing brace": true, -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-9.json: -------------------------------------------------------------------------------- 1 | {"Extra comma": true,} -------------------------------------------------------------------------------- /jsonv/debian/libjsonv-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/lib*.so 3 | usr/lib/pkgconfig/* 4 | -------------------------------------------------------------------------------- /jsonv/doc/meme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/venediktov/vanilla-rtb/HEAD/jsonv/doc/meme.jpg -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-25.json: -------------------------------------------------------------------------------- 1 | [" tab character in string "] -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_MODULE "vanilla" 2 | #include 3 | -------------------------------------------------------------------------------- /jsonv/config/make-doxygen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | mkdir -p build/doc 3 | doxygen config/Doxyfile 4 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass2.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /examples/campaign/campaigns.json: -------------------------------------------------------------------------------- 1 | {"budget":1000000,metric:{"id":1, "value":20000},"id":123,"spent":1000} 2 | -------------------------------------------------------------------------------- /jsonv/doc/conversions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/venediktov/vanilla-rtb/HEAD/jsonv/doc/conversions.png -------------------------------------------------------------------------------- /rtb/DSL/README.md: -------------------------------------------------------------------------------- 1 | # DSL 2 | DSL formats for exchanges and other json objects implemention goes here 3 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/fail10.json: -------------------------------------------------------------------------------- 1 | {"Extra value after close": true} "misplaced quoted value" -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-13.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot have leading zeroes": 013} -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/numbers_add.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": 2, 4 | "expected": 3 5 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-18.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/booleans.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": true, 3 | "b": false, 4 | "expected": true 5 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/numbers_mixed.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 2.5, 3 | "b": 2, 4 | "expected": 4.5 5 | } -------------------------------------------------------------------------------- /jsonv/config/travisci_ecdsa.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/venediktov/vanilla-rtb/HEAD/jsonv/config/travisci_ecdsa.enc -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass-but-fail-strict-1.json: -------------------------------------------------------------------------------- 1 | "A JSON payload should be an object or array, not a string." -------------------------------------------------------------------------------- /examples/bidder/etc/config.cfg: -------------------------------------------------------------------------------- 1 | [bidder] 2 | log = /tmp/bidder_log 3 | host = 0.0.0.0 4 | port = 9081 5 | root = . 6 | timeout = 50 7 | 8 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/decimal_add.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1.0, 3 | "b": 2.0, 4 | "expected": 3.0, 5 | "recursive": 3 6 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/nulls.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": null, 3 | "b": null, 4 | "expected": null, 5 | "recursive": null 6 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/strings_append.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "Hello, ", 3 | "b": "world!", 4 | "expected": "Hello, world!" 5 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/numbers_coerce.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": "2", 4 | "expected": "FAILURE", 5 | "recursive": 3 6 | } -------------------------------------------------------------------------------- /examples/UI/CampaignBudgetsCDN/images/vanilla.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/venediktov/vanilla-rtb/HEAD/examples/UI/CampaignBudgetsCDN/images/vanilla.jpg -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/boolean_integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": false, 3 | "b": 1, 4 | "expected": "FAILURE", 5 | "recursive": true 6 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/strings_append_coerce.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "hi", 3 | "b": 4, 4 | "expected": "FAILURE", 5 | "recursive": "hi4" 6 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/array_appends.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [ 1, 2, 3, 4 ], 3 | "b": [ 5, 6, 7, 8 ], 4 | "expected": [ 1, 2, 3, 4, 5, 6, 7, 8 ] 5 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/type_mixing.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [ 1, 2, 3 ], 3 | "b": "yo", 4 | "expected": "FAILURE", 5 | "recursive": [ 1, 2, 3, "yo" ] 6 | } -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/object_mix_extra.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { }, 3 | "b": [], 4 | "expected": "FAILURE", 5 | "recursive": { "undefined": [] } 6 | } 7 | -------------------------------------------------------------------------------- /jsonv/debian/changelog: -------------------------------------------------------------------------------- 1 | libjsonv (1.0.0-pre0-1) unstable; urgency=low 2 | 3 | * Initial Release. 4 | 5 | -- Remy Chibois Wed, 11 Mar 2015 16:08:47 +0100 6 | -------------------------------------------------------------------------------- /jsonv/msvc/vs2015/jsonv-tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /jsonv/msvc/vs2015/jsonv/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | ### Diagram of targeting filters used in examples 2 | ![alt text](https://raw.githubusercontent.com/wiki/venediktov/vanilla-rtb/images/vanilla-relational-cache-latest.png) 3 | -------------------------------------------------------------------------------- /jsonv/config/travisci_ecdsa.pub: -------------------------------------------------------------------------------- 1 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBI5T5Zk1kSHI2zFdOau/oPLTVxqYJYG44f6ukA0bbl7kySji/wWr24hxRCdFNvXlDVotodYi6ytJ5D9jGeP4y2k= travis@gockelhut.com 2 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass3.json: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": { 3 | "The outermost value": "must be an object or array.", 4 | "In this test": "It is an object." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/integer_same.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": 5, 4 | "right": 5 5 | }, 6 | "result": { 7 | "same": 5, 8 | "left": null, 9 | "right": null 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /docker/vanilla-base.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | LABEL Description="VanillaRTB Base" Vendor="ForkBid" Maintainer="mrbald@github" 3 | RUN apt-get update && apt-get -yq --no-install-suggests --no-install-recommends install -y apt-utils 4 | CMD ["bash"] 5 | -------------------------------------------------------------------------------- /docker/vanilla-runtime.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM vanillartb/vanilla-base:0.0.2 2 | ARG BOOST_VERSION=1.67.0 3 | ARG WORK_ROOT=/root 4 | LABEL Description="VanillaRTB Runtime" Vendor="ForkBid" Maintainer="mrbald@github" 5 | ADD deps ${WORK_ROOT}/deps 6 | CMD ["bash"] 7 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/numbers_mixed_same.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": 4.0, 4 | "right": 4 5 | }, 6 | "result": { 7 | "same": 4, 8 | "left": null, 9 | "right": null 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/string_same.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": "same", 4 | "right": "same" 5 | }, 6 | "result": { 7 | "same": "same", 8 | "left": null, 9 | "right": null 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/different_kinds.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": 5, 4 | "right": "something" 5 | }, 6 | "result": { 7 | "same": null, 8 | "left": 5, 9 | "right": "something" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/arrays_same.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": [3, 4, 5, 6], 4 | "right": [3, 4, 5, 6] 5 | }, 6 | "result": { 7 | "same": [3, 4, 5, 6], 8 | "left": null, 9 | "right": null 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/libjsonv.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: libjsonv 7 | Description: JSON Voorhees 8 | Version: @JSONV_VERSION@ 9 | Libs: -L${libdir} -ljsonv 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /docker/vanilla-prod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM vanillartb/vanilla-runtime:0.0.2 2 | ARG VANILLA_RTB_VERSION=snapshot 3 | ARG WORK_ROOT=/root 4 | LABEL Description="VanillaRTB Prod" Vendor="ForkBid" Maintainer="mrbald@github" 5 | ADD pkg ${WORK_ROOT}/pkg 6 | WORKDIR ${WORK_ROOT}/pkg/vanilla-rtb-${VANILLA_RTB_VERSION}/bin 7 | CMD ["bash"] 8 | -------------------------------------------------------------------------------- /examples/campaign/curl_win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | output=`curl -X GET -H "Content-Type: application/json" "http://localhost:12081/win/details?price=100&campaign_id=123" 2> /dev/null` 4 | echo $output 5 | 6 | output=`curl -X GET -H "Content-Type: application/json" "http://localhost:12081/status.html" 2> /dev/null` 7 | 8 | echo $output 9 | -------------------------------------------------------------------------------- /jsonv/AUTHORS: -------------------------------------------------------------------------------- 1 | Created By: 2 | Travis Gockel 3 | 4 | Maintained by: 5 | Travis Gockel 6 | 7 | Contributions by: 8 | Remy Chibois - Debian packaging, bugfixes 9 | sth - bugfixes 10 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/arrays_different.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": [1, 2, 3, 4, 5], 4 | "right": [1, 1, 2, 3, 5] 5 | }, 6 | "result": { 7 | "same": [1, null, null, null, 5], 8 | "left": [null, 2, 3, 4, null], 9 | "right": [null, 1, 2, 3, null] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/objects_same.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": { "a": null, "b": true, "c": "see" }, 4 | "right": { "a": null, "b": true, "c": "see" } 5 | }, 6 | "result": { 7 | "same": { "a": null, "b": true, "c": "see" }, 8 | "left": null, 9 | "right": null 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/arrays_different_left_longer.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": [1, 2, 3, 4, 5, 6, 7], 4 | "right": [1, 1, 2, 3, 5] 5 | }, 6 | "result": { 7 | "same": [1, null, null, null, 5], 8 | "left": [null, 2, 3, 4, null, 6, 7], 9 | "right": [null, 1, 2, 3, null] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/arrays_different_right_longer.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": [1, 2, 3, 4, 5], 4 | "right": [1, 1, 2, 3, 5, 8, 13] 5 | }, 6 | "result": { 7 | "same": [1, null, null, null, 5], 8 | "left": [null, 2, 3, 4, null], 9 | "right": [null, 1, 2, 3, null, 8, 13] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/paths.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": ".a", 3 | "b": [ 4 | ".b[0]", 5 | ".b[1]", 6 | [ 7 | ".b[2][0]", 8 | { 9 | "x": ".b[2][1].x" 10 | }, 11 | ".b[2][2]" 12 | ] 13 | ], 14 | "c": { 15 | "d e": ".c[\"d e\"]" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/objects_different_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": { "a": null, "b": true, "c": "see" }, 4 | "right": { "a": null, "b": true, "d": "see" } 5 | }, 6 | "result": { 7 | "same": { "a": null, "b": true }, 8 | "left": { "c": "see" }, 9 | "right": { "d": "see" } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/objects_different_values.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": { "a": null, "b": true, "c": "see" }, 4 | "right": { "a": null, "b": true, "c": "dee" } 5 | }, 6 | "result": { 7 | "same": { "a": null, "b": true }, 8 | "left": { "c": "see" }, 9 | "right": { "c": "dee" } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jsonv/config/upload-coverage: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | coveralls \ 3 | --build-root . \ 4 | --exclude-pattern test \ 5 | --exclude-pattern bits \ 6 | --exclude-pattern boost \ 7 | --gcov-options '\-lp' --gcov 'gcov-4.8' 8 | -------------------------------------------------------------------------------- /CRUD/service/spin_lock.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | 7 | class spin_lock { 8 | std::atomic_flag locked = ATOMIC_FLAG_INIT ; 9 | public: 10 | void lock() { 11 | while (locked.test_and_set(std::memory_order_acquire)) { ; } 12 | } 13 | void unlock() { 14 | locked.clear(std::memory_order_release); 15 | } 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /docker_swarm/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | bidder: 4 | image: localhost:5000/vanilla-dev 5 | tty: true 6 | working_dir: /root/pkg/vanilla-rtb/snapshot/bin 7 | command: ./http_bidder_test --config etc/config.cfg 8 | deploy: 9 | replicas: 5 10 | restart_policy: 11 | condition: on-failure 12 | ports: 13 | - 9081:9081 14 | 15 | -------------------------------------------------------------------------------- /rtb/core/core.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: core.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 17 апреля 2017 г., 23:34 6 | */ 7 | 8 | #ifndef CORE_HPP 9 | #define CORE_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define LOG(x) BOOST_LOG_TRIVIAL(x) 16 | 17 | #endif /* CORE_HPP */ 18 | 19 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/optional_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "test.hpp" 2 | 3 | #include 4 | 5 | namespace jsonv_test 6 | { 7 | 8 | TEST(optional_none) 9 | { 10 | jsonv::optional x = jsonv::nullopt; 11 | ensure(!x); 12 | } 13 | 14 | TEST(optional_something) 15 | { 16 | jsonv::optional x = 1; 17 | ensure(bool(x)); 18 | ensure_eq(1, *x); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/arrays_different_recursive.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": [[1, 1], [2, 2], [3, 3], [4, 4]], 4 | "right": [[1, 1], [2, 4], [3, 9], [4, 16]] 5 | }, 6 | "result": { 7 | "same": [[1, 1], [2, null], [3, null], [4, null]], 8 | "left": [null, [null, 2], [null, 3], [null, 4]], 9 | "right": [null, [null, 4], [null, 9], [null, 16]] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 1. read issues and milestones 2 | 2. identify if this issue was already discussed 3 | 3. talk to our existing team and find out if anyone is working on this issue 4 | 4. If no one in our team is working on the issue: 5 | - fork repository 6 | - make changes ( make sure your changes have enough comments for us to understand ) 7 | - create a pull request referencing issue # 8 | - wait for your pull request review 9 | 5. Done 10 | -------------------------------------------------------------------------------- /jsonv/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.1.{build} 2 | os: Visual Studio 2015 3 | platform: 4 | - Win32 5 | - x64 6 | configuration: 7 | - Debug 8 | - Release 9 | install: 10 | - cmd: msbuild /version 11 | clone_folder: C:\projects\json-voorhees 12 | before_build: 13 | - cmd: cd C:\projects\json-voorhees\msvc\vs2015 14 | - cmd: nuget restore 15 | build: 16 | project: C:\projects\json-voorhees\msvc\vs2015\JsonVoorhees.sln 17 | test_script: 18 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/stopwatch.cpp: -------------------------------------------------------------------------------- 1 | #include "chrono_io.hpp" 2 | #include "stopwatch.hpp" 3 | 4 | #include 5 | 6 | namespace jsonv_test 7 | { 8 | 9 | std::ostream& operator<<(std::ostream& os, const stopwatch::values& x) 10 | { 11 | os << "{\"total\": \"" << x.sum << '\"'; 12 | os << ", \"count\": " << x.count; 13 | os << ", \"mean\": \"" << x.mean << '\"'; 14 | os << '}'; 15 | return os; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/diffs/objects_different_recursive.json: -------------------------------------------------------------------------------- 1 | { 2 | "input": { 3 | "left": { "a": null, "b": [1, 2, 3, 4], "c": { "something": {} }, "d": { "else": 4} }, 4 | "right": { "a": null, "b": [2, 4, 6, 8], "c": { "something": {} }, "d": { "else": 5} } 5 | }, 6 | "result": { 7 | "same": { "a": null, "c": { "something": {} } }, 8 | "left": { "b": [1, 2, 3, 4], "d": { "else": 4 } }, 9 | "right": { "b": [2, 4, 6, 8], "d": { "else": 5 } } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/campaign/curl_campaign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | output=`curl -X PUT -H "Content-Type: application/json" --data @campaigns.json http://localhost:11081/campaign/budget/id/123 2> /dev/null` 4 | echo $output 5 | output=`curl -X GET -H "Content-Type: application/json" --data @campaigns.json http://localhost:11081/campaign/budget/id/123 2> /dev/null` 6 | echo $output 7 | output=`curl -X GET -H "Content-Type: application/json" --data @campaigns.json http://localhost:11081/campaign/budget 2> /dev/null` 8 | echo $output 9 | 10 | 11 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/object_simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "one": 1, 4 | "three": 3, 5 | "array": [ 4, 5, 6 ] 6 | }, 7 | "b": { 8 | "two": 2, 9 | "object": { "a": 1 } 10 | }, 11 | "expected": { 12 | "one": 1, 13 | "three": 3, 14 | "array": [ 4, 5, 6 ], 15 | "two": 2, 16 | "object": { "a": 1 } 17 | }, 18 | "recursive": { 19 | "one": 1, 20 | "three": 3, 21 | "array": [ 4, 5, 6 ], 22 | "two": 2, 23 | "object": { "a": 1 } 24 | } 25 | } -------------------------------------------------------------------------------- /examples/loader/curl_loader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/geo 2> /dev/null` 4 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/geo_campaign 2> /dev/null` 5 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/ad 2> /dev/null` 6 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/budget 2> /dev/null` 7 | #output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/ 2> /dev/null` 8 | 9 | echo $output 10 | 11 | -------------------------------------------------------------------------------- /examples/loader/ico_curl_loader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/ico_cache_loader/ico_ref 2> /dev/null` 4 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/ico_cache_loader/ico_campaign 2> /dev/null` 5 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/ico_cache_loader/budget 2> /dev/null` 6 | output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/ad 2> /dev/null` 7 | #output=`curl -X PUT -H "Content-Type: application/json" http://localhost:10081/cache_loader/ 2> /dev/null` 8 | 9 | echo $output 10 | 11 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(Threads REQUIRED) 2 | 3 | SET(Boost_USE_MULTITHREADED ON) 4 | FIND_PACKAGE(Boost REQUIRED COMPONENTS unit_test_framework REQUIRED) 5 | ADD_DEFINITIONS("-DBOOST_TEST_DYN_LINK") 6 | 7 | ADD_EXECUTABLE(vanilla_tests 8 | vanilla_all.cpp 9 | main.cpp) 10 | 11 | TARGET_INCLUDE_DIRECTORIES(vanilla_tests SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) 12 | LINK_DIRECTORIES(vanilla_tests ${Boost_LIBRARY_DIRS}) 13 | TARGET_LINK_LIBRARIES(vanilla_tests ${Boost_LIBRARIES}) 14 | 15 | ADD_CUSTOM_TARGET(unit-test vanilla_tests DEPENDS vanilla_tests USES_TERMINAL) 16 | 17 | ADD_TEST(ctest_vanilla_tests "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target unit-test) 18 | -------------------------------------------------------------------------------- /docker/vanilla-deps.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM vanillartb/vanilla-base:0.0.2 2 | ARG BOOST_VERSION=1.67.0 3 | ARG WORK_ROOT=/root 4 | LABEL Description="VanillaRTB Dependencies Builder" Vendor="ForkBid" Maintainer="mrbald@github" 5 | RUN apt-get install -yq --no-install-suggests --no-install-recommends wget build-essential g++-7 6 | ENV CC=gcc-7 CXX=g++-7 7 | 8 | WORKDIR ${WORK_ROOT}/scripts 9 | ADD build-boost.sh ${WORK_ROOT}/scripts 10 | RUN chmod +x ${WORK_ROOT}/scripts/build-boost.sh && sync 11 | 12 | WORKDIR ${WORK_ROOT}/deps 13 | WORKDIR ${WORK_ROOT}/build 14 | RUN env DEPS_DIR=${WORK_ROOT}/deps BUILD_DIR=${WORK_ROOT}/build BOOST_VERSION=${BOOST_VERSION} ${WORK_ROOT}/scripts/build-boost.sh 15 | 16 | CMD ["bash"] 17 | -------------------------------------------------------------------------------- /examples/UI/CampaignBudgetsCDN/scripts/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('budgetsApp', ['ui.router','ngResource']) 4 | .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { 5 | $stateProvider 6 | 7 | // route for the home page 8 | .state('app', { 9 | url:'/', 10 | views: { 11 | 12 | 'content': { 13 | templateUrl : 'views/header.html', 14 | controller : 'JumboController' 15 | } 16 | 17 | } 18 | 19 | }); 20 | 21 | $urlRouterProvider.otherwise('/'); 22 | }]) 23 | ; -------------------------------------------------------------------------------- /jsonv/include/jsonv/extract.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/extract.hpp 2 | * Extract a C++ class from a JSON value. 3 | * 4 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_EXTRACT_HPP_INCLUDED__ 13 | #define __JSONV_EXTRACT_HPP_INCLUDED__ 14 | 15 | #include 16 | 17 | namespace jsonv 18 | { 19 | 20 | 21 | } 22 | 23 | #endif/*__JSONV_EXTRACT_HPP_INCLUDED__*/ 24 | -------------------------------------------------------------------------------- /benchmarks/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Vladimir Lysyy (mrbald@github) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | BENCHMARK_MAIN(); 20 | -------------------------------------------------------------------------------- /examples/multiexchange/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | add_executable( 4 | multi_exchange_handler 5 | multi_exchange_handler.cpp 6 | ) 7 | 8 | if (WIN32) 9 | target_compile_definitions(multi_exchange_handler PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 10 | target_compile_definitions(jsonv PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 11 | endif(WIN32) 12 | 13 | target_link_libraries( 14 | multi_exchange_handler 15 | crud_service 16 | vanilla_rtb 17 | jsonv 18 | parsers 19 | ${Boost_LIBRARIES} 20 | ${CMAKE_THREAD_LIBS_INIT} 21 | ) 22 | 23 | install(TARGETS multi_exchange_handler 24 | RUNTIME DESTINATION bin 25 | LIBRARY DESTINATION lib 26 | ) 27 | 28 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/README.md: -------------------------------------------------------------------------------- 1 | Data in this directory is from the [JSON_Checker](http://json.org/JSON_checker/) test data. 2 | 3 | There are 3 kinds of files in this directory, all with different patterns: 4 | 5 | - `pass${#}.json`: These are valid JSON files and should be parsed by JSON Voorhees. 6 | - `fail${#}.json`: These are invalid JSON files that should be rejected with a `jsonv::parse_error`. 7 | - `pass-but-fail-strict-${#}.json`: These are invalid JSON files that the default JSON Voorhees parser will happily 8 | parse, but should be rejected in strict parsing mode (which does not exist). 9 | There is [an issue](https://github.com/tgockel/json-voorhees/issues/16) to think about or potentially do something 10 | about these files. 11 | -------------------------------------------------------------------------------- /CRUD/service/header.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // header.hpp 3 | // ~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef HTTP_HEADER_HPP 12 | #define HTTP_HEADER_HPP 13 | 14 | #include 15 | 16 | namespace http { 17 | namespace server { 18 | 19 | struct header 20 | { 21 | std::string name; 22 | std::string value; 23 | header() 24 | {} 25 | header(const std::string &name, const std::string &value) : name{name}, value{value} 26 | {} 27 | }; 28 | 29 | } // namespace server 30 | } // namespace http 31 | 32 | #endif // HTTP_HEADER_HPP 33 | -------------------------------------------------------------------------------- /examples/bidder_experimental/ICO_BID_REQUEST_BANNER.json: -------------------------------------------------------------------------------- 1 | {"id": "ssp1-27009141-1485848975137","at": 2,"imp": [{"id": "1","bidfloor": 13.521766169371157,"bidfloorcur": "RUB","banner": {"pos": 0,"h": 100,"w": 300},"secure": 0}],"site": {"id": "10930","domain": "https://www.coinbase.com","ref": "https://www.coinbase.com/new_to_bitcoin","publisher": {"id": "9886"},"ext": {"place_id": 79170},"cat": ["IAB12"]},"device": {"ua": "Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) YaBrowser/16.11.0.2708.11 Mobile/13G36 Safari/601.1","ip": "84.234.53.206","make": "Apple","model": "iPad","os": "iOS","osv": "9.0","devicetype": 5},"user": {"id": "35e4f8a5-e897-4589-a075-bc2c8acd7e1e","buyeruid": "6331632281203562848","geo": {"type": 2,"city": "Moscow","region": "MD-BD","country": "Russia"}}} 2 | -------------------------------------------------------------------------------- /examples/bidder/BID_REQUEST_BANNER.json: -------------------------------------------------------------------------------- 1 | {"id": "ssp1-27009141-1485848975137","at": 2,"imp": [{"id": "1","bidfloor": 13.521766169371157,"bidfloorcur": "RUB","banner": {"pos": 0,"h": 100,"w": 300},"secure": 0}],"site": {"id": "10930","domain": "warfiles.ru","ref": "http://warfiles.ru/show-142725-rossiya-vpervye-ispytala-noveyshuyu-aviabombu-drel-v-sirii.html","publisher": {"id": "9886"},"ext": {"place_id": 79170},"cat": ["IAB12"]},"device": {"ua": "Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) YaBrowser/16.11.0.2708.11 Mobile/13G36 Safari/601.1","ip": "84.234.53.206","make": "Apple","model": "iPad","os": "iOS","osv": "9.0","devicetype": 5},"user": {"id": "35e4f8a5-e897-4589-a075-bc2c8acd7e1e","buyeruid": "6331632281203562848","geo": {"type": 2,"city": "Moscow","region": "MD-BD","country": "Russia"}}} 2 | -------------------------------------------------------------------------------- /rtb/core/bid_request.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: bid_request.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 10 марта 2017 г., 23:08 6 | */ 7 | 8 | #ifndef BID_REQUEST_HPP 9 | #define BID_REQUEST_HPP 10 | 11 | #include "openrtb.hpp" 12 | 13 | namespace vanilla { 14 | template 15 | struct BidRequest { 16 | using request_type = typename DSL::deserialized_type; 17 | request_type bid_request; 18 | UserInfo user_info; 19 | 20 | BidRequest &operator=(const request_type &req) { 21 | bid_request = req; 22 | return *this; 23 | } 24 | 25 | const request_type& request() const { 26 | return bid_request; 27 | } 28 | }; 29 | } 30 | 31 | #endif /* BID_REQUEST_HPP */ 32 | 33 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/merges/object_keyshare.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": { 3 | "a": "a", 4 | "b": null, 5 | "array": [ 1, 2, 3 ], 6 | "object": { 7 | "a": "a", 8 | "array": [ 1, 2 ] 9 | }, 10 | "string": "ab" 11 | }, 12 | "b": { 13 | "a": null, 14 | "b": "b", 15 | "array": [ 4, 5, 6 ], 16 | "object": { 17 | "b": "b", 18 | "array": [ 3, 4 ] 19 | }, 20 | "string": "cd" 21 | }, 22 | "expected": "FAILURE", 23 | "recursive": { 24 | "a": "a", 25 | "b": "b", 26 | "array": [ 1, 2, 3, 4, 5, 6 ], 27 | "object": { 28 | "a": "a", 29 | "b": "b", 30 | "array": [ 1, 2, 3, 4 ] 31 | }, 32 | "string": "abcd" 33 | } 34 | } -------------------------------------------------------------------------------- /examples/UI/CampaignBudgetsCDN/styles/mystyles.css: -------------------------------------------------------------------------------- 1 | td input {width: 100%} 2 | 3 | .idWidth input {min-width: 55px} 4 | 5 | /*.budgetWidth input {max-width: 100px; min-width: 55px}*/ 6 | 7 | /*.spentWidth input {max-width: 100px; min-width: 55px}*/ 8 | 9 | /*.cpmWidth input {max-width: 100px; min-width: 55px}*/ 10 | .cpmWidth select {max-width: 75px; min-width: 75px } 11 | 12 | #date { 13 | color: #2b3541; 14 | font-weight: bolder; 15 | } 16 | body { 17 | padding-top: 500px; 18 | } 19 | 20 | .row-content { 21 | margin: 0px auto; 22 | padding: 50px 0px; 23 | border-bottom: 1px ridge; 24 | min-height: 400px; 25 | } 26 | 27 | 28 | 29 | .navbar { 30 | background: #F3E5AB; 31 | color: #ffffff; 32 | } 33 | 34 | 35 | 36 | body { 37 | align: center; 38 | padding: 50px 0px 0px 0px; 39 | z-index: 0; 40 | } 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/bidder_experimental/config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: config.hpp 3 | */ 4 | 5 | #ifndef ICO_BIDDER_CONFIG_HPP 6 | #define ICO_BIDDER_CONFIG_HPP 7 | 8 | struct ico_bidder_config_data { 9 | std::string log_file_name; 10 | std::string ads_source; 11 | std::string ads_ipc_name; 12 | std::string domain_source; 13 | std::string domain_ipc_name; 14 | std::string ico_campaign_ipc_name; 15 | std::string ico_campaign_source; 16 | std::string campaign_budget_source; 17 | std::string ipc_name; 18 | int timeout; 19 | unsigned int concurrency; 20 | short port; 21 | std::string host; 22 | std::string root; 23 | short num_of_bidders; 24 | 25 | ico_bidder_config_data() : timeout{}, concurrency{}, port{}, num_of_bidders{} 26 | {} 27 | }; 28 | 29 | #endif /* ICO_BIDDER_CONFIG_HPP */ 30 | 31 | -------------------------------------------------------------------------------- /jsonv/doc/conversions.dot: -------------------------------------------------------------------------------- 1 | digraph jsonv { 2 | label="Conversions" 3 | labelloc="t" 4 | 5 | str [label="std::string"] 6 | istream [label="std::istream"] 7 | ostream [label="std::ostream"] 8 | value [label="value", URL="\ref jsonv::value"] 9 | class [label="C++ class"] 10 | dsl [label="C++ DSL"] 11 | 12 | value -> str [label="to_string", URL="\ref jsonv::to_string(jsonv::value)"] 13 | value -> ostream [label="operator<<"] 14 | str -> value [label="parse", URL="\ref jsonv::parse"] 15 | istream -> value [label="parse", URL="\ref jsonv::parse"] 16 | value -> value [label="map, merge, diff, ..."] 17 | value -> class [label="extract", URL="\ref jsonv::extract"] 18 | class -> value [label="to_json", URL="\ref jsonv::to_json"] 19 | dsl -> value [label="value, object, array"] 20 | } 21 | -------------------------------------------------------------------------------- /examples/bidder/mock_exchange/data.json.template: -------------------------------------------------------------------------------- 1 | {"id": "ssp1-27009141-1485848975137","at": 2,"imp": [{"id": "1","bidfloor": 13.521766169371157,"bidfloorcur": "RUB","banner": {"pos": 0,"h": %(height)d,"w": %(width)d},"secure": 0}],"site": {"id": "10930","domain": "warfiles.ru","ref": "http://warfiles.ru/show-142725-rossiya-vpervye-ispytala-noveyshuyu-aviabombu-drel-v-sirii.html","publisher": {"id": "9886"},"ext": {"place_id": 79170},"cat": ["IAB12"]},"device": {"ua": "Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) YaBrowser/16.11.0.2708.11 Mobile/13G36 Safari/601.1","ip": "84.234.53.206","make": "Apple","model": "iPad","os": "iOS","osv": "9.0","devicetype": 5},"user": {"id": "35e4f8a5-e897-4589-a075-bc2c8acd7e1e","buyeruid": "6331632281203562848","geo": {"type": 2,"city": "%(city)s","region": "MD-BD","country": "%(country)s"}}} 2 | -------------------------------------------------------------------------------- /CRUD/service/request.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // request.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef HTTP_REQUEST_HPP 12 | #define HTTP_REQUEST_HPP 13 | 14 | #include 15 | #include 16 | #include "header.hpp" 17 | 18 | namespace http { 19 | namespace server { 20 | 21 | /// A request received from a client. 22 | struct request 23 | { 24 | std::string method; 25 | std::string uri; 26 | int http_version_major; 27 | int http_version_minor; 28 | std::vector
headers; 29 | std::string data; 30 | }; 31 | 32 | } // namespace server 33 | } // namespace http 34 | 35 | #endif // HTTP_REQUEST_HPP 36 | -------------------------------------------------------------------------------- /rtb/core/user_info.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: user_info.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 10 марта 2017 г., 23:18 6 | */ 7 | 8 | #ifndef USER_INFO_HPP 9 | #define USER_INFO_HPP 10 | 11 | #include 12 | #include "rtb/core/bid_request.hpp" 13 | #include "rtb/DSL/generic_dsl.hpp" 14 | 15 | namespace vanilla { 16 | struct UserInfo { 17 | std::string user_id{}; 18 | std::string user_data{}; 19 | }; 20 | 21 | using VanillaRequest = vanilla::BidRequest, vanilla::UserInfo>; 22 | } 23 | 24 | 25 | 26 | namespace boost { namespace serialization { 27 | template 28 | void serialize(Archive & ar, vanilla::UserInfo & value, const unsigned int version) { 29 | ar & value.user_id; 30 | ar & value.user_data; 31 | } 32 | }} 33 | #endif /* USER_INFO_HPP */ 34 | 35 | -------------------------------------------------------------------------------- /CRUD/service/mime_types.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // mime_types.cpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Modified by: Vladimir Venediktov 11 | // Introducing constexpr for mapping see mime_types.hpp 12 | // 13 | 14 | #include "mime_types.hpp" 15 | 16 | namespace http { 17 | namespace server { 18 | namespace mime_types { 19 | 20 | std::string extension_to_type(const std::string& extension) 21 | { 22 | for (mapping m: mappings) 23 | { 24 | if (m.extension == extension) 25 | { 26 | return m.mime_type; 27 | } 28 | } 29 | 30 | return "text/plain"; 31 | } 32 | 33 | } // namespace mime_types 34 | } // namespace server 35 | } // namespace http 36 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/functional.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "detail.hpp" 18 | 19 | namespace jsonv 20 | { 21 | 22 | int value_compare::operator()(const value& a, const value& b) const 23 | { 24 | return compare(a, b); 25 | } 26 | 27 | int value_compare_icase::operator()(const value& a, const value& b) const 28 | { 29 | return compare_icase(a, b); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /docker/vanilla-dev.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM vanillartb/vanilla-runtime:0.0.2 2 | ARG BOOST_VERSION=1.67.0 3 | ARG VANILLA_RTB_VERSION=snapshot 4 | ARG WORK_ROOT=/root 5 | LABEL Description="vanilla-rtb Dev" Vendor="ForkBid" Maintainer="mrbald@github" 6 | RUN apt-get update 7 | RUN apt-get install -yq --no-install-suggests --no-install-recommends make cmake git build-essential g++-7 vim python 8 | ENV CC=gcc-7 CXX=g++-7 9 | 10 | WORKDIR ${WORK_ROOT}/scripts 11 | ADD build-vanilla.sh ${WORK_ROOT}/scripts 12 | RUN chmod +x ${WORK_ROOT}/scripts/build-vanilla.sh && sync 13 | 14 | WORKDIR ${WORK_ROOT}/deps 15 | WORKDIR ${WORK_ROOT}/build 16 | RUN env VANILLA_RTB_VERSION=${VANILLA_RTB_VERSION} PKG_DIR=${WORK_ROOT}/pkg DEPS_DIR=${WORK_ROOT}/deps BUILD_DIR=${WORK_ROOT}/build BOOST_VERSION=${BOOST_VERSION} ${WORK_ROOT}/scripts/build-vanilla.sh 17 | 18 | WORKDIR /root/pkg/vanilla-rtb-${VANILLA_RTB_VERSION}/bin 19 | 20 | CMD ["bash"] 21 | -------------------------------------------------------------------------------- /examples/campaign/serialization.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: serialization.hpp 3 | * Author: Vladimir Venediktov 4 | * 5 | * Created on March 12, 2017, 10:20 PM 6 | */ 7 | 8 | #ifndef CAMPAIGN_SERIALIZATION_HPP 9 | #define CAMPAIGN_SERIALIZATION_HPP 10 | 11 | 12 | //Non-Intrusive boost serialization implementation 13 | namespace boost { namespace serialization { 14 | template 15 | void serialize(Archive & ar, vanilla::CampaignBudget & value, const unsigned int) { 16 | ar & value.campaign_id; 17 | ar & value.day_budget_limit; 18 | ar & value.day_budget_spent; 19 | ar & value.metric; 20 | } 21 | template 22 | void serialize(Archive & ar, vanilla::CampaignBudget::Metric & metric, const unsigned int) { 23 | ar & metric.type; 24 | ar & metric.value; 25 | } 26 | }} 27 | 28 | #endif /* CAMPAIGN_SERIALIZATION_HPP */ 29 | 30 | -------------------------------------------------------------------------------- /tests/vanilla_all.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace { 5 | 6 | namespace utf = boost::unit_test; 7 | 8 | BOOST_AUTO_TEST_SUITE(vanilla_all) 9 | 10 | BOOST_AUTO_TEST_CASE(green_test, *utf::description("good passing test")) { 11 | BOOST_TEST_MESSAGE("I am a good test, I am passing"); 12 | BOOST_REQUIRE_THROW(throw std::runtime_error{"indentionally thrown"}, std::runtime_error); 13 | BOOST_REQUIRE_EQUAL(42, 42); 14 | } // BOOST_AUTO_TEST_CASE(green_test) 15 | 16 | BOOST_AUTO_TEST_CASE(red_test, 17 | *utf::disabled() 18 | *utf::description("requires network")) { 19 | BOOST_TEST_MESSAGE("I am a bad test, I am failing"); 20 | BOOST_CHECK_EQUAL(42, 43); // "soft" assertion 21 | BOOST_REQUIRE_EQUAL(43, 44); 22 | } // BOOST_AUTO_TEST_CASE(red_test) 23 | 24 | BOOST_AUTO_TEST_SUITE_END(/* vanilla_all */) 25 | 26 | } // local namespace 27 | -------------------------------------------------------------------------------- /jsonv/config/publish-doxygen: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Settings 4 | REPO_PATH=git@github.com:tgockel/json-voorhees.git 5 | HTML_PATH=build/doc/html 6 | COMMIT_USER="Documentation Builder" 7 | COMMIT_EMAIL="travis@gockelhut.com" 8 | CHANGESET=$(git rev-parse --verify HEAD) 9 | 10 | # Get a clean version of the HTML documentation repo. 11 | rm -rf ${HTML_PATH} 12 | mkdir -p ${HTML_PATH} 13 | git clone -b gh-pages "${REPO_PATH}" --single-branch ${HTML_PATH} 14 | 15 | # rm all the files through git to prevent stale files. 16 | cd ${HTML_PATH} 17 | git rm -rf . 18 | cd - 19 | 20 | # Generate the HTML documentation. 21 | ./config/make-doxygen 22 | 23 | # Create and commit the documentation repo. 24 | cd ${HTML_PATH} 25 | git add . 26 | git config user.name "${COMMIT_USER}" 27 | git config user.email "${COMMIT_EMAIL}" 28 | git commit -m "Automated documentation build for changeset ${CHANGESET}." 29 | git push origin gh-pages 30 | cd - 31 | -------------------------------------------------------------------------------- /examples/bidder/generator/campaign_budget.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import random 3 | import sys 4 | #import argparse 5 | 6 | #format 7 | # id\tday_budget\day budget spentday_show_limit\tday_click_limit 8 | campaigns = 1000 9 | budget = [100, 10000000000] 10 | metrics = { 11 | 'CPM': {'id': 1, 'limit': [0, 1000000]}, 12 | 'CPC': {'id': 2, 'limit': [0, 1000]} 13 | } 14 | 15 | for campaign_id in range(1, campaigns+1): 16 | campaign_budget = random.randint(budget[0], budget[1]) 17 | metric = random.choice(list(metrics)) #make it run on both python 2.x and 3.x 18 | print("%(id)s\t%(budget)s\t%(spent)s\t%(metric)s\t%(limit)s" % { 19 | 'id' : campaign_id, 20 | 'budget' : campaign_budget, 21 | 'spent': random.randint(0, campaign_budget), 22 | 'metric' : metrics[metric]['id'], 23 | 'limit' : random.randint(metrics[metric]['limit'][0], metrics[metric]['limit'][1]) 24 | }) 25 | 26 | -------------------------------------------------------------------------------- /jsonv/debian/control: -------------------------------------------------------------------------------- 1 | Source: libjsonv 2 | Priority: optional 3 | Maintainer: Remy Chibois 4 | Build-Depends: debhelper (>= 9), cmake 5 | Standards-Version: 3.9.5 6 | Section: libs 7 | Homepage: https://github.com/tgockel/jsonv 8 | 9 | Package: libjsonv-dev 10 | Section: libdevel 11 | Architecture: any 12 | Depends: libjsonv1.0.0 (= ${binary:Version}), ${misc:Depends} 13 | Description: development files for jsonv 14 | Yet another JSON library for C++. 15 | This one touts new C++11 features for developer-friendliness, 16 | an extremely high-speed parser and no dependencies beyond a compliant compiler. 17 | 18 | Package: libjsonv1.0.0 19 | Architecture: any 20 | Depends: ${shlibs:Depends}, ${misc:Depends} 21 | Description: Killer modern C++ library for interacting with JSON 22 | Yet another JSON library for C++. 23 | This one touts new C++11 features for developer-friendliness, 24 | an extremely high-speed parser and no dependencies beyond a compliant compiler. 25 | -------------------------------------------------------------------------------- /docker_swarm/swarm-persist-with-haproxy.yaml: -------------------------------------------------------------------------------- 1 | version: "3.3" 2 | services: 3 | bidder: 4 | image: localhost:5000/vanilla-dev 5 | tty: true 6 | working_dir: /root/pkg/vanilla-rtb/snapshot/bin 7 | command: ./http_bidder_test --config etc/config.cfg 8 | environment: 9 | - SERVICE_PORTS=9081 10 | deploy: 11 | mode: replicated 12 | replicas: 5 13 | restart_policy: 14 | condition: on-failure 15 | networks: 16 | - net 17 | ports: 18 | - 9081:9081 19 | 20 | haproxy: 21 | image: dockercloud/haproxy 22 | depends_on: 23 | - bidder 24 | environment: 25 | - BALANCE=leastconn 26 | - OPTION=http-keep-alive 27 | volumes: 28 | - /var/run/docker.sock:/var/run/docker.sock 29 | networks: 30 | - net 31 | ports: 32 | - 80:80 33 | deploy: 34 | mode: global 35 | placement: 36 | constraints: [node.role == manager] 37 | networks: 38 | net: 39 | 40 | 41 | -------------------------------------------------------------------------------- /jsonv/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #DH_VERBOSE = 1 5 | 6 | # see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* 7 | DPKG_EXPORT_BUILDFLAGS = 1 8 | include /usr/share/dpkg/default.mk 9 | 10 | # see FEATURE AREAS in dpkg-buildflags(1) 11 | #export DEB_BUILD_MAINT_OPTIONS = hardening=+all 12 | 13 | # see ENVIRONMENT in dpkg-buildflags(1) 14 | # package maintainers to append CFLAGS 15 | #export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic 16 | # package maintainers to append LDFLAGS 17 | #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed 18 | 19 | 20 | # main packaging script based on dh7 syntax 21 | %: 22 | dh $@ 23 | 24 | # debmake generated override targets 25 | # This is example for Cmake (See http://bugs.debian.org/641051 ) 26 | #override_dh_auto_configure: 27 | # dh_auto_configure -- \ 28 | # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.3.0/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.3.0 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost-libs>=1.52') 14 | checkdepends=('boost>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('0bd61e34276aedd85a4cbaabdb1bb9d1') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.3.1/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.3.1 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('9a62a2d558406b9ac8f01407b30e1a04') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.4.0/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.4.0 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('3bdb13afd3b3d7d26e83aad27bb25f92') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.4.1/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.4.1 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('2b5e5968ccde80ea4e624ff901517517') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.5.0/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.5.0 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('24be872ab4586958eaf6fc866cbfaab2') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/installer/arch/v0.5.1/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=0.5.1 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('fe524bd451e2f485090b2bec5baadca2') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | make 30 | } 31 | 32 | check() { 33 | cd "${srcdir}/${pkgname}-${pkgver}" 34 | make test 35 | } 36 | 37 | package() { 38 | cd "${srcdir}/${pkgname}-${pkgver}" 39 | make INSTALL_DIR="${pkgdir}/" install 40 | } 41 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/jsonv_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "core.hpp" 12 | 13 | #include 14 | 15 | namespace json_benchmark 16 | { 17 | 18 | class jsonv_benchmark_suite : 19 | public typed_benchmark_suite 20 | { 21 | public: 22 | jsonv_benchmark_suite() : 23 | typed_benchmark_suite("JSONV") 24 | { } 25 | 26 | protected: 27 | virtual jsonv::value parse(const std::string& source) const 28 | { 29 | return jsonv::parse(source); 30 | } 31 | 32 | } jsonv_benchmark_suite_instance; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /docker/build-vanilla.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | readonly VANILLA_RTB_PKG_DIR="${PKG_DIR}/vanilla-rtb-${VANILLA_RTB_VERSION}" 6 | readonly VANILLA_RTB_BUILD_DIR="${BUILD_DIR}/vanilla-rtb-${VANILLA_RTB_VERSION}" 7 | 8 | $(type -P rm) -rf ${VANILLA_RTB_BUILD_DIR} ${VANILLA_RTB_PKG_DIR} 9 | 10 | git -c http.sslVerify=false clone --recursive https://github.com/venediktov/vanilla-rtb.git ${VANILLA_RTB_BUILD_DIR} 11 | 12 | $(type -P mkdir) ${VANILLA_RTB_BUILD_DIR}/Release 13 | cd ${VANILLA_RTB_BUILD_DIR}/Release 14 | 15 | CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX='${VANILLA_RTB_PKG_DIR}'" 16 | if [[ ${BOOST_VERSION} != 'default' ]]; then 17 | readonly BOOST_DEPS_DIR="${DEPS_DIR}/boost-${BOOST_VERSION}" 18 | export CMAKE_OPTIONS+=" -DBOOST_ROOT='${BOOST_DEPS_DIR}'" 19 | fi 20 | 21 | cmake .. -G 'Unix Makefiles' ${CMAKE_OPTIONS} 22 | cmake --build . --target install -- -j$(nproc) -l$(nproc) 23 | 24 | cd ${BUILD_DIR} 25 | $(type -P rm) -rf ${VANILLA_RTB_BUILD_DIR} 26 | 27 | -------------------------------------------------------------------------------- /examples/loader/config.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef CACHE_LOADER_CONFIG_HPP 4 | #define CACHE_LOADER_CONFIG_HPP 5 | 6 | struct cache_loader_config_data { 7 | std::string log_file_name; 8 | std::string ads_source; 9 | std::string ads_ipc_name; 10 | std::string geo_source; 11 | std::string geo_ipc_name; 12 | std::string geo_campaign_ipc_name; 13 | std::string geo_campaign_source; 14 | std::string campaign_budget_source; 15 | std::string ipc_name; 16 | }; 17 | 18 | struct ico_cache_loader_config_data { 19 | std::string log_file_name; 20 | std::string domain_source; 21 | std::string domain_ipc_name; 22 | std::string ico_campaign_source; 23 | std::string ico_campaign_ipc_name; 24 | std::string ads_source; 25 | std::string ads_ipc_name; 26 | std::string campaign_budget_source; 27 | std::string ipc_name; 28 | }; 29 | 30 | using CacheLoadConfig = vanilla::config::config; 31 | 32 | #endif /* CACHE_LOADER_CONFIG_HPP */ 33 | 34 | -------------------------------------------------------------------------------- /examples/UI/CampaignBudgetsCDN/scripts/services.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('budgetsApp') 4 | 5 | 6 | .constant("baseURL", window.location.origin + "/campaign/") 7 | .service('budgetFactory', ['$resource', 'baseURL', function($resource, baseURL) { 8 | 9 | 10 | this.getBudgets = function () { 11 | return $resource(baseURL+"budget/:id",null, {'update':{method:'PUT'}}); 12 | }; 13 | 14 | 15 | 16 | }]) 17 | .service('budgetIdCall', ['$resource', 'baseURL', function($resource, baseURL) { 18 | this.getBudget = function () { 19 | return $resource(baseURL+"budget/id/:id", null, 20 | { 21 | 'update':{method:'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded'}}, 22 | 'new':{method:'PUT'} 23 | } 24 | ); 25 | }; 26 | }]) 27 | 28 | 29 | ; -------------------------------------------------------------------------------- /jsonv/installer/arch/v1.0.0/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | pkgname=json-voorhees 4 | pkgver=1.0.0 5 | pkgrel=1 6 | epoch= 7 | pkgdesc="A modern JSON parsing library for C++" 8 | arch=('x86_64') 9 | url="https://github.com/tgockel/json-voorhees" 10 | license=('Apache') 11 | groups=() 12 | depends=() 13 | makedepends=('gcc>=4.9' 'boost>=1.52 cmake>=2.8') 14 | checkdepends=('boost-libs>=1.48') 15 | optdepends=() 16 | provides=() 17 | conflicts=() 18 | replaces=() 19 | backup=() 20 | options=() 21 | install= 22 | changelog= 23 | source=("https://github.com/tgockel/${pkgname}/archive/v${pkgver}.tar.gz") 24 | noextract=() 25 | md5sums=('b92c91e833c19bbd4e36ec759bb600b1') # makepkg -g 26 | 27 | build() { 28 | cd "${srcdir}/${pkgname}-${pkgver}" 29 | cmake . -DCMAKE_BUILD_TYPE=Release 30 | make 31 | } 32 | 33 | check() { 34 | cd "${srcdir}/${pkgname}-${pkgver}" 35 | ./jsonv-tests 36 | } 37 | 38 | package() { 39 | cd "${srcdir}/${pkgname}-${pkgver}" 40 | make DESTDIR="${pkgdir}/" install 41 | } 42 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/demangle_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | namespace jsonv_test 20 | { 21 | 22 | TEST(demangle_types) 23 | { 24 | std::cout << jsonv::demangle(typeid(jsonv::string_view).name()); 25 | jsonv::demangle("_ZN20garbage"); 26 | } 27 | 28 | TEST(demangle_set_reset) 29 | { 30 | jsonv::set_demangle_function(nullptr); 31 | auto cleanup = jsonv::detail::on_scope_exit(jsonv::reset_demangle_function); 32 | jsonv::demangle(typeid(int).name()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /examples/REQUEST__SHORT_NOROOT_STRING.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "9zj61whbdl319sjgz098lpys5cngmtro_short_false_false", 3 | "imp" : [ { 4 | "id" : "imp1", 5 | "native" : { 6 | "request" : "{\"ver\":\"1\",\"layout\":2,\"adunit\":4,\"plcmtcnt\":1,\"seq\":1}" 7 | }, 8 | "bidfloor" : 100.0, 9 | "bidfloorcur" : "USD" 10 | } ], 11 | "app" : { 12 | "id" : "app1", 13 | "name" : "my-app-name", 14 | "domain" : "mysite.foo.com", 15 | "paid" : 1, 16 | "keywords" : "my,app,key,words" 17 | }, 18 | "device" : { 19 | "ua" : "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", 20 | "geo" : { 21 | "city" : "New York" 22 | }, 23 | "dnt" : 0, 24 | "lmt" : 1, 25 | "ip" : "192.168.1.0", 26 | "ipv6" : "1:2:3:4:5:6:0:0" 27 | }, 28 | "user" : { 29 | "id" : "user1", 30 | "buyeruid" : "buyer1", 31 | "gender" : "O", 32 | "keywords" : "user,builder,key,words", 33 | "geo" : { 34 | "city" : "New York" 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/chrono_io.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * I/O for the chrono library. 3 | * 4 | * Copyright (c) 2016 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_TESTS_CHRONO_IO_HPP_INCLUDED__ 13 | #define __JSONV_TESTS_CHRONO_IO_HPP_INCLUDED__ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace jsonv_test 20 | { 21 | 22 | std::ostream& operator<<(std::ostream&, std::chrono::nanoseconds); 23 | 24 | template 25 | std::ostream& operator<<(std::ostream& os, std::chrono::duration value) 26 | { 27 | return os << std::chrono::duration_cast(value); 28 | } 29 | 30 | } 31 | 32 | #endif/*__JSONV_TESTS_CHRONO_IO_HPP_INCLUDED__*/ 33 | -------------------------------------------------------------------------------- /jsonv/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.orig 4 | *.kdev4 5 | build* 6 | .kdev* 7 | *.kdev4 8 | packages/ 9 | .vs 10 | x64/ 11 | *sdf 12 | *.pc 13 | 14 | # Compiled source # 15 | ################### 16 | *.com 17 | *.class 18 | *.dll 19 | *.exe 20 | *.o 21 | *.so 22 | 23 | # Packages # 24 | ############ 25 | # it's better to unpack these files and commit the raw source 26 | # git has its own built in compression methods 27 | *.7z 28 | *.dmg 29 | *.gz 30 | *.iso 31 | *.jar 32 | *.rar 33 | *.tar 34 | *.zip 35 | 36 | # Logs and databases # 37 | ###################### 38 | *.log 39 | *.sql 40 | *.sqlite 41 | 42 | # OS generated files # 43 | ###################### 44 | .DS_Store 45 | .DS_Store? 46 | ._* 47 | .Spotlight-V100 48 | .Trashes 49 | ehthumbs.db 50 | Thumbs.db 51 | ## my files and cmake 52 | out 53 | out.* 54 | 55 | # IDE files # 56 | ############# 57 | nbproject 58 | .~lock.* 59 | .buildpath 60 | .idea 61 | .project 62 | .settings 63 | composer.lock 64 | 65 | #Cmake 66 | CMakeCache.txt 67 | CMakeFiles 68 | CMakeScripts 69 | Makefile 70 | cmake_install.cmake 71 | install_manifest.txt 72 | -------------------------------------------------------------------------------- /CRUD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | cmake_minimum_required(VERSION 3.3.2) 4 | 5 | # VERSION not required, but good for library versioning 6 | project(CRUD VERSION 0.1.0) 7 | 8 | #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 9 | #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 10 | #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 11 | 12 | add_subdirectory(service) 13 | 14 | set(CMAKE_CXX_STANDARD 14) 15 | SET(CMAKE_CXX_STANDARD_REQUIRED ON) 16 | SET(CMAKE_CXX_EXTENSIONS OFF) 17 | 18 | set ( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}) 19 | 20 | find_package(Boost 21 | COMPONENTS "log" "system" "serialization" "program_options" 22 | REQUIRED 23 | ) 24 | 25 | include_directories(${Boost_INCLUDE_DIRS} handlers service) 26 | 27 | add_executable( 28 | my_service 29 | main.cpp 30 | ) 31 | 32 | find_package (Threads) 33 | 34 | target_link_libraries( 35 | my_service 36 | crud_service 37 | ${Boost_LIBRARIES} 38 | ${CMAKE_THREAD_LIBS_INIT} 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/chrono_io.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "chrono_io.hpp" 5 | 6 | namespace jsonv_test 7 | { 8 | 9 | std::ostream& operator<<(std::ostream& os, std::chrono::nanoseconds value) 10 | { 11 | using namespace std::chrono; 12 | 13 | if (value < nanoseconds(0)) 14 | { 15 | // Don't know how ISO 8601 is supposed to deal with negative durations since the Wikipedia did not mention them. 16 | os << '-'; 17 | value = -value; 18 | } 19 | os << "PT"; 20 | auto hrs = duration_cast(value); 21 | if (hrs > hours(0)) 22 | { 23 | os << hrs.count() << 'H'; 24 | value -= hrs; 25 | } 26 | auto mins = duration_cast(value); 27 | if (mins > minutes(0)) 28 | { 29 | os << mins.count() << 'M'; 30 | value -= mins; 31 | } 32 | auto secs = duration_cast(value); 33 | value -= secs; 34 | os << secs.count(); 35 | os << '.'; 36 | os << std::setfill('0') << std::setw(9) << value.count(); 37 | os << 'S'; 38 | 39 | return os; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/array.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Internal-only header for array-related values. 3 | * 4 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_ARRAY_HPP_INCLUDED__ 13 | #define __JSONV_ARRAY_HPP_INCLUDED__ 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | namespace jsonv 21 | { 22 | namespace detail 23 | { 24 | 25 | class JSONV_LOCAL array_impl : 26 | public cloneable 27 | { 28 | public: 29 | typedef std::deque array_type; 30 | 31 | public: 32 | value::size_type size() const; 33 | 34 | bool empty() const; 35 | 36 | public: 37 | array_type _values; 38 | }; 39 | 40 | } 41 | } 42 | 43 | 44 | #endif/*__JSONV_ARRAY_HPP_INCLUDED__*/ 45 | -------------------------------------------------------------------------------- /jsonv/debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: jsonv 3 | Source: https://github.com/tgockel/json-voorhees 4 | 5 | Files: * 6 | Copyright: 2015 by Travis Gockel. All rights reserved. 7 | License: Apache-2.0 8 | 9 | Files: debian/* 10 | Copyright: 2015 by Travis Gockel. All rights reserved. 11 | License: Apache-2.0 12 | 13 | License: Apache-2.0 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | . 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | . 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | . 26 | On Debian systems, the complete text of the Apache version 2.0 license 27 | can be found in "/usr/share/common-licenses/Apache-2.0". 28 | -------------------------------------------------------------------------------- /examples/bidder_experimental/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | 4 | include_directories( 5 | "${PROJECT_SOURCE_DIR}/examples" 6 | "${PROJECT_SOURCE_DIR}/examples/bidder" 7 | ) 8 | 9 | add_executable( 10 | ico_campaign_bidder_test 11 | ico_campaign_bidder_test.cpp 12 | ) 13 | 14 | if (WIN32) 15 | target_compile_definitions(ico_campaign_bidder_test PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 16 | target_compile_definitions(jsonv PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 17 | endif(WIN32) 18 | 19 | target_link_libraries( 20 | ico_campaign_bidder_test 21 | crud_service 22 | vanilla_rtb 23 | jsonv 24 | parsers 25 | ${Boost_LIBRARIES} 26 | ${CMAKE_THREAD_LIBS_INIT} 27 | ${RT_LIB} 28 | ) 29 | 30 | install(TARGETS ico_campaign_bidder_test 31 | RUNTIME DESTINATION bin 32 | LIBRARY DESTINATION lib 33 | ) 34 | 35 | add_custom_target( 36 | generator_experimental 37 | COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/../bidder/generator && python ico.py 38 | ) 39 | 40 | add_dependencies(ico_campaign_bidder_test generator_experimental) 41 | 42 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/jq_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "core.hpp" 12 | 13 | extern "C" 14 | { 15 | 16 | #include 17 | 18 | } 19 | 20 | namespace json_benchmark 21 | { 22 | 23 | using jq_value = std::shared_ptr; 24 | 25 | class jq_benchmark_suite : 26 | public typed_benchmark_suite 27 | { 28 | public: 29 | jq_benchmark_suite() : 30 | typed_benchmark_suite("jq") 31 | { } 32 | 33 | protected: 34 | virtual jq_value parse(const std::string& source) const 35 | { 36 | jq_value x(new jv, [] (jv* p) { jv_free(*p); delete p; }); 37 | *x = jv_parse_sized(source.c_str(), source.size()); 38 | return x; 39 | } 40 | 41 | } jq_benchmark_suite_instance; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /jsonv/installer/arch/git/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Travis Gockel 2 | # mkaurball 3 | _pkgbase=json-voorhees 4 | pkgname=${_pkgbase}-git 5 | pkgver=1.0.0.r7.g1810f53 6 | pkgver() { 7 | cd "${srcdir}/${_pkgbase}" 8 | git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g' | cut -c2- 9 | } 10 | pkgrel=1 11 | epoch= 12 | pkgdesc="A modern JSON parsing library for C++" 13 | arch=('x86_64') 14 | url="https://github.com/tgockel/json-voorhees" 15 | license=('Apache') 16 | groups=() 17 | depends=() 18 | makedepends=('gcc>=4.9' 'boost-libs>=1.52 cmake>=2.8') 19 | checkdepends=('boost>=1.48') 20 | optdepends=() 21 | provides=() 22 | conflicts=() 23 | replaces=() 24 | backup=() 25 | options=() 26 | install= 27 | changelog= 28 | source=("${_pkgbase}::git+https://github.com/tgockel/${_pkgbase}.git#branch=v1.0") 29 | noextract=() 30 | md5sums=('SKIP') 31 | 32 | build() { 33 | cd "${srcdir}/${_pkgbase}" 34 | cmake . -DCMAKE_BUILD_TYPE=Release -DJSONV_VERSION=${pkgver} 35 | make 36 | } 37 | 38 | check() { 39 | cd "${srcdir}/${_pkgbase}" 40 | ./jsonv-tests 41 | } 42 | 43 | package() { 44 | cd "${srcdir}/${_pkgbase}" 45 | make install DESTDIR="${pkgdir}/" 46 | } 47 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/jansson_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "core.hpp" 12 | 13 | #include 14 | 15 | namespace json_benchmark 16 | { 17 | 18 | using jansson_value = std::shared_ptr; 19 | 20 | class jansson_benchmark_suite : 21 | public typed_benchmark_suite 22 | { 23 | public: 24 | jansson_benchmark_suite() : 25 | typed_benchmark_suite("jansson") 26 | { } 27 | 28 | protected: 29 | virtual jansson_value parse(const std::string& source) const 30 | { 31 | json_t* px = json_loads(source.c_str(), 0, nullptr); 32 | jansson_value x(px, [] (json_t* p) { json_decref(p); }); 33 | return x; 34 | } 35 | 36 | } jansson_benchmark_suite_instance; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/jsoncpp_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "core.hpp" 12 | 13 | #include 14 | #include 15 | 16 | namespace json_benchmark 17 | { 18 | 19 | class jsoncpp_benchmark_suite : 20 | public typed_benchmark_suite 21 | { 22 | public: 23 | jsoncpp_benchmark_suite() : 24 | typed_benchmark_suite("JsonCpp") 25 | { } 26 | 27 | protected: 28 | virtual Json::Value parse(const std::string& source) const 29 | { 30 | Json::Reader reader; 31 | Json::Value out; 32 | if (!reader.parse(source, out)) 33 | throw std::runtime_error("Failed to parse"); 34 | return out; 35 | } 36 | 37 | } jsoncpp_benchmark_suite_instance; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /rtb/DSL/campaign_dsl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __RTB_DSL_CAMPAIGN_DSL_HPP_ 2 | #define __RTB_DSL_CAMPAIGN_DSL_HPP_ 3 | 4 | #include "jsonv/all.hpp" 5 | 6 | namespace DSL { 7 | using namespace jsonv; 8 | 9 | template 10 | class CampaignDSL : Mapper { 11 | public: 12 | using deserialized_type = typename Mapper::deserialized_type; 13 | using serialized_type = typename Mapper::serialized_type; 14 | using parse_error_type = typename Mapper::parse_error_type; 15 | 16 | 17 | CampaignDSL() { 18 | request_fmt_ = this->build_request(); 19 | response_fmt_ = this->build_response(); 20 | } 21 | 22 | deserialized_type extract_request(const std::string & campaign_entity) { 23 | auto encoded = parse(campaign_entity); 24 | return extract(encoded, request_fmt_); 25 | } 26 | 27 | auto create_response(const serialized_type & campaign_response) { 28 | return to_json(campaign_response, response_fmt_); 29 | } 30 | 31 | private: 32 | formats request_fmt_; 33 | formats response_fmt_; 34 | }; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /CRUD/service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_CXX_STANDARD 14) 3 | 4 | ## Configuring Boost 5 | set(REQUIRED_BOOST_LIBRARIES) 6 | list(APPEND REQUIRED_BOOST_LIBRARIES "system") 7 | list(APPEND REQUIRED_BOOST_LIBRARIES "regex") 8 | set(Boost_USE_MULTITHREADED ON) 9 | 10 | find_package(Boost 11 | COMPONENTS "${REQUIRED_BOOST_LIBRARIES}" 12 | REQUIRED 13 | ) 14 | 15 | if(Boost_FOUND) 16 | include_directories(${Boost_INCLUDE_DIRS}) 17 | endif() 18 | 19 | include_directories(../handlers) 20 | 21 | if (WIN32) 22 | # DLLs in Windows appear to have not been fully thought through 23 | set(DEFAULT_LIBRARY_TYPE "STATIC") 24 | else() 25 | set(DEFAULT_LIBRARY_TYPE "SHARED") 26 | endif() 27 | 28 | add_library(crud_service 29 | ${DEFAULT_LIBRARY_TYPE} 30 | mime_types.cpp 31 | reply.cpp 32 | request_handler.cpp 33 | request_parser.cpp 34 | ) 35 | find_package (Threads) 36 | 37 | if (Boost_LIBRARIES) 38 | target_link_libraries( crud_service ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 39 | endif() 40 | 41 | install(TARGETS crud_service 42 | ARCHIVE DESTINATION lib 43 | LIBRARY DESTINATION lib 44 | ) 45 | 46 | -------------------------------------------------------------------------------- /examples/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | 4 | include_directories( 5 | "${PROJECT_SOURCE_DIR}/examples" 6 | "${PROJECT_SOURCE_DIR}/examples/bidder" 7 | ) 8 | 9 | add_executable( 10 | cache_loader_test 11 | cache_loader_test.cpp 12 | ) 13 | 14 | add_executable( 15 | ico_campaign_loader_test 16 | ico_campaign_loader_test.cpp 17 | ) 18 | 19 | 20 | 21 | if (WIN32) 22 | target_compile_definitions(cache_loader_test PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 23 | target_compile_definitions(jsonv PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 24 | endif(WIN32) 25 | 26 | target_link_libraries( 27 | cache_loader_test 28 | crud_service 29 | vanilla_rtb 30 | jsonv 31 | ${Boost_LIBRARIES} 32 | ${CMAKE_THREAD_LIBS_INIT} 33 | ${RT_LIB} 34 | ) 35 | 36 | target_link_libraries( 37 | ico_campaign_loader_test 38 | crud_service 39 | vanilla_rtb 40 | jsonv 41 | ${Boost_LIBRARIES} 42 | ${CMAKE_THREAD_LIBS_INIT} 43 | ${RT_LIB} 44 | ) 45 | 46 | install(TARGETS cache_loader_test ico_campaign_loader_test 47 | RUNTIME DESTINATION bin 48 | LIBRARY DESTINATION lib 49 | ) 50 | 51 | -------------------------------------------------------------------------------- /examples/campaign/config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: serialization.hpp 3 | * Author: Vladimir Venediktov 4 | * 5 | * Created on March 12, 2017, 10:25 PM 6 | */ 7 | 8 | #ifndef CAMPAIGN_CONFIG_HPP 9 | #define CAMPAIGN_CONFIG_HPP 10 | 11 | #include "rtb/config/config.hpp" 12 | 13 | struct campaign_manager_config_data { 14 | std::string log_file_name; 15 | std::string create_restful_prefix; 16 | std::string update_restful_prefix; 17 | std::string delete_restful_prefix; 18 | std::string ipc_name; 19 | std::string campaign_budget_source; 20 | }; 21 | using CampaignManagerConfig = vanilla::config::config; 22 | 23 | struct notification_service_config_data { 24 | std::string log_file_name; 25 | int budget_port{}; 26 | std::string nurl_match; 27 | std::string ipc_name; 28 | }; 29 | 30 | using WinNotificationConfig = vanilla::config::config; 31 | 32 | struct slavebanker_service_config_data { 33 | std::string log_file_name; 34 | int budget_port{}; 35 | std::string ipc_name; 36 | }; 37 | 38 | using SlaveBankerConfig = vanilla::config::config; 39 | 40 | #endif /* CAMPAIGN_CONFIG_HPP */ 41 | 42 | -------------------------------------------------------------------------------- /jsonv/msvc/vs2015/jsonv-tests/jsonv-tests.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(ProjectDir)..\..\.. 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ProjectDir)..\..\.. 9 | WindowsLocalDebugger 10 | 11 | 12 | $(ProjectDir)..\..\.. 13 | WindowsLocalDebugger 14 | 15 | 16 | $(ProjectDir)..\..\.. 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /examples/multiexchange/multiexchange_config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: multiexchange_config.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 25 марта 2017 г., 13:19 6 | */ 7 | 8 | #ifndef MULTIEXCHANGE_CONFIG_HPP 9 | #define MULTIEXCHANGE_CONFIG_HPP 10 | 11 | #include 12 | #include "../../rtb/config/config.hpp" 13 | 14 | namespace vanilla { 15 | namespace multiexchange { 16 | 17 | struct multi_exchange_handler_config_data { 18 | std::string log_file_name; 19 | int handler_timeout; 20 | int num_bidders; 21 | int bidders_port; 22 | int bidders_response_timeout; 23 | int concurrency; 24 | std::string key_value_host; 25 | int key_value_port; 26 | 27 | 28 | multi_exchange_handler_config_data() : 29 | log_file_name{}, handler_timeout{}, num_bidders{}, bidders_port{}, bidders_response_timeout{}, concurrency{}, 30 | key_value_host{}, key_value_port{} 31 | { 32 | } 33 | }; 34 | 35 | using multiexchange_config = vanilla::config::config; 36 | } 37 | } 38 | #endif /* MULTIEXCHANGE_CONFIG_HPP */ 39 | 40 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/filesystem_util.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Utility functions for interacting with the filesystem. 3 | * 4 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_TESTS_FILESYSTEM_UTIL_HPP_INCLUDED__ 13 | #define __JSONV_TESTS_FILESYSTEM_UTIL_HPP_INCLUDED__ 14 | 15 | #include "test.hpp" 16 | 17 | #include 18 | 19 | namespace jsonv_test 20 | { 21 | 22 | std::string test_path(const std::string& path); 23 | 24 | std::string filename(std::string path); 25 | 26 | void recursive_directory_for_each(const std::string& root_path, 27 | const std::string& extension_filter, 28 | const std::function action 29 | ); 30 | 31 | } 32 | 33 | #endif/*__JSONV_TESTS_FILESYSTEM_UTIL_HPP_INCLUDED__*/ 34 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/object.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Internal-only header for object-related values. 3 | * 4 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_OBJECT_HPP_INCLUDED__ 13 | #define __JSONV_OBJECT_HPP_INCLUDED__ 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | namespace jsonv 21 | { 22 | namespace detail 23 | { 24 | 25 | class JSONV_LOCAL object_impl : 26 | public cloneable 27 | { 28 | public: 29 | using map_type = std::map; 30 | using iterator = map_type::iterator; 31 | using const_iterator = map_type::const_iterator; 32 | 33 | public: 34 | bool empty() const; 35 | 36 | value::size_type size() const; 37 | 38 | public: 39 | map_type _values; 40 | }; 41 | 42 | } 43 | 44 | } 45 | 46 | #endif/*__JSONV_OBJECT_HPP_INCLUDED__*/ 47 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/algorithm_compare_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | namespace jsonv_test 17 | { 18 | 19 | using namespace jsonv; 20 | 21 | TEST(compare_icase_sames) 22 | { 23 | ensure_eq(compare_icase("A", "a"), 0); 24 | ensure_eq(compare_icase("a", "A"), 0); 25 | ensure_eq(compare_icase("a", "a"), 0); 26 | ensure_eq(compare_icase("A", "A"), 0); 27 | } 28 | 29 | TEST(compare_icase_diffs) 30 | { 31 | ensure_lt(compare_icase("A", "b"), 0); 32 | ensure_lt(compare_icase("a", "B"), 0); 33 | ensure_gt(compare_icase("b", "a"), 0); 34 | ensure_gt(compare_icase("B", "A"), 0); 35 | } 36 | 37 | TEST(compare_icase_empty) 38 | { 39 | ensure_eq(compare_icase("", ""), 0); 40 | ensure_gt(compare_icase("a", ""), 0); 41 | ensure_lt(compare_icase("", "a"), 0); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /docker_swarm/swarm-persist-with-traefik.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | bidder: 4 | image: localhost:5000/vanilla-dev 5 | tty: true 6 | working_dir: /root/pkg/vanilla-rtb/snapshot/bin 7 | command: ./http_bidder_test --config etc/config.cfg 8 | deploy: 9 | mode: replicated 10 | replicas: 5 11 | restart_policy: 12 | condition: on-failure 13 | labels: 14 | - "traefik.docker.network=vanilla_swarm_net" 15 | - "traefik.port=9081" 16 | - "traefik.frontend.rule=Path:/bid/{id:[0-9]+}" 17 | - "traefik.backend.loadbalancer.stickiness=true" 18 | networks: 19 | - net 20 | ports: 21 | - 9081 22 | 23 | loadbalancer: 24 | image: traefik 25 | command: --docker \ 26 | --docker.swarmmode \ 27 | --docker.watch \ 28 | --web \ 29 | --loglevel=ERROR 30 | ports: 31 | - 80:80 32 | - 9090:8080 33 | volumes: 34 | - /var/run/docker.sock:/var/run/docker.sock 35 | deploy: 36 | restart_policy: 37 | condition: any 38 | mode: replicated 39 | replicas: 1 40 | update_config: 41 | delay: 2s 42 | placement: 43 | constraints: [node.role == manager] 44 | networks: 45 | - net 46 | 47 | networks: 48 | net: 49 | 50 | 51 | -------------------------------------------------------------------------------- /parsers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | project(parsers) 4 | 5 | 6 | set(PACKAGE_NAME "parsers" 7 | CACHE STRING "The packaging name of this library." 8 | ) 9 | 10 | set(JSMN_VERSION "1.0.0" 11 | CACHE STRING "The version of the library." 12 | ) 13 | 14 | 15 | ## Configure CXX 16 | 17 | file(GLOB_RECURSE parsers_cs RELATIVE_PATH "." "*.c") 18 | file(GLOB_RECURSE parsers_hs RELATIVE_PATH "." "*.h") 19 | file(GLOB_RECURSE parsers_cpps RELATIVE_PATH "." "*.cpp") 20 | file(GLOB_RECURSE parsers_hpps RELATIVE_PATH "." "*.hpp") 21 | 22 | if (WIN32) 23 | # DLLs in Windows appear to have not been fully thought through 24 | set(DEFAULT_LIBRARY_TYPE "STATIC") 25 | else() 26 | set(DEFAULT_LIBRARY_TYPE "SHARED") 27 | endif() 28 | 29 | 30 | add_library(parsers ${DEFAULT_LIBRARY_TYPE} ${parsers_cs} ${parsers_cpps}) 31 | 32 | set_target_properties(parsers 33 | PROPERTIES 34 | SOVERSION ${JSMN_VERSION} 35 | VERSION ${JSMN_VERSION} 36 | LINKER_LANGUAGE CXX 37 | ) 38 | 39 | install(TARGETS parsers 40 | ARCHIVE DESTINATION lib 41 | LIBRARY DESTINATION lib 42 | ) 43 | 44 | install(FILES ${parsers_hpps} ${parsers_hs} 45 | DESTINATION include/parsers) 46 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/detail.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2012-2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSONV_DETAIL_HPP_INCLUDED__ 12 | #define __JSONV_DETAIL_HPP_INCLUDED__ 13 | 14 | #include 15 | #include 16 | 17 | namespace jsonv 18 | { 19 | namespace detail 20 | { 21 | 22 | template 23 | struct cloneable 24 | { 25 | T* clone() const 26 | { 27 | return new T(*static_cast(this)); 28 | } 29 | }; 30 | 31 | class string_impl : 32 | public cloneable 33 | { 34 | public: 35 | std::string _string; 36 | }; 37 | 38 | } 39 | 40 | const char* kind_desc(kind type); 41 | bool kind_valid(kind k); 42 | void check_type(kind expected, kind actual); 43 | void check_type(std::initializer_list expected, kind actual); 44 | std::ostream& stream_escaped_string(std::ostream& stream, string_view str, bool require_ascii); 45 | 46 | } 47 | 48 | #endif/*__JSONV_DETAIL_HPP_INCLUDED__*/ 49 | -------------------------------------------------------------------------------- /jsonv/include/jsonv/forward.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/forward.hpp 2 | * 3 | * Copyright (c) 2012-2014 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSONV_FORWARD_HPP_INCLUDED__ 12 | #define __JSONV_FORWARD_HPP_INCLUDED__ 13 | 14 | namespace jsonv 15 | { 16 | 17 | class adapter; 18 | template class adapter_builder; 19 | class encoder; 20 | class extractor; 21 | class extraction_context; 22 | class formats; 23 | class formats_builder; 24 | enum class kind : unsigned char; 25 | class kind_error; 26 | template class member_adapter_builder; 27 | class parse_error; 28 | class parse_options; 29 | class path; 30 | class path_element; 31 | enum class path_element_kind : unsigned char; 32 | template class polymorphic_adapter_builder; 33 | class serializer; 34 | class serialization_context; 35 | class tokenizer; 36 | enum class token_kind : unsigned int; 37 | class value; 38 | struct version; 39 | 40 | } 41 | 42 | #endif/*__JSONV_FORWARD_HPP_INCLUDED__*/ 43 | -------------------------------------------------------------------------------- /rtb/core/banker.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: banker.hpp 3 | * Author: Vladimir Venediktov 4 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 5 | * 6 | * Created on July 8, 2017, 1:42 PM 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #pragma once 20 | #ifndef CORE_BANKER_HPP 21 | #define CORE_BANKER_HPP 22 | 23 | #include 24 | 25 | namespace vanilla { namespace core { 26 | 27 | template 28 | class Banker 29 | { 30 | public : 31 | template 32 | auto authorize(CampaignCache && cache, CampaignId && campaign_id) { 33 | auto budget = cache.retrieve(std::forward(campaign_id)); 34 | return budget_mgr.authorize(budget); 35 | } 36 | private : 37 | BudgetMgr budget_mgr ; 38 | }; 39 | 40 | }} 41 | #endif /* CORE_BANKER_HPP */ 42 | 43 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/util_validate_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace jsonv_test 19 | { 20 | 21 | using namespace jsonv; 22 | 23 | TEST(validate_non_finite_number) 24 | { 25 | value src = object({ { "a", 1 }, 26 | { "b", 2.5 }, 27 | { "c", array({ "hi", std::nan(""), 3.0 }) } 28 | } 29 | ); 30 | ensure_throws(validation_error, validate(src)); 31 | try 32 | { 33 | validate(src); 34 | } 35 | catch (const validation_error& err) 36 | { 37 | ensure_eq(err.error_code(), validation_error::code::non_finite_number); 38 | ensure_eq(err.path(), path::create(".c[1]")); 39 | ensure_eq(err.value().kind(), kind::decimal); 40 | ensure(std::isnan(err.value().as_decimal())); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /examples/bidder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | add_executable( 4 | http_bidder_test 5 | http_bidder_test.cpp 6 | ) 7 | 8 | add_executable( 9 | multi_bidder 10 | multi_bidder.cpp 11 | ) 12 | 13 | if (WIN32) 14 | target_compile_definitions(http_bidder_test PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 15 | target_compile_definitions(multi_bidder PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 16 | target_compile_definitions(jsonv PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 17 | endif(WIN32) 18 | 19 | target_link_libraries( 20 | http_bidder_test 21 | crud_service 22 | vanilla_rtb 23 | jsonv 24 | parsers 25 | ${Boost_LIBRARIES} 26 | ${CMAKE_THREAD_LIBS_INIT} 27 | ${RT_LIB} 28 | ) 29 | 30 | target_link_libraries( 31 | multi_bidder 32 | crud_service 33 | vanilla_rtb 34 | jsonv 35 | ${Boost_LIBRARIES} 36 | ${CMAKE_THREAD_LIBS_INIT} 37 | ${RT_LIB} 38 | ) 39 | 40 | install(TARGETS http_bidder_test multi_bidder 41 | RUNTIME DESTINATION bin 42 | LIBRARY DESTINATION lib 43 | ) 44 | 45 | add_custom_target( 46 | generator 47 | COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/generator && python ad.py && python campaign_budget.py > ../data/campaign_budget 48 | ) 49 | 50 | add_dependencies(http_bidder_test generator) 51 | add_dependencies(multi_bidder generator) 52 | -------------------------------------------------------------------------------- /rtb/common/decision_router.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: decision_router.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 9 мая 2017 г., 17:12 6 | */ 7 | 8 | #ifndef DECISION_ROUTER_HPP 9 | #define DECISION_ROUTER_HPP 10 | 11 | #include 12 | 13 | namespace vanilla { 14 | namespace decision { 15 | template 16 | class router { 17 | static constexpr int tree_depth{static_cast(SIZE)}; 18 | using decision_manager = vanilla::common::decision_tree_manager; 19 | public: 20 | using decision_tree_type = typename decision_manager::decision_tree_type; 21 | using decision_action = vanilla::common::decision_action; 22 | 23 | template 24 | router(T &&decision_tree): 25 | decision_tree{decision_tree}, manager{this->decision_tree} 26 | {} 27 | template 28 | void execute(TArgs && ...args) { 29 | manager.execute(std::forward(args)...); 30 | } 31 | private: 32 | decision_tree_type decision_tree; 33 | decision_manager manager; 34 | 35 | }; 36 | } 37 | } 38 | 39 | #endif /* DECISION_ROUTER_HPP */ 40 | 41 | -------------------------------------------------------------------------------- /docker/build-boost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | if [[ ${BOOST_VERSION} != 'default' ]]; then 6 | readonly BOOST_URL="https://dl.bintray.com/boostorg/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION//\./_}.tar.gz" 7 | readonly BOOST_DEPS_DIR="${DEPS_DIR}/boost-${BOOST_VERSION}" 8 | readonly BOOST_BUILD_DIR="${BUILD_DIR}/boost-${BOOST_VERSION}" 9 | readonly BOOST_TOOLSET=gcc 10 | readonly BOOST_LIBS='program_options,system,regex,serialization,log,date_time,test,filesystem' 11 | 12 | $(type -P rm) -rf "${BOOST_BUILD_DIR}" 13 | $(type -P mkdir) -p "${BOOST_BUILD_DIR}" 14 | 15 | $(type -P wget) --no-check-certificate --quiet -O - "${BOOST_URL}" | $(type -P tar) --strip-components=1 -xz -C "${BOOST_BUILD_DIR}" 16 | 17 | cd "${BOOST_BUILD_DIR}" 18 | ./bootstrap.sh --with-libraries="${BOOST_LIBS}" --with-toolset="${BOOST_TOOLSET}" || { cat bootstrap.log; exit 1; } 19 | ./b2 -d0 -q toolset="${BOOST_TOOLSET}" variant=release link=shared threading=multi runtime-link=shared install --prefix="${BOOST_DEPS_DIR}" 20 | 21 | $(type -P rm) -rf "${BOOST_BUILD_DIR}" 22 | $(type -P rmdir) --ignore-fail-on-non-empty "${BUILD_DIR}" 23 | 24 | export CMAKE_OPTIONS+=" -DBOOST_ROOT='${BOOST_DEPS_DIR}'" 25 | 26 | echo "Boost v${BOOST_VERSION} installed to ${BOOST_DEPS_DIR}" 27 | else 28 | echo "Nothing done - using the default Boost installation" 29 | fi 30 | -------------------------------------------------------------------------------- /CRUD/service/request_handler.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // request_handler.hpp 3 | // ~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef HTTP_REQUEST_HANDLER_HPP 12 | #define HTTP_REQUEST_HANDLER_HPP 13 | 14 | #include 15 | 16 | namespace http { 17 | namespace server { 18 | 19 | struct reply; 20 | struct request; 21 | 22 | /// The common handler for all incoming requests. 23 | class request_handler 24 | { 25 | public: 26 | request_handler(const request_handler&) = delete; 27 | request_handler& operator=(const request_handler&) = delete; 28 | 29 | /// Construct with a directory containing files to be served. 30 | explicit request_handler(const std::string& doc_root); 31 | 32 | /// Handle a request and produce a reply. 33 | void handle_request(const request& req, reply& rep); 34 | 35 | private: 36 | /// The directory containing the files to be served. 37 | std::string doc_root_; 38 | 39 | /// Perform URL-decoding on a string. Returns false if the encoding was 40 | /// invalid. 41 | static bool url_decode(const std::string& in, std::string& out); 42 | }; 43 | 44 | } // namespace server 45 | } // namespace http 46 | 47 | #endif // HTTP_REQUEST_HANDLER_HPP 48 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/core.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "core.hpp" 12 | 13 | #include 14 | 15 | namespace json_benchmark 16 | { 17 | 18 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 19 | // benchmark_suite // 20 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 21 | 22 | static benchmark_suite::suite_list& benchmark_suite_all_ref() 23 | { 24 | static benchmark_suite::suite_list instance; 25 | return instance; 26 | } 27 | 28 | const benchmark_suite::suite_list& benchmark_suite::all() 29 | { 30 | return benchmark_suite_all_ref(); 31 | } 32 | 33 | benchmark_suite::benchmark_suite(std::string name) : 34 | _name(std::move(name)) 35 | { 36 | benchmark_suite_all_ref().push_back(this); 37 | } 38 | 39 | benchmark_suite::~benchmark_suite() noexcept 40 | { } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /CRUD/README.md: -------------------------------------------------------------------------------- 1 | # CRUD 2 | Restful web-service written in C++11 based on boost.ASIO and CRUD handlers 3 | 4 | ### REST handler with regex 5 | 6 | ```C++ 7 | using regex_restful_dispatcher_t = http::crud::crud_dispatcher ; 8 | regex_restful_dispatcher_t regex_handler(".") ; //root is irrelavant for REST only used for web-server 9 | regex_handler.crud_match(boost::regex("/venue_handler/(\w+)") ) 10 | .post([](http::server::reply & r, const http::crud::crud_match & match) { 11 | r << "{}" << http::server::reply::flush("json") ; 12 | std::cout << "POST group_1_match=[ << match[1] << "], request_data=" << match.data << std::endl; 13 | }); 14 | 15 | ``` 16 | 17 | ### simple REST handler 18 | 19 | ```C++ 20 | // SIMPLE NO REGEX MATCH FOR POST "/venue_handler/RTB" 21 | using simple_restful_dispatcher_t = http::crud::crud_dispatcher ; 22 | simple_restful_dispatcher_t simple_handler(".") ; //root is irrelavant for REST only used for web-server 23 | simple_handler.crud_match(std::string("/venue_handler/RTB") ) 24 | .post([](http::server::reply & r, const http::crud::crud_match & match) { 25 | r << "{}" << http::server::reply::flush("json") ; 26 | std::cout << "POST request_data=" << match.data << std::endl; 27 | }); 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /examples/bidder/config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: config.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 16 февраля 2017 г., 21:12 6 | */ 7 | 8 | #ifndef BIDDER_CONFIG_HPP 9 | #define BIDDER_CONFIG_HPP 10 | 11 | struct bidder_config_data { 12 | std::string log_file_name; 13 | std::string ads_source; 14 | std::string ads_ipc_name; 15 | std::string geo_ad_source; 16 | std::string geo_ad_ipc_name; 17 | std::string geo_source; 18 | std::string geo_ipc_name; 19 | std::string geo_campaign_ipc_name; 20 | std::string geo_campaign_source; 21 | std::string campaign_budget_source; 22 | std::string ipc_name; 23 | std::string key_value_host; 24 | int key_value_port; 25 | int timeout; 26 | unsigned int concurrency; 27 | short port; 28 | std::string host; 29 | std::string root; 30 | short num_of_bidders; 31 | 32 | bidder_config_data() : 33 | log_file_name{}, 34 | ads_source{}, ads_ipc_name{}, 35 | geo_ad_source{}, geo_ad_ipc_name{}, 36 | geo_source{}, geo_ipc_name{}, geo_campaign_ipc_name{}, 37 | geo_campaign_source{}, 38 | campaign_budget_source{}, ipc_name{}, 39 | key_value_host{}, key_value_port{}, 40 | timeout{}, concurrency{}, 41 | port{}, host{}, root{}, num_of_bidders{} 42 | {} 43 | }; 44 | using BidderConfig = vanilla::config::config; 45 | 46 | #endif /* BIDDER_CONFIG_HPP */ 47 | 48 | -------------------------------------------------------------------------------- /rtb/common/type_algo.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #include "rtb/core/tagged_tuple.hpp" 4 | #include 5 | #include 6 | 7 | namespace vanilla { 8 | 9 | template 10 | struct nth_function { 11 | using func_type = vanilla::nth_element; 12 | template 13 | using return_type = typename std::result_of; 14 | }; 15 | 16 | 17 | template 18 | struct terminal_function ; 19 | 20 | template 21 | struct terminal_function { 22 | template 23 | using current_return_type = typename std::result_of::type; 24 | template 25 | struct func_ { 26 | using type = typename terminal_function::template func_,Args...>::type ; 27 | }; 28 | template 29 | using return_type = typename std::result_of::type>::type; 30 | }; 31 | 32 | template 33 | struct terminal_function { 34 | template 35 | struct func_ { 36 | using type = Func(Args...); 37 | }; 38 | template 39 | using return_type = typename std::result_of::type>::type; 40 | }; 41 | 42 | } -------------------------------------------------------------------------------- /rtb/messaging/shared_io_service.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: shared_io_service.hpp 3 | * Author: Vladimir Venediktov vvenedict@gmail.com 4 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 5 | * 6 | * Created on February 20, 2017, 11:19 PM 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #ifndef __VANILLA_MESSAGING_SHARED_IO_SERVICE__ 20 | #define __VANILLA_MESSAGING_SHARED_IO_SERVICE__ 21 | 22 | #include 23 | 24 | namespace vanilla { namespace messaging { 25 | 26 | struct shared_io_service { 27 | shared_io_service() : io_service_ptr{new boost::asio::io_service} 28 | {} 29 | void run() { 30 | io_service_ptr->run(); 31 | } 32 | void stop() { 33 | io_service_ptr->stop(); 34 | } 35 | operator boost::asio::io_service& () const { 36 | return *io_service_ptr; 37 | } 38 | private: 39 | std::shared_ptr io_service_ptr; 40 | }; 41 | 42 | }} 43 | 44 | #endif /* __VANILLA_MESSAGING_SHARED_IO_SERVICE__ */ 45 | 46 | -------------------------------------------------------------------------------- /rtb/common/perf_timer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: perf_timer.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 15 февраля 2017 г., 11:20 6 | */ 7 | 8 | #ifndef PERF_TIMER_HPP 9 | #define PERF_TIMER_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | template 16 | struct perf_timer { 17 | perf_timer(std::shared_ptr &osp, std::string name = "") : 18 | begin{std::chrono::steady_clock::now()}, end{begin}, osp{osp}, name{std::move(name)} 19 | {} 20 | ~perf_timer() { 21 | end = std::chrono::steady_clock::now() ; 22 | if(name.length()) { 23 | *osp << name << " : "; 24 | } 25 | *osp << "elapsed_sec=" 26 | << std::chrono::duration_cast(end - begin).count() 27 | << "|"; 28 | *osp << "elapsed_ms=" 29 | << std::chrono::duration_cast(end - begin).count() 30 | << "|"; 31 | *osp << "elapsed_mu=" 32 | << std::chrono::duration_cast(end - begin).count() 33 | << "|"; 34 | *osp << "elapsed_ns=" 35 | << std::chrono::duration_cast(end - begin).count() 36 | << "|"; 37 | } 38 | private: 39 | decltype(std::chrono::steady_clock::now()) begin; 40 | decltype(std::chrono::steady_clock::now()) end; 41 | std::shared_ptr osp; 42 | std::string name; 43 | }; 44 | 45 | 46 | #endif /* PERF_TIMER_HPP */ 47 | 48 | -------------------------------------------------------------------------------- /examples/campaign/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | 4 | include_directories( 5 | "${PROJECT_SOURCE_DIR}/examples" 6 | "${PROJECT_SOURCE_DIR}/examples/bidder" 7 | ) 8 | 9 | add_executable( 10 | campaign_manager_test 11 | campaign_manager_test.cpp 12 | ) 13 | 14 | add_executable( 15 | notification_service_test 16 | notification_service_test.cpp 17 | ) 18 | 19 | add_executable( 20 | slavebanker_service_test 21 | slavebanker_service_test.cpp 22 | ) 23 | 24 | if (WIN32) 25 | target_compile_definitions(campaign_manager_test PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 26 | target_compile_definitions(jsonv PRIVATE JSON_SO=1 _LIB JSON_COMPILING=1) 27 | endif(WIN32) 28 | 29 | target_link_libraries( 30 | campaign_manager_test 31 | crud_service 32 | vanilla_rtb 33 | jsonv 34 | ${Boost_LIBRARIES} 35 | ${CMAKE_THREAD_LIBS_INIT} 36 | ${RT_LIB} 37 | ) 38 | 39 | target_link_libraries( 40 | notification_service_test 41 | crud_service 42 | vanilla_rtb 43 | ${Boost_LIBRARIES} 44 | ${CMAKE_THREAD_LIBS_INIT} 45 | ${RT_LIB} 46 | ) 47 | 48 | target_link_libraries( 49 | slavebanker_service_test 50 | vanilla_rtb 51 | ${Boost_LIBRARIES} 52 | ${CMAKE_THREAD_LIBS_INIT} 53 | ${RT_LIB} 54 | ) 55 | 56 | install(TARGETS campaign_manager_test notification_service_test slavebanker_service_test 57 | RUNTIME DESTINATION bin 58 | LIBRARY DESTINATION lib 59 | ) 60 | 61 | -------------------------------------------------------------------------------- /examples/bidder/serialization.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: serialization.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 16 февраля 2017 г., 21:24 6 | */ 7 | 8 | #ifndef BIDDER_SERIALIZATION_HPP 9 | #define BIDDER_SERIALIZATION_HPP 10 | 11 | #include 12 | #include 13 | 14 | #include "examples/matchers/geo_campaign.hpp" 15 | #include "campaign_data.hpp" 16 | #include "examples/matchers/ad.hpp" 17 | #include "examples/matchers/geo.hpp" 18 | #include "examples/campaign/serialization.hpp" 19 | 20 | //Non-Intrusive boost serialization implementation 21 | namespace boost { namespace serialization { 22 | template 23 | void serialize(Archive & ar, Ad & value, const unsigned int version) { 24 | ar & value.ad_id; 25 | ar & value.campaign_id; 26 | ar & value.width; 27 | ar & value.height; 28 | ar & value.position; 29 | ar & value.max_bid_micros; 30 | ar & value.code; 31 | } 32 | 33 | template 34 | void serialize(Archive & ar, Geo & value, const unsigned int version) { 35 | ar & value.geo_id; 36 | ar & value.city; 37 | ar & value.country; 38 | ar & value.record; 39 | } 40 | template 41 | void serialize(Archive & ar, GeoCampaign & value, const unsigned int version) { 42 | ar & value.geo_id; 43 | ar & value.campaign_id; 44 | } 45 | }} 46 | 47 | #endif /* BIDDER_SERIALIZATION_HPP */ 48 | 49 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/kind_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | namespace jsonv_test 17 | { 18 | 19 | using namespace jsonv; 20 | 21 | TEST(kind_serialization) 22 | { 23 | ensure_eq(to_string(kind::array), "array"); 24 | ensure_eq(to_string(kind::object), "object"); 25 | ensure_eq(to_string(kind::string), "string"); 26 | ensure_eq(to_string(kind::integer), "integer"); 27 | ensure_eq(to_string(kind::decimal), "decimal"); 28 | ensure_eq(to_string(kind::boolean), "boolean"); 29 | ensure_eq(to_string(kind::null), "null"); 30 | 31 | // all we care about here is that it doesn't assert 32 | to_string(static_cast(~0)); 33 | } 34 | 35 | TEST(kind_valid) 36 | { 37 | ensure(!kind_valid(static_cast(~0))); 38 | } 39 | 40 | TEST(check_type_valid) 41 | { 42 | check_type({ kind::array, kind::object, kind::null }, kind::object); 43 | } 44 | 45 | TEST(check_type_invalid) 46 | { 47 | ensure_throws(kind_error, check_type({ kind::array, kind::object, kind::null }, kind::integer)); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/test.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2012 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace jsonv_test 19 | { 20 | 21 | unit_test_list_type& get_unit_tests() 22 | { 23 | static unit_test_list_type instance; 24 | return instance; 25 | } 26 | 27 | unit_test::unit_test(const std::string& name) : 28 | _name(name) 29 | { 30 | get_unit_tests().push_back(this); 31 | } 32 | 33 | bool unit_test::run() 34 | { 35 | std::cout << "TEST: " << name() << " ..."; 36 | _success = true; 37 | try 38 | { 39 | run_impl(); 40 | } 41 | catch (const std::exception& ex) 42 | { 43 | _success = false; 44 | _failstring = std::string("Threw exception of type ") + jsonv::demangle(typeid(ex).name()) + ": " + ex.what(); 45 | } 46 | catch (...) 47 | { 48 | _success = false; 49 | _failstring = "Threw unknown exception"; 50 | } 51 | if (_success) 52 | std::cout << " SUCCESS!" << std::endl; 53 | else 54 | std::cout << " \x1b[0;31mFAILURE " << _failstring << "\x1b[m" << std::endl; 55 | return _success; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /rtb/common/split_string.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: split_string.hpp 3 | * Author: Vladimir Venediktov vvenedict@gmail.com 4 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 5 | * 6 | * Created on February 20, 2017, 11:19 PM 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #ifndef __RTB_COMMON_SPLIT_STRING_HPP__ 20 | #define __RTB_COMMON_SPLIT_STRING_HPP__ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace vanilla { namespace common { 27 | 28 | template 29 | void split_string( std::vector &ret, 30 | const std::string &s, 31 | const char *delims) { 32 | char const* begin = s.c_str(); 33 | char const* end = strpbrk(begin + 1, delims); 34 | for (; end != NULL; end = strpbrk(begin, delims)) { 35 | ret.emplace_back(begin, std::distance(begin,end)); 36 | begin = ++end; 37 | } 38 | 39 | if ( begin != &*s.end() ) { 40 | ret.emplace_back(begin, std::distance(begin, &*s.end())) ; 41 | } 42 | } 43 | 44 | }} 45 | 46 | #endif /* __RTB_COMMON_SPLIT_STRING_HPP__ */ 47 | 48 | -------------------------------------------------------------------------------- /rtb/core/algos.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: algos.hpp 3 | * Author: Vladimir Venediktov 4 | * Author: Arseny Bushev 5 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 6 | * 7 | * Created on January 8, 2018, 1:42 PM 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | */ 19 | 20 | #ifndef VANILLA_RTB_ALGOS_HPP 21 | #define VANILLA_RTB_ALGOS_HPP 22 | 23 | #include 24 | 25 | namespace vanilla { namespace algorithm { 26 | 27 | template 28 | static auto calculate_max_bid(const std::vector& ads) { 29 | if(ads.size() == 0) { 30 | return std::make_unique(); 31 | } 32 | const typename std::vector::const_iterator result = 33 | std::max_element(ads.cbegin(), ads.cend(), [](const Ad &first, const Ad &second) -> bool { 34 | return first.auth_bid_micros && second.auth_bid_micros ? 35 | first.auth_bid_micros (*result); 38 | } 39 | 40 | }} 41 | 42 | 43 | #endif //VANILLA_RTB_ALGOS_HPP 44 | -------------------------------------------------------------------------------- /examples/etc/config.cfg: -------------------------------------------------------------------------------- 1 | [exchange] 2 | log = /tmp/openrtb_handler_log 3 | host = 0.0.0.0 4 | port = 8081 5 | root = . 6 | v1.timeout = 100 7 | v2.timeout = 80 8 | 9 | [mock-bidder] 10 | log = /tmp/openrtb_mock_bidder_test_log 11 | local_address = 0.0.0.0 12 | group_address = 0.0.0.0 13 | port = 5000 14 | communicator.type = broadcast 15 | num_of_bidders = 5 16 | 17 | [bidder] 18 | log = /tmp/bidder_log 19 | host = 0.0.0.0 20 | port = 9081 21 | root = . 22 | timeout = 50 23 | 24 | [ico-bidder] 25 | log = /tmp/bidder_log 26 | host = 0.0.0.0 27 | port = 9082 28 | root = . 29 | timeout = 50 30 | 31 | [cache-loader] 32 | log = /tmp/vanilla_cache_loader_log 33 | host = 0.0.0.0 34 | port = 10081 35 | root = . 36 | 37 | [multi_exchange] 38 | log = /tmp/multi_exchange_log 39 | host = 0.0.0.0 40 | port = 9090 41 | root = . 42 | timeout = 80 43 | 44 | [multi_bidder] 45 | log = /tmp/multi_bidder_log 46 | host = 0.0.0.0 47 | port = 5000 48 | budget_port = 5001 49 | root = . 50 | timeout = 50 51 | num_of_bidders = 3 52 | 53 | [campaign-manager] 54 | log = /tmp/campaign_manager_log 55 | host = 0.0.0.0 56 | port = 11081 57 | root = www 58 | ipc_name = vanilla-campaign-budget-ipc 59 | 60 | [notification-service] 61 | log = /tmp/notification_service_log 62 | host = 0.0.0.0 63 | port = 12081 64 | root = . 65 | nurl = http://localhost:12081/win/details?price=${AUCTION_PRICE}&BidResponse.seatbid.bid.impid=${AUCTION_IMP_ID}&BidRequest.id=${AUCTION_ID}¤cy=${AUCTION_CURRENCY}&BidResponse.bidid=${AUCTION_BID_ID}&campaign_id= 66 | nurl_match = /win/.*(?:price=)(\d+).*(?:campaign_id=)(\d+) 67 | 68 | [slave-banker-service] 69 | log = /tmp/slavebanker_service_log 70 | ipc_name = vanilla-slavebanker-budget-ipc 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | 31 | # Compiled source # 32 | ################### 33 | *.com 34 | *.class 35 | *.dll 36 | *.exe 37 | *.o 38 | *.so 39 | 40 | # Packages # 41 | ############ 42 | # it's better to unpack these files and commit the raw source 43 | # git has its own built in compression methods 44 | *.7z 45 | *.dmg 46 | *.gz 47 | *.iso 48 | *.jar 49 | *.rar 50 | *.tar 51 | *.zip 52 | 53 | # Logs and databases # 54 | ###################### 55 | *.log 56 | *.sql 57 | *.sqlite 58 | 59 | # OS generated files # 60 | ###################### 61 | .DS_Store 62 | .DS_Store? 63 | ._* 64 | .Spotlight-V100 65 | .Trashes 66 | ehthumbs.db 67 | Thumbs.db 68 | ## my files and cmake 69 | out 70 | out.* 71 | 72 | # IDE files # 73 | ############# 74 | nbproject 75 | .~lock.* 76 | .buildpath 77 | .idea 78 | .project 79 | .settings 80 | composer.lock 81 | 82 | #Cmake 83 | CMakeCache.txt 84 | CMakeFiles 85 | CMakeScripts 86 | Makefile 87 | cmake_install.cmake 88 | install_manifest.txt 89 | .pc 90 | *.vcxproj 91 | *.suo 92 | *.vcxproj.filters 93 | *.opendb 94 | *.lastbuildstate 95 | *.tlog 96 | *.db 97 | *.sln 98 | *.lastbuildstate 99 | *.cache 100 | *.pdb 101 | *.user 102 | *.ilk 103 | *.exp 104 | *.pc 105 | *.ipch 106 | *.db-shm 107 | *.db-wal 108 | compile_commands.json 109 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/data/json_checker/pass1.json: -------------------------------------------------------------------------------- 1 | [ 2 | "JSON Test Pattern pass1", 3 | {"object with 1 member":["array with 1 element"]}, 4 | {}, 5 | [], 6 | -42, 7 | true, 8 | false, 9 | null, 10 | { 11 | "integer": 1234567890, 12 | "real": -9876.543210, 13 | "e": 0.123456789e-12, 14 | "E": 1.234567890E+34, 15 | "": 23456789012E66, 16 | "zero": 0, 17 | "one": 1, 18 | "space": " ", 19 | "quote": "\"", 20 | "backslash": "\\", 21 | "controls": "\b\f\n\r\t", 22 | "slash": "/ & \/", 23 | "alpha": "abcdefghijklmnopqrstuvwyz", 24 | "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", 25 | "digit": "0123456789", 26 | "0123456789": "digit", 27 | "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", 28 | "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", 29 | "true": true, 30 | "false": false, 31 | "null": null, 32 | "array":[ ], 33 | "object":{ }, 34 | "address": "50 St. James Street", 35 | "url": "http://www.JSON.org/", 36 | "comment": "// /* */": " ", 38 | " s p a c e d " :[1,2 , 3 39 | 40 | , 41 | 42 | 4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], 43 | "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", 44 | "quotes": "" \u0022 %22 0x22 034 "", 45 | "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" 46 | : "A key can be any string" 47 | }, 48 | 0.5 ,98.6 49 | , 50 | 99.44 51 | , 52 | 53 | 1066, 54 | 1e1, 55 | 0.1e1, 56 | 1e-1, 57 | 1e00,2e+00,2e-00 58 | ,"rosebud"] -------------------------------------------------------------------------------- /jsonv/include/jsonv/serialization_optional.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/serialization_optional.hpp 2 | * Template specialization to support optional serialization. 3 | * These are usually not needed unless you are writing your own 4 | * \c extractor or \c serializer. 5 | * 6 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 7 | * 8 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 9 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 10 | * version. 11 | * 12 | * \author Vladimir Venediktov (vvenedict@gmail.com) 13 | **/ 14 | 15 | #ifndef __JSONV_SERIALIZATION_OPTIONAL_HPP_INCLUDED__ 16 | #define __JSONV_SERIALIZATION_OPTIONAL_HPP_INCLUDED__ 17 | 18 | #include 19 | #include 20 | 21 | 22 | namespace jsonv 23 | { 24 | 25 | //specialization for optional 26 | template 27 | class container_adapter> : 28 | public adapter_for> 29 | { 30 | using element_type = optional; 31 | 32 | protected: 33 | virtual optional create(const extraction_context& context, const value& from) const override 34 | { 35 | optional out; 36 | if (from.is_null()) { 37 | return out; 38 | } 39 | out = context.extract(from); 40 | return out; 41 | } 42 | 43 | virtual value to_json(const serialization_context& context, const optional& from) const override 44 | { 45 | value out; 46 | if (from) { 47 | out = context.to_json(*from); 48 | } 49 | return out; 50 | } 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/algorithm_compare.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace jsonv 17 | { 18 | 19 | int compare(const value& a, const value& b) 20 | { 21 | return compare(a, b, compare_traits()); 22 | } 23 | 24 | struct compare_traits_icase : 25 | public compare_traits 26 | { 27 | /** Compares strings a and b in a case-insensitive manner. It is not UTF-8 aware and I am not sure it needs to be. **/ 28 | static int compare_strings(const std::string& a, const std::string& b) 29 | { 30 | using std::begin; 31 | using std::end; 32 | 33 | auto aiter = begin(a); 34 | auto biter = begin(b); 35 | 36 | for ( ; aiter != end(a) && biter != end(b); ++aiter, ++biter) 37 | { 38 | auto aa = std::tolower(*aiter); 39 | auto bb = std::tolower(*biter); 40 | if (aa == bb) 41 | continue; 42 | else if (aa < bb) 43 | return -1; 44 | else 45 | return 1; 46 | } 47 | 48 | return aiter == end(a) ? biter == end(b) ? 0 : -1 49 | : 1; 50 | } 51 | }; 52 | 53 | int compare_icase(const value& a, const value& b) 54 | { 55 | return compare(a, b, compare_traits_icase()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /rtb/core/logger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | void init_framework_logging(const std::string & full_file_name){ 12 | 13 | boost::log::add_file_log( 14 | boost::log::keywords::file_name = full_file_name + "_%Y%m%d.log", 15 | boost::log::keywords::open_mode = (std::ios::out | std::ios::app), 16 | boost::log::keywords::auto_flush = true, 17 | boost::log::keywords::format = 18 | ( 19 | boost::log::expressions::stream 20 | << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S.%f") 21 | << ": <" << boost::log::trivial::severity 22 | << "> " << boost::log::expressions::smessage 23 | ) 24 | ); 25 | boost::log::add_console_log( 26 | std::cout, 27 | boost::log::keywords::format = 28 | ( 29 | boost::log::expressions::stream 30 | << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S.%f") 31 | << ": <" << boost::log::trivial::severity 32 | << "> " << boost::log::expressions::smessage 33 | ) 34 | ); 35 | 36 | boost::log::add_common_attributes(); 37 | 38 | #ifdef NDEBUG 39 | boost::log::core::get()->set_filter ( 40 | boost::log::trivial::severity >= boost::log::trivial::info 41 | ); 42 | #endif 43 | } 44 | 45 | -------------------------------------------------------------------------------- /docker_swarm/scatter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | if [ "$(uname)" == "Darwin" ]; then 5 | IP_ADDR="--advertise-addr $(docker-machine ip default)" 6 | SUDO= 7 | MAC=1 8 | elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then 9 | IP_ADDR= 10 | SUDO=sudo 11 | else 12 | echo platform $(uname -s) not supported ... 13 | fi 14 | 15 | #else 16 | # echo "$(expr substr $(uname -s) 1 10) system is not yet supported 17 | # exit 1 18 | #fi 19 | 20 | if ! [ -z ${MAC+x} ]; then 21 | echo MAC OS detected 22 | if docker-machine status 2> /dev/null; then 23 | docker-machine upgrade 24 | else 25 | docker-machine create --driver virtualbox default 26 | fi 27 | #to set env corectly for docker commands mac and win only 28 | eval $(docker-machine env default) 29 | fi 30 | 31 | 32 | $SUDO docker swarm leave --force 33 | 34 | #for multi IP networks specify ip to start swarm network 35 | $SUDO docker swarm init ${IP_ADDR} 36 | 37 | #create local service to share image between nodes 38 | $SUDO docker service create --name registry --publish 5000:5000 registry:2 39 | 40 | #pull vanilla image if it's not installed on VM 41 | $SUDO docker pull vanillartb/vanilla-dev 42 | 43 | #tag it with localhost for local registry upload 44 | $SUDO docker tag vanillartb/vanilla-dev localhost:5000/vanilla-dev 45 | 46 | #upload image to local registry accessibe by all swarm nodes 47 | $SUDO docker push localhost:5000/vanilla-dev 48 | 49 | #remove cached images in the docker 50 | $SUDO docker image rm vanillartb/vanilla-dev --force 51 | $SUDO docker image rm localhost:5000/vanilla-dev --force 52 | 53 | #deploy stack to the swarm manager 54 | #$SUDO docker stack deploy -c swarm-persist-with-traefik.yaml vanilla_swarm 55 | #$SUDO docker stack deploy -c swarm-persist-with-haproxy.yaml vanilla_swarm 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /rtb/client/empty_key_value_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: empty_key_value_client.h 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 31 марта 2017 г., 12:33 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | 18 | #ifndef EMPTY_KEY_VALUE_CLIENT_H 19 | #define EMPTY_KEY_VALUE_CLIENT_H 20 | 21 | #include 22 | #include 23 | 24 | namespace vanilla { 25 | namespace client { 26 | class empty_key_value_client { 27 | public: 28 | using self_type = empty_key_value_client; 29 | using response_handler_type = std::function; 30 | 31 | empty_key_value_client() { 32 | } 33 | 34 | self_type &response(const response_handler_type &handler) { 35 | response_handler = handler; 36 | return *this; 37 | } 38 | 39 | void request(const std::string &key, std::string &data) { 40 | response_handler(); 41 | } 42 | 43 | void connect(const std::string &host, uint16_t port) { 44 | } 45 | 46 | bool connected() const { 47 | return true; 48 | } 49 | private: 50 | response_handler_type response_handler; 51 | }; 52 | 53 | } 54 | } 55 | 56 | #endif /* EMPTY_KEY_VALUE_CLIENT_H */ 57 | 58 | -------------------------------------------------------------------------------- /jsonv/include/jsonv/demangle.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/demangle.hpp 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSONV_DEMANGLE_HPP_INCLUDED__ 12 | #define __JSONV_DEMANGLE_HPP_INCLUDED__ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace jsonv 21 | { 22 | 23 | /** \addtogroup Serialization 24 | * \{ 25 | **/ 26 | 27 | /** Convert the input \a source from a mangled type into a human-friendly version. This is used by \c formats (and the 28 | * associated serialization functions) to give more user-friendly names in type errors. 29 | * 30 | * \see demangle_function 31 | * \see set_demangle_function 32 | **/ 33 | JSONV_PUBLIC std::string demangle(string_view source); 34 | 35 | /** Type of function used in setting a custom demangler. 36 | * 37 | * \see demangle 38 | * \see set_demangle_function 39 | **/ 40 | using demangle_function = std::function; 41 | 42 | /** Sets the global demangle function. This controls the behavior of \c demangle -- the provided \a func will be called 43 | * by \c demangle. 44 | * 45 | * \see demangle 46 | **/ 47 | JSONV_PUBLIC void set_demangle_function(demangle_function func); 48 | 49 | /** Resets the demangle function to the default. 50 | * 51 | * \see set_demangle_function 52 | **/ 53 | JSONV_PUBLIC void reset_demangle_function(); 54 | 55 | /** \} **/ 56 | 57 | } 58 | 59 | #endif/*__JSONV_DEMANGLE_HPP_INCLUDED__*/ 60 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/demangle.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | 14 | #ifndef _MSC_VER 15 | #include 16 | #endif 17 | #include 18 | 19 | namespace jsonv 20 | { 21 | 22 | #ifdef _MSC_VER 23 | static std::string demangle_impl(string_view source) 24 | { 25 | return std::string(source); 26 | } 27 | #else 28 | static std::string demangle_impl(string_view source) 29 | { 30 | namespace cxxabi = __cxxabiv1; 31 | int status; 32 | char* demangled = cxxabi::__cxa_demangle(source.data(), nullptr, nullptr, &status); 33 | if (demangled) 34 | { 35 | auto cleanup = detail::on_scope_exit([demangled] { std::free(demangled); }); 36 | return std::string(demangled); 37 | } 38 | else 39 | { 40 | return std::string(source); 41 | } 42 | } 43 | #endif 44 | 45 | static demangle_function& demangle_function_ref() 46 | { 47 | static demangle_function instance = demangle_impl; 48 | return instance; 49 | } 50 | 51 | void set_demangle_function(demangle_function func) 52 | { 53 | demangle_function_ref() = std::move(func); 54 | } 55 | 56 | void reset_demangle_function() 57 | { 58 | demangle_function_ref() = demangle_impl; 59 | } 60 | 61 | std::string demangle(string_view source) 62 | { 63 | const demangle_function& func = demangle_function_ref(); 64 | if (func) 65 | return func(source); 66 | else 67 | return std::string(source); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/UI/CampaignBudgetsCDN/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Campaign Budgets UI 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /rtb/DSL/generic_dsl.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: generic_dsl.hpp 3 | * Author: Vladimir Venediktov vvenedict@gmail.com 4 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 5 | * 6 | * Created on October 7, 2016, 9:08 PM 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #ifndef RTB_DSL_GENERIC_DSL_HPP 20 | #define RTB_DSL_GENERIC_DSL_HPP 21 | 22 | #include "encoders.hpp" 23 | #include "dsl_mapper.hpp" 24 | 25 | namespace DSL { 26 | using namespace jsonv; 27 | 28 | template class Mapper = DSL::dsl_mapper> 29 | class GenericDSL : public Mapper { 30 | 31 | using encoded_type = typename Mapper::encoded_type; 32 | public: 33 | using Mapper::Mapper; 34 | using deserialized_type = typename Mapper::deserialized_type; 35 | using serialized_type = typename Mapper::serialized_type; 36 | using parse_error_type = typename Mapper::parse_error_type; 37 | 38 | 39 | template 40 | deserialized_type extract_request(const string_view_type & bid_request) { 41 | return Mapper::template extract(bid_request); 42 | } 43 | 44 | auto create_response(const serialized_type & bid_response) { 45 | return Mapper::serialize(bid_response); 46 | } 47 | 48 | }; 49 | 50 | } //namespace 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /jsonv/include/jsonv/detail/nested_exception.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/detail/nested_exception.hpp 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSONV_DETAIL_NESTED_EXCEPTION_HPP_INCLUDED__ 12 | #define __JSONV_DETAIL_NESTED_EXCEPTION_HPP_INCLUDED__ 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace jsonv 19 | { 20 | 21 | #ifdef _MSC_VER 22 | 23 | /** Component for exception classes that captures the currently handled exception as nested. This class is only used in 24 | * Microsoft Visual C++ -- as of MSVC 14 CTP 5, there is no definition for std::nested_exception. 25 | **/ 26 | class JSONV_PUBLIC nested_exception 27 | { 28 | public: 29 | nested_exception() noexcept : 30 | _nested(std::current_exception()) 31 | { } 32 | 33 | nested_exception(const nested_exception& src) noexcept : 34 | _nested(src._nested) 35 | { } 36 | 37 | nested_exception& operator=(const nested_exception& src) noexcept 38 | { 39 | _nested = src._nested; 40 | return *this; 41 | } 42 | 43 | virtual ~nested_exception() noexcept = default; 44 | 45 | __declspec(noreturn) void rethrow_nested() const 46 | { 47 | std::rethrow_exception(_nested); 48 | } 49 | 50 | std::exception_ptr nested_ptr() const noexcept 51 | { 52 | return _nested; 53 | } 54 | 55 | private: 56 | std::exception_ptr _nested; 57 | }; 58 | 59 | #else 60 | 61 | using nested_exception = std::nested_exception; 62 | 63 | #endif 64 | 65 | } 66 | 67 | #endif/*__JSONV_DETAIL_NESTED_EXCEPTION_HPP_INCLUDED__*/ 68 | -------------------------------------------------------------------------------- /parsers/jsmn.h: -------------------------------------------------------------------------------- 1 | #ifndef __JSMN_H_ 2 | #define __JSMN_H_ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /** 11 | * JSON type identifier. Basic types are: 12 | * o Object 13 | * o Array 14 | * o String 15 | * o Other primitive: number, boolean (true/false) or null 16 | */ 17 | typedef enum { 18 | JSMN_UNDEFINED = 0, 19 | JSMN_OBJECT = 1, 20 | JSMN_ARRAY = 2, 21 | JSMN_STRING = 3, 22 | JSMN_PRIMITIVE = 4 23 | } jsmntype_t; 24 | 25 | enum jsmnerr { 26 | /* Not enough tokens were provided */ 27 | JSMN_ERROR_NOMEM = -1, 28 | /* Invalid character inside JSON string */ 29 | JSMN_ERROR_INVAL = -2, 30 | /* The string is not a full JSON packet, more bytes expected */ 31 | JSMN_ERROR_PART = -3 32 | }; 33 | 34 | /** 35 | * JSON token description. 36 | * type type (object, array, string etc.) 37 | * start start position in JSON data string 38 | * end end position in JSON data string 39 | */ 40 | typedef struct { 41 | jsmntype_t type; 42 | int start; 43 | int end; 44 | int size; 45 | #ifdef JSMN_PARENT_LINKS 46 | int parent; 47 | #endif 48 | } jsmntok_t; 49 | 50 | /** 51 | * JSON parser. Contains an array of token blocks available. Also stores 52 | * the string being parsed now and current position in that string 53 | */ 54 | typedef struct { 55 | unsigned int pos; /* offset in the JSON string */ 56 | unsigned int toknext; /* next token to allocate */ 57 | int toksuper; /* superior token node, e.g parent object or array */ 58 | } jsmn_parser; 59 | 60 | /** 61 | * Create JSON parser over an array of tokens 62 | */ 63 | void jsmn_init(jsmn_parser *parser); 64 | 65 | /** 66 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing 67 | * a single JSON object. 68 | */ 69 | int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, 70 | jsmntok_t *tokens, unsigned int num_tokens); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* __JSMN_H_ */ 77 | -------------------------------------------------------------------------------- /jsonv/include/jsonv/detail/scope_exit.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/detail/scope_exit.hpp 2 | * Definition of the \c on_scope_exit utility. 3 | * 4 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__ 13 | #define __JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__ 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace jsonv 20 | { 21 | namespace detail 22 | { 23 | 24 | template 25 | class scope_exit_invoker 26 | { 27 | public: 28 | explicit scope_exit_invoker(Function&& func) : 29 | _func(std::move(func)), 30 | _responsible(true) 31 | { } 32 | 33 | scope_exit_invoker(scope_exit_invoker&& src) : 34 | _func(std::move(src._func)), 35 | _responsible(src._responsible) 36 | { 37 | src._responsible = false; 38 | } 39 | 40 | scope_exit_invoker(const scope_exit_invoker&) = delete; 41 | scope_exit_invoker& operator=(const scope_exit_invoker&) = delete; 42 | scope_exit_invoker& operator=(scope_exit_invoker&&) = delete; 43 | 44 | ~scope_exit_invoker() 45 | { 46 | if (_responsible) 47 | _func(); 48 | } 49 | 50 | void release() 51 | { 52 | _responsible = false; 53 | } 54 | 55 | private: 56 | Function _func; 57 | bool _responsible; 58 | }; 59 | 60 | template 61 | scope_exit_invoker on_scope_exit(Function func) 62 | { 63 | return scope_exit_invoker(std::move(func)); 64 | } 65 | 66 | } 67 | } 68 | 69 | #endif/*__JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__*/ 70 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/main.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2012-2016 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "filesystem_util.hpp" 24 | #include "test.hpp" 25 | 26 | TEST(demo) 27 | { 28 | std::string src = "{ \"blazing\": [ 3, \"\\\"\\n\", 4.5, 5.123, 4.10921e19 ], " 29 | " \"text\": [ 1, 2, 3, 4, \t\"something\"], " 30 | " \"we call him \\\"empty array\\\"\": [], " 31 | " \"we call him \\\"empty object\\\"\": {}, " 32 | " \"unicode\" :\"\\uface\"" 33 | "}"; 34 | jsonv::value parsed = jsonv::parse(src); 35 | std::cout << parsed; 36 | } 37 | 38 | int main(int argc, char** argv) 39 | { 40 | std::string filter; 41 | if (argc == 2) 42 | filter = argv[1]; 43 | 44 | int fail_count = 0; 45 | for (auto test : jsonv_test::get_unit_tests()) 46 | { 47 | bool shouldrun = filter.empty() 48 | || test->name().find(filter) != std::string::npos; 49 | if (shouldrun && !test->run()) 50 | ++fail_count; 51 | } 52 | #ifdef _MSC_VER 53 | // Visual Studio doesn't seem to treat non-zero exits as an error...so we'll just throw an exception. 54 | if (fail_count > 0) 55 | throw std::runtime_error("Not all unit tests passed..."); 56 | #endif 57 | return fail_count; 58 | } 59 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/algorithm_traverse.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | #include 14 | 15 | namespace jsonv 16 | { 17 | 18 | void traverse(const value& tree, 19 | const std::function& func, 20 | const path& base_path, 21 | bool leafs_only 22 | ) 23 | { 24 | if (!leafs_only || tree.empty() || (tree.kind() != kind::array && tree.kind() != kind::object)) 25 | func(base_path, tree); 26 | 27 | if (tree.kind() == kind::object) 28 | { 29 | for (const auto& field : tree.as_object()) 30 | { 31 | traverse(field.second, 32 | func, 33 | base_path + field.first, 34 | leafs_only 35 | ); 36 | } 37 | } 38 | else if (tree.kind() == kind::array) 39 | { 40 | for (value::size_type idx = 0; idx < tree.size(); ++idx) 41 | traverse(tree[idx], 42 | func, 43 | base_path + idx, 44 | leafs_only 45 | ); 46 | } 47 | } 48 | 49 | void traverse(const value& tree, 50 | const std::function& func, 51 | bool leafs_only 52 | ) 53 | { 54 | traverse(tree, func, path(), leafs_only); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/detail/regex.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Internal-only header for regex. 3 | * 4 | * Copyright (c) 2016 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_DETAIL_REGEX_HPP_INCLUDED__ 13 | #define __JSONV_DETAIL_REGEX_HPP_INCLUDED__ 14 | 15 | /** \def JSONV_REGEX_INCLUDE 16 | * Controls the regular expression engine to use. By default, this will use the C++ Standard Library implementation. 17 | * GCC versions below 4.8 will happy compile regular expressions, but will fail at runtime. If using GCC under 4.9, it 18 | * is recommended that you set \c JSONV_REGEX_USE_BOOST to \c 1. 19 | * 20 | * \def JSONV_REGEX_NAMESPACE 21 | * The regular expression namespace to use. By default, this is \c std. 22 | * 23 | * \def JSONV_REGEX_USE_BOOST 24 | * Use Boost as the regular expression engine. Sets \c JSONV_REGEX_INCLUDE to \c and 25 | * \c JSONV_REGEX_NAMESPACE to \c boost. 26 | **/ 27 | #ifndef JSONV_REGEX_INCLUDE 28 | # if defined(JSONV_REGEX_USE_BOOST) && JSONV_REGEX_USE_BOOST 29 | # define JSONV_REGEX_INCLUDE 30 | # define JSONV_REGEX_NAMESPACE boost 31 | # else 32 | # define JSONV_REGEX_INCLUDE 33 | # define JSONV_REGEX_NAMESPACE std 34 | # endif 35 | #elif !defined(JSONV_REGEX_NAMESPACE) 36 | # error "JSONV_REGEX_NAMESPACE is unset, but JSONV_REGEX_INCLUDE is. You must set both." 37 | #elif defined(JSONV_REGEX_NAMESPACE) 38 | # error "JSONV_REGEX_INCLUDE is unset, but JSONV_REGEX_NAMESPACE is. You must set both." 39 | #endif 40 | 41 | #include JSONV_REGEX_INCLUDE 42 | 43 | namespace jsonv 44 | { 45 | namespace detail 46 | { 47 | 48 | namespace regex = JSONV_REGEX_NAMESPACE; 49 | 50 | } 51 | } 52 | 53 | #endif/*__JSONV_DETAIL_REGEX_HPP_INCLUDED__*/ 54 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/tokenizer_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | namespace jsonv_test 19 | { 20 | 21 | using namespace jsonv; 22 | 23 | TEST(token_kind_streaming) 24 | { 25 | ensure_eq(to_string(token_kind::boolean), "boolean"); 26 | ensure_eq(to_string(token_kind::boolean | token_kind::string), "boolean|string"); 27 | ensure_eq(to_string(token_kind::boolean | token_kind::parse_error_indicator), "parse_error(boolean)"); 28 | ensure_eq(to_string(token_kind::number | static_cast(0x4000)), "number|0x4000"); 29 | } 30 | 31 | TEST(token_kind_streaming_random) 32 | { 33 | // create a bunch of (most likely invalid) token_kind values and to_string them...this sort of checks that we 34 | // never infinitely loop in the output formatter 35 | std::random_device prng; 36 | for (std::size_t x = 0; x < 1000; ++x) 37 | { 38 | token_kind tok = static_cast(prng()); 39 | to_string(tok); 40 | } 41 | } 42 | 43 | TEST(tokenizer_single_boolean) 44 | { 45 | std::string input = "true"; 46 | std::istringstream istream(input); 47 | tokenizer tokens(istream); 48 | ensure(tokens.next()); 49 | auto found = tokens.current(); 50 | ensure_eq(found.kind, token_kind::boolean); 51 | ensure_eq(found.text, "true"); 52 | } 53 | 54 | TEST(tokenizer_string) 55 | { 56 | std::string input = "\"true\""; 57 | std::istringstream istream(input); 58 | tokenizer tokens(istream); 59 | ensure(tokens.next()); 60 | auto found = tokens.current(); 61 | ensure_eq(found.kind, token_kind::string); 62 | ensure_eq(found.text, "\"true\""); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /CRUD/handlers/crud_matcher.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: crud_matcher.hpp 3 | * Author: vvenedict@gmail.com 4 | * 5 | * Created on September 29, 2015, 6:06 PM 6 | */ 7 | 8 | #ifndef _HTTP_CRUD_MATCHER_HPP__ 9 | #define _HTTP_CRUD_MATCHER_HPP__ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace http { namespace crud { 16 | 17 | template 18 | struct crud_match : Matched { 19 | crud_match(const Matched &m, const std::string &d) : Matched(m) , data(d) {} 20 | std::string data; 21 | }; 22 | 23 | template 24 | struct crud_matcher { 25 | typedef std::function &)> request_handler_type; 26 | typedef crud_matcher self_type ; 27 | explicit crud_matcher(const Regex &expression) : _expression(expression) {} 28 | self_type & get(request_handler_type handler) { 29 | _handlers["GET"] = handler; 30 | return *this ; 31 | } 32 | self_type & post(request_handler_type handler) { 33 | _handlers["POST"] = handler; 34 | return *this; 35 | } 36 | self_type & del(request_handler_type handler) { 37 | _handlers["DELETE"] = handler; 38 | return *this; 39 | } 40 | self_type & put(request_handler_type handler) { 41 | _handlers["PUT"] = handler; 42 | return *this; 43 | } 44 | template 45 | void handle_request(const Request& request, Response& response, const Matched &what) { 46 | //dispatching to matching based on CRUD handler 47 | crud_match match(what, request.data) ; 48 | auto &handler = _handlers[request.method]; 49 | if (handler) { 50 | handler(response, match); 51 | } 52 | } 53 | private: 54 | Regex _expression; 55 | std::map _handlers; 56 | }; 57 | 58 | }} 59 | 60 | #endif /* __HTTP_CRUD_MATCHER__ */ 61 | -------------------------------------------------------------------------------- /jsonv/src/json-benchmark/core.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSON_BENCHMARK_CORE_HPP_INCLUDED__ 12 | #define __JSON_BENCHMARK_CORE_HPP_INCLUDED__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace json_benchmark 19 | { 20 | 21 | class benchmark_suite 22 | { 23 | public: 24 | using value_ptr = std::shared_ptr; 25 | 26 | using suite_list = std::deque; 27 | 28 | public: 29 | static const suite_list& all(); 30 | 31 | explicit benchmark_suite(std::string name); 32 | 33 | virtual ~benchmark_suite() noexcept; 34 | 35 | benchmark_suite(const benchmark_suite&) = delete; 36 | benchmark_suite& operator=(const benchmark_suite&) = delete; 37 | 38 | const std::string& name() const { return _name; } 39 | 40 | virtual void parse_test(const std::string& source) const = 0; 41 | 42 | virtual value_ptr create_value(const std::string& source) const = 0; 43 | 44 | private: 45 | std::string _name; 46 | }; 47 | 48 | template 49 | class typed_benchmark_suite : 50 | public benchmark_suite 51 | { 52 | public: 53 | using value_type = TValue; 54 | 55 | using benchmark_suite::benchmark_suite; 56 | 57 | virtual void parse_test(const std::string& source) const override 58 | { 59 | value_type x = parse(source); 60 | static_cast(x); 61 | } 62 | 63 | virtual value_ptr create_value(const std::string& source) const override 64 | { 65 | return std::make_shared(parse(source)); 66 | } 67 | 68 | protected: 69 | virtual value_type parse(const std::string& source) const = 0; 70 | }; 71 | 72 | } 73 | 74 | #endif/*__JSON_BENCHMARK_CORE_HPP_INCLUDED__*/ 75 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/functional_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | namespace jsonv_test 22 | { 23 | 24 | using namespace jsonv; 25 | 26 | using string_list = std::vector; 27 | 28 | template 29 | static void check_sort(const formats& fmts, string_list source, FJsonCmp json_cmp, FStrCmp str_cmp) 30 | { 31 | value orig = to_json(source, fmts); 32 | if (source != extract(orig, fmts)) 33 | throw std::logic_error("Extraction or encoding is broken"); 34 | 35 | std::sort(source.begin(), source.end(), str_cmp); 36 | std::sort(orig.begin_array(), orig.end_array(), json_cmp); 37 | 38 | if (source != extract(orig, fmts)) 39 | throw std::logic_error("Sorting did not produce identical results"); 40 | } 41 | 42 | TEST(functional_sort_strings) 43 | { 44 | formats fmts = 45 | formats::compose 46 | ({ 47 | formats_builder() 48 | .register_container>(), 49 | formats::defaults() 50 | }); 51 | std::vector source = { "fire", "wind", "water", "earth", "heart" }; 52 | 53 | check_sort(fmts, source, value_less(), std::less()); 54 | check_sort(fmts, source, value_less_equal(), std::less_equal()); 55 | check_sort(fmts, source, value_greater(), std::greater()); 56 | check_sort(fmts, source, value_greater_equal(), std::greater_equal()); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /CRUD/service/mime_types.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // mime_types.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Modified by: Vladimir Venediktov 11 | // Introduced constexpr for compile time use case 12 | // 13 | 14 | #ifndef HTTP_MIME_TYPES_HPP 15 | #define HTTP_MIME_TYPES_HPP 16 | 17 | #include 18 | 19 | namespace http { 20 | namespace server { 21 | namespace mime_types { 22 | 23 | struct mapping 24 | { 25 | const char* extension; 26 | const char* mime_type; 27 | } constexpr mappings[] = 28 | { 29 | { "gif", "image/gif" }, 30 | { "htm", "text/html" }, 31 | { "html", "text/html" }, 32 | { "jpg", "image/jpeg" }, 33 | { "png", "image/png" }, 34 | { "json", "application/json"}, 35 | { "css", "text/css"} 36 | }; 37 | 38 | 39 | constexpr bool equal( char const* lhs, char const* rhs ) 40 | { 41 | while (*lhs || *rhs) 42 | if (*lhs++ != *rhs++) 43 | return false; 44 | return true; 45 | } 46 | 47 | constexpr const char* extension_to_type(const char* extension) 48 | { 49 | for (mapping m: mappings) 50 | { 51 | if (equal(m.extension,extension) ) 52 | { 53 | return m.mime_type; 54 | } 55 | } 56 | 57 | return "text/plain"; 58 | } 59 | 60 | constexpr const char* GIF = mime_types::extension_to_type("gif"); 61 | constexpr const char* HTM = mime_types::extension_to_type("htm"); 62 | constexpr const char* HTML = mime_types::extension_to_type("html"); 63 | constexpr const char* JPG = mime_types::extension_to_type("jpg"); 64 | constexpr const char* PNG = mime_types::extension_to_type("png"); 65 | constexpr const char* JSON = mime_types::extension_to_type("json"); 66 | constexpr const char* CSS = mime_types::extension_to_type("css"); 67 | 68 | /// Convert a file extension into a MIME type. 69 | std::string extension_to_type(const std::string& extension); 70 | 71 | } // namespace mime_types 72 | } // namespace server 73 | } // namespace http 74 | 75 | #endif // HTTP_MIME_TYPES_HPP 76 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/char_convert.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2012 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #ifndef __JSONV_CHAR_CONVERT_HPP_INCLUDED__ 12 | #define __JSONV_CHAR_CONVERT_HPP_INCLUDED__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | namespace jsonv 22 | { 23 | namespace detail 24 | { 25 | 26 | class decode_error : 27 | public std::runtime_error 28 | { 29 | public: 30 | typedef std::string::size_type size_type; 31 | public: 32 | decode_error(size_type offset, const std::string& message); 33 | 34 | virtual ~decode_error() noexcept; 35 | 36 | inline size_type offset() const 37 | { 38 | return _offset; 39 | } 40 | 41 | private: 42 | size_type _offset; 43 | }; 44 | 45 | /** Encodes C++ string \a source into a fully-escaped JSON string into \a stream ready for sending over the wire. 46 | **/ 47 | std::ostream& string_encode(std::ostream& stream, string_view source, bool ensure_ascii = true); 48 | 49 | /** A function that decodes an over the wire character sequence \c source into a C++ string. **/ 50 | typedef std::string (*string_decode_fn)(string_view source); 51 | 52 | /** Get a string decoding function for the given output \a encoding. **/ 53 | string_decode_fn get_string_decoder(parse_options::encoding encoding); 54 | 55 | /** Convert the UTF-8 encoded \a source into a UTF-16 encoded \c std::wstring. **/ 56 | std::wstring convert_to_wide(string_view source); 57 | 58 | /** Convert the UTF-16 encoded \a source into a UTF-8 encoded \c std::string. **/ 59 | std::string convert_to_narrow(const std::wstring& source); 60 | std::string convert_to_narrow(const wchar_t* source); 61 | 62 | } 63 | } 64 | 65 | #endif/*__JSONV_CHAR_CONVERT_HPP_INCLUDED__*/ 66 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/unicode_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2012-2014 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | TEST(parse_unicode_single) 17 | { 18 | std::string s = jsonv::parse("\"\\u0004\"").as_string(); 19 | ensure(s.size() == 1); 20 | ensure(s[0] == '\x04'); 21 | } 22 | 23 | TEST(parse_unicode_inline) 24 | { 25 | std::string s = jsonv::parse("\"é\"").as_string(); 26 | ensure(s.size() == 2); 27 | ensure(s[0] == '\xc3'); 28 | ensure(s[1] == '\xa9'); 29 | } 30 | 31 | TEST(parse_unicode_multi) 32 | { 33 | std::string s = jsonv::parse("\"\\u00e9\"").as_string(); 34 | ensure(s.size() == 2); 35 | ensure(s[0] == '\xc3'); 36 | ensure(s[1] == '\xa9'); 37 | } 38 | 39 | TEST(parse_unicode_insanity) 40 | { 41 | std::string s = jsonv::parse("\"\\uface\"").as_string(); 42 | ensure(s.size() == 3); 43 | // The right answer according to Python: u'\uface'.encode('utf-8') 44 | const char vals[] = "\xef\xab\x8e"; 45 | for (unsigned idx = 0; idx < 3; ++idx) 46 | ensure(s[idx] == vals[idx]); 47 | } 48 | 49 | TEST(parse_unicode_invalid_surrogates) 50 | { 51 | ensure_throws(jsonv::parse_error, jsonv::parse("\"\\udead\\ubeef\"").as_string()); 52 | } 53 | 54 | TEST(parse_unicode_invalid_surrogates_cesu8) 55 | { 56 | std::string s = jsonv::parse("\"\\udead\\ubeef\"", 57 | jsonv::parse_options().string_encoding(jsonv::parse_options::encoding::cesu8) 58 | ).as_string(); 59 | ensure(s.size() == 6); 60 | // The right answer according to Python: u'\udead\ubeef'.encode('utf-8') 61 | const char vals[] = "\xed\xba\xad\xeb\xbb\xaf"; 62 | for (unsigned idx = 0; idx < sizeof vals; ++idx) 63 | ensure(s[idx] == vals[idx]); 64 | } 65 | -------------------------------------------------------------------------------- /examples/bidder/bidder_caches.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: bidder_caches.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 16 февраля 2017 г., 21:15 6 | */ 7 | 8 | #ifndef BIDDER_CACHES_HPP 9 | #define BIDDER_CACHES_HPP 10 | 11 | #include "examples/matchers/ad.hpp" 12 | #include "examples/matchers/geo.hpp" 13 | #include "examples/matchers/geo_campaign.hpp" 14 | #include "rtb/core/openrtb.hpp" 15 | #include "rtb/common/perf_timer.hpp" 16 | #include "examples/campaign/campaign_cache.hpp" 17 | 18 | namespace vanilla { 19 | template 20 | struct BidderCaches { 21 | public: 22 | BidderCaches(const Config &config): 23 | config(config), 24 | ad_data_entity(config), 25 | geo_data_entity(config), 26 | geo_campaign_entity(config), 27 | budget_cache(config) 28 | {} 29 | void load() noexcept(false) { 30 | auto sp = std::make_shared(); 31 | { 32 | perf_timer timer(sp, "\nselector load"); 33 | { 34 | perf_timer timer(sp, "\nad load"); 35 | ad_data_entity.load(); 36 | } 37 | { 38 | perf_timer timer(sp, "\ngeo_data load"); 39 | geo_data_entity.load(); 40 | } 41 | { 42 | perf_timer timer(sp, "\ngeo_campaign load"); 43 | geo_campaign_entity.load(); 44 | } 45 | { 46 | perf_timer timer(sp, "\nbudget_cache load"); 47 | budget_cache.load(); 48 | } 49 | // load others 50 | } 51 | LOG(info) << sp->str() ; 52 | } 53 | const Config &config; 54 | AdDataEntity ad_data_entity; 55 | GeoDataEntity geo_data_entity; 56 | GeoCampaignEntity geo_campaign_entity; 57 | vanilla::CampaignCache budget_cache; 58 | }; 59 | } 60 | 61 | #endif /* BIDDER_CACHES_HPP */ 62 | 63 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/util_diff_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | #include "filesystem_util.hpp" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | namespace jsonv_test 21 | { 22 | 23 | using namespace jsonv; 24 | 25 | class json_diff_test : 26 | public unit_test 27 | { 28 | public: 29 | json_diff_test(std::string path) : 30 | unit_test(std::string("diff_test/") + filename(path)), 31 | path(std::move(path)) 32 | { } 33 | 34 | virtual void run_impl() override 35 | { 36 | value whole; 37 | { 38 | std::ifstream in(path.c_str()); 39 | whole = parse(in); 40 | } 41 | 42 | diff_result result = diff(whole.at_path(".input.left"), whole.at_path(".input.right")); 43 | diff_result expected; 44 | expected.same = whole.at_path(".result.same"); 45 | expected.right = whole.at_path(".result.right"); 46 | expected.left = whole.at_path(".result.left"); 47 | 48 | ensure_eq(expected.same, result.same); 49 | ensure_eq(expected.left, result.left); 50 | ensure_eq(expected.right, result.right); 51 | } 52 | 53 | private: 54 | std::string path; 55 | }; 56 | 57 | class json_diff_test_initializer 58 | { 59 | public: 60 | explicit json_diff_test_initializer(const std::string& rootpath) 61 | { 62 | recursive_directory_for_each(rootpath, ".json", [this] (const std::string& p) 63 | { 64 | _tests.emplace_back(new json_diff_test(p)); 65 | }); 66 | } 67 | 68 | private: 69 | std::deque> _tests; 70 | } json_diff_test_initializer_instance(test_path("diffs")); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /examples/campaign/slavebanker_service_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * File: slavebanker_service_test.cpp 4 | * Author: vladimir venediktov 5 | * 6 | * Created on March 29, 2017, 9:47 PM 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "rtb/config/config.hpp" 13 | #include "rtb/messaging/communicator.hpp" 14 | #include "campaign_cache.hpp" 15 | #include "serialization.hpp" 16 | 17 | #include "rtb/core/core.hpp" 18 | 19 | extern void init_framework_logging(const std::string &) ; 20 | 21 | using namespace vanilla; 22 | 23 | template 24 | void run(short port, Cache &cache) { 25 | using namespace vanilla::messaging; 26 | communicator().inbound(port).consume([&cache](auto endpoint, auto budget) { 27 | cache.update(budget,budget.campaign_id); 28 | LOG(debug) << "updated budget :" << budget; 29 | return ; 30 | }).dispatch(); 31 | } 32 | 33 | int main(int argc, char** argv) { 34 | using CampaignCacheType = CampaignCache; 35 | //using CampaignBudgets = typename CampaignCacheType::DataCollection; 36 | namespace po = boost::program_options; 37 | vanilla::config::config config([](slavebanker_service_config_data &d, po::options_description &desc){ 38 | desc.add_options() 39 | ("slave-banker-service.log", po::value(&d.log_file_name), "slavebanker_service_test log file name") 40 | ("multi_bidder.budget_port", po::value(&d.budget_port)->required(), "udp port for broadcast to bidders budget change") 41 | ("slave-banker-service.ipc_name", po::value(&d.ipc_name)->required(), "name of campaign manager ipc cache") 42 | ; 43 | }); 44 | try { 45 | config.parse(argc, argv); 46 | } 47 | catch(std::exception const& e) { 48 | LOG(error) << e.what(); 49 | return 0; 50 | } 51 | LOG(debug) << config; 52 | init_framework_logging(config.data().log_file_name); 53 | 54 | CampaignCacheType cache(config); 55 | run(config.data().budget_port, cache); 56 | 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/multiexchange/multiexchange_status.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: multiexchange_config.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 25 марта 2017 г., 13:17 6 | */ 7 | 8 | #ifndef MULTIEXCHANGE_STATUS_HPP 9 | #define MULTIEXCHANGE_STATUS_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace vanilla { 16 | namespace multiexchange { 17 | struct multi_exchange_status { 18 | boost::posix_time::ptime start{boost::posix_time::microsec_clock::local_time()}; 19 | boost::atomic_uint64_t request_count{}; 20 | boost::atomic_uint64_t all_response_count{}; 21 | boost::atomic_uint64_t bidder_response_count{}; 22 | boost::atomic_uint64_t empty_response_count{}; 23 | boost::atomic_uint64_t timeout_response_count{}; 24 | 25 | friend std::ostream& operator<<(std::ostream &os, const multi_exchange_status &st) { 26 | boost::posix_time::time_duration td = boost::posix_time::microsec_clock::local_time() - st.start; 27 | os << "start: " << boost::posix_time::to_simple_string(st.start) << "
" << 28 | "elapsed: " << boost::posix_time::to_simple_string(td) << "
" << 29 | "" << 30 | "" << 31 | "" << 32 | "" << 33 | "" << 34 | "" << 35 | "
requests" << st.request_count << "
all bidders responsed" << st.all_response_count << "
bid responses" << st.bidder_response_count << "
empty responses" << st.empty_response_count << "
timeout responses" << st.timeout_response_count << "
"; 36 | return os; 37 | } 38 | 39 | std::string to_string() const { 40 | std::stringstream ss; 41 | ss << *this; 42 | return ss.str(); 43 | } 44 | }; 45 | } 46 | } 47 | #endif /* MULTIEXCHANGE_STATUS_HPP */ 48 | 49 | -------------------------------------------------------------------------------- /examples/curl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROGNAME=${0##*/} 4 | PROGVERSION=1.0.1 5 | 6 | usage() 7 | { 8 | cat << EO 9 | Usage: $PROGNAME [options] 10 | $PROGNAME -o -c 11 | 12 | Increase the .deb file's version number, noting the change in the 13 | 14 | 15 | Options: 16 | EO 17 | cat < /dev/null` 90 | echo $output 91 | 92 | -------------------------------------------------------------------------------- /jsonv/src/jsonv-tests/algorithm_map_tests.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include "test.hpp" 12 | 13 | #include 14 | #include 15 | 16 | namespace jsonv_test 17 | { 18 | 19 | using namespace jsonv; 20 | 21 | TEST(map_scalar) 22 | { 23 | value init = 2; 24 | value result = init.map([] (const value& x) { return x.as_integer() * 2; }); 25 | ensure_eq(init, 2); 26 | ensure_eq(result, 4); 27 | } 28 | 29 | TEST(map_array) 30 | { 31 | value init = array({ 1, 2, 3 }); 32 | value result = init.map([] (const value& x) { return x.as_integer() * 2; }); 33 | ensure_eq(init, array({ 1, 2, 3 })); 34 | ensure_eq(result, array({ 2, 4, 6 })); 35 | } 36 | 37 | TEST(map_object) 38 | { 39 | value init = object({ { "one", 1 }, { "two", 2 } }); 40 | value result = init.map([] (const value& x) { return x.as_integer() * 2; }); 41 | ensure_eq(init, object({ { "one", 1 }, { "two", 2 } })); 42 | ensure_eq(result, object({ { "one", 2 }, { "two", 4 } })); 43 | } 44 | 45 | TEST(map_scalar_rvalue) 46 | { 47 | value init = 2; 48 | value result = std::move(init).map([] (const value& x) { return x.as_integer() * 2; }); 49 | ensure_eq(init, value(null)); 50 | ensure_eq(result, 4); 51 | } 52 | 53 | TEST(map_array_rvalue) 54 | { 55 | value init = array({ 1, 2, 3 }); 56 | value result = std::move(init).map([] (const value& x) { return x.as_integer() * 2; }); 57 | ensure_eq(init, value(null)); 58 | ensure_eq(result, array({ 2, 4, 6 })); 59 | } 60 | 61 | TEST(map_object_rvalue) 62 | { 63 | value init = object({ { "one", 1 }, { "two", 2 } }); 64 | value result = std::move(init).map([] (const value& x) { return x.as_integer() * 2; }); 65 | ensure_eq(init, value(null)); 66 | ensure_eq(result, object({ { "one", 2 }, { "two", 4 } })); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /jsonv/include/jsonv/string_view.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/string_view.hpp 2 | * Pulls in an implementation of \c string_view. 3 | * 4 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_STRING_VIEW_HPP_INCLUDED__ 13 | #define __JSONV_STRING_VIEW_HPP_INCLUDED__ 14 | 15 | #include 16 | 17 | /** \def JSONV_STRING_VIEW_TYPE 18 | * The type to use for \c jsonv::string_view. By default, this is \c jsonv::detail::string_view. 19 | * 20 | * \def JSONV_STRING_VIEW_INCLUDE 21 | * The file to include to get the implementation for \c string_view. If you define \c JSONV_STRING_VIEW_TYPE, you must 22 | * also define this. 23 | * 24 | * \def JSONV_STRING_VIEW_USE_STD 25 | * Set this to 1 to use \c std::string_view as the backing type for \c jsonv::string_view. 26 | * 27 | * \def JSONV_STRING_VIEW_USE_BOOST 28 | * Set this to 1 to use \c boost::string_ref as the backing type for \c jsonv::string_view. 29 | **/ 30 | #ifndef JSONV_STRING_VIEW_TYPE 31 | # if defined(JSONV_STRING_VIEW_USE_STD) && JSONV_STRING_VIEW_USE_STD 32 | # define JSONV_STRING_VIEW_TYPE std::string_view 33 | # define JSONV_STRING_VIEW_INCLUDE 34 | # elif defined(JSONV_STRING_VIEW_USE_BOOST) && JSONV_STRING_VIEW_USE_BOOST 35 | # define JSONV_STRING_VIEW_TYPE boost::string_ref 36 | # define JSONV_STRING_VIEW_INCLUDE 37 | # else 38 | # define JSONV_STRING_VIEW_TYPE jsonv::detail::string_view 39 | # define JSONV_STRING_VIEW_INCLUDE 40 | # endif 41 | #endif 42 | 43 | #include JSONV_STRING_VIEW_INCLUDE 44 | 45 | namespace jsonv 46 | { 47 | 48 | /** A non-owning reference to a string. 49 | * 50 | * \see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html 51 | **/ 52 | using string_view = JSONV_STRING_VIEW_TYPE; 53 | 54 | } 55 | 56 | #endif/*__JSONV_STRING_REF_HPP_INCLUDED__*/ 57 | -------------------------------------------------------------------------------- /rtb/exchange/multibidder_communicator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: multibidder_communicator.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 31 марта 2017 г., 12:14 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | 18 | #ifndef MULTIBIDDER_COMMUNICATOR_HPP 19 | #define MULTIBIDDER_COMMUNICATOR_HPP 20 | 21 | #include 22 | #include "rtb/messaging/communicator.hpp" 23 | #include "rtb/exchange/multibidder_collector.hpp" 24 | #include "rtb/core/openrtb.hpp" 25 | 26 | namespace vanilla { 27 | 28 | template 29 | < 30 | typename DSL, 31 | typename Duration = std::chrono::milliseconds, 32 | typename DeliveryType = vanilla::messaging::broadcast 33 | > 34 | class multibidder_communicator { 35 | private: 36 | using serialized_type = typename DSL::serialized_type; 37 | public: 38 | multibidder_communicator(uint16_t bidders_port, Duration response_timeout) : 39 | response_timeout(response_timeout) { 40 | communicator.outbound(bidders_port); 41 | } 42 | 43 | template 44 | void process(const Request &request, multibidder_collector &collector) { 45 | communicator 46 | .distribute(request) 47 | .template collect(response_timeout, [&collector](serialized_type bid, auto done) { //move ctored by collect() 48 | collector.add(std::move(bid)); 49 | if (collector.done()) { 50 | done(); 51 | } 52 | }); 53 | } 54 | private: 55 | vanilla::messaging::communicator communicator; 56 | Duration response_timeout; 57 | }; 58 | } 59 | #endif /* MULTIBIDDER_COMMUNICATOR_HPP */ 60 | 61 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/algorithm_map.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * Copyright (c) 2015 by Travis Gockel. All rights reserved. 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 6 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 7 | * version. 8 | * 9 | * \author Travis Gockel (travis@gockelhut.com) 10 | **/ 11 | #include 12 | #include 13 | 14 | namespace jsonv 15 | { 16 | 17 | value map(const std::function& func, 18 | const value& input 19 | ) 20 | { 21 | switch (input.kind()) 22 | { 23 | case kind::boolean: 24 | case kind::decimal: 25 | case kind::integer: 26 | case kind::null: 27 | case kind::string: 28 | return func(input); 29 | case kind::array: 30 | { 31 | value out = array(); 32 | for (const value& sub : input.as_array()) 33 | out.push_back(func(sub)); 34 | return out; 35 | } 36 | case kind::object: 37 | { 38 | value out = object(); 39 | for (const value::object_value_type& sub : input.as_object()) 40 | out.insert({ sub.first, func(sub.second) }); 41 | return out; 42 | } 43 | default: 44 | return null; 45 | } 46 | } 47 | 48 | value map(const std::function& func, 49 | value&& input 50 | ) 51 | { 52 | switch (input.kind()) 53 | { 54 | case kind::boolean: 55 | case kind::decimal: 56 | case kind::integer: 57 | case kind::null: 58 | case kind::string: 59 | return func(std::move(input)); 60 | case kind::array: 61 | { 62 | value out = array(); 63 | for (value& sub : input.as_array()) 64 | out.push_back(func(std::move(sub))); 65 | input = null; 66 | return out; 67 | } 68 | case kind::object: 69 | { 70 | value out = object(); 71 | for (value::object_value_type& sub : input.as_object()) 72 | out.insert({ sub.first, func(std::move(sub.second)) }); 73 | input = null; 74 | return out; 75 | } 76 | default: 77 | return null; 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /rtb/datacache/any_str_ops.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Copyright 2017 Vladimir Lysyy (mrbald@github) 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | #include 20 | #if BOOST_VERSION <= 106000 21 | #include 22 | namespace boost { 23 | template 24 | using basic_string_view = boost::basic_string_ref; 25 | } 26 | #else 27 | #include 28 | #endif 29 | 30 | #include 31 | 32 | namespace ufw { 33 | 34 | /** 35 | * Functor for containers transparent across `std::string`, 36 | * `boost::container::string`, `boost::string_view`, and `char const*`. 37 | */ 38 | template 39 | struct any_str_op { 40 | template 41 | bool operator () (X&& l, Y&& r) const { return op_(view(l), view(r)); } 42 | 43 | private: 44 | Op op_; 45 | 46 | using char_t = char; 47 | using char_traits_t = std::char_traits; 48 | using shm_str_t = typename boost::container::basic_string; 49 | using std_str_t = std::basic_string>; 50 | using str_view_t = boost::basic_string_view; 51 | 52 | static str_view_t view(char_t const* x) { return {x}; } 53 | static str_view_t view(shm_str_t const& x) { return {x.data(), x.size()}; } 54 | static str_view_t view(std_str_t const& x) { return {x}; } 55 | static str_view_t view(str_view_t x) { return x; } 56 | }; 57 | 58 | template 59 | using any_str_less = any_str_op>; 60 | 61 | } // namespace ufw 62 | -------------------------------------------------------------------------------- /jsonv/src/jsonv/detail/token_patterns.hpp: -------------------------------------------------------------------------------- 1 | /** \file jsonv/detail/token_patterns.hpp 2 | * Pattern matching for JSON tokens. 3 | * 4 | * Copyright (c) 2014 by Travis Gockel. All rights reserved. 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License 7 | * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * \author Travis Gockel (travis@gockelhut.com) 11 | **/ 12 | #ifndef __JSONV_DETAIL_TOKEN_PATTERNS_HPP_INCLUDED__ 13 | #define __JSONV_DETAIL_TOKEN_PATTERNS_HPP_INCLUDED__ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace jsonv 20 | { 21 | namespace detail 22 | { 23 | 24 | /** The result of a match. **/ 25 | enum class match_result 26 | { 27 | // A "complete" match -- a whole token was definitely found 28 | complete, 29 | // A "complete" match, but it might continue on 30 | complete_eof, 31 | // An "incomplete" match -- the pattern looks good so far, but we don't know for sure 32 | incomplete_eof, 33 | // Could not find a valid sequence. 34 | unmatched, 35 | }; 36 | 37 | /** Attempt to match the given sequence. 38 | * 39 | * \param begin The beginning of the sequence to attempt to match. 40 | * \param end The end of the sequence to attempt to match. 41 | * \param[out] kind The kind of token matched. 42 | * \param[out] length The length of the match, if found. 43 | * \returns the result of the match. 44 | **/ 45 | match_result attempt_match(const char* begin, 46 | const char* end, 47 | token_kind& kind, 48 | std::size_t& length 49 | ); 50 | 51 | enum class path_match_result : char 52 | { 53 | simple_object = '.', 54 | brace = '[', 55 | invalid = '\x00', 56 | }; 57 | 58 | /** Attempt to match a path. 59 | * 60 | * \param input The input to match 61 | * \param[out] match_contents The full contents of a match 62 | **/ 63 | path_match_result path_match(string_view input, 64 | string_view& match_contents 65 | ); 66 | 67 | } 68 | } 69 | 70 | #endif/*__JSONV_DETAIL_TOKEN_PATTERNS_HPP_INCLUDED__*/ 71 | -------------------------------------------------------------------------------- /jsonv/msvc/vs2015/JsonVoorhees.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.22512.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonv", "jsonv\jsonv.vcxproj", "{51AC737D-C2CD-4625-983F-DF0DBE8C30C5}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonv-tests", "jsonv-tests\jsonv-tests.vcxproj", "{07E981AF-1A6B-46FB-BC8C-895809D93558}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5} = {51AC737D-C2CD-4625-983F-DF0DBE8C30C5} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Debug|x64.ActiveCfg = Debug|x64 22 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Debug|x64.Build.0 = Debug|x64 23 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Debug|x86.ActiveCfg = Debug|Win32 24 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Debug|x86.Build.0 = Debug|Win32 25 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Release|x64.ActiveCfg = Release|x64 26 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Release|x64.Build.0 = Release|x64 27 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Release|x86.ActiveCfg = Release|Win32 28 | {51AC737D-C2CD-4625-983F-DF0DBE8C30C5}.Release|x86.Build.0 = Release|Win32 29 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Debug|x64.ActiveCfg = Debug|x64 30 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Debug|x64.Build.0 = Debug|x64 31 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Debug|x86.ActiveCfg = Debug|Win32 32 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Debug|x86.Build.0 = Debug|Win32 33 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Release|x64.ActiveCfg = Release|x64 34 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Release|x64.Build.0 = Release|x64 35 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Release|x86.ActiveCfg = Release|Win32 36 | {07E981AF-1A6B-46FB-BC8C-895809D93558}.Release|x86.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /rtb/client/empty_asio_client_adapter.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: empty_asio_client_adapter.hpp 3 | * Author: arseny.bushev@gmail.com 4 | * 5 | * Created on 31 марта 2017 г., 12:49 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | 18 | #ifndef EMPTY_ASIO_CLIENT_ADAPTER_HPP 19 | #define EMPTY_ASIO_CLIENT_ADAPTER_HPP 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace vanilla { 26 | class empty_asio_client_adapter { 27 | public: 28 | using connection_ok_handler_type = std::function; 29 | using connection_fail_handler_type = std::function; 30 | using get_handler_type = std::function; 31 | 32 | empty_asio_client_adapter(boost::asio::io_service &io): 33 | io{io} 34 | {} 35 | void connect(const std::string &host, uint16_t port, const connection_ok_handler_type &connection_ok_handler, const connection_fail_handler_type &connection_fail_handler) { 36 | // Please call specific clients connect method here, 37 | // call connection_ok_handler & connection_fail_handler in callback lambda 38 | connection_ok_handler(this->io); 39 | } 40 | void get(const std::string &key, std::string &data, const get_handler_type &get_handler) { 41 | // Please call specific clients get method here, 42 | // call get_handler in callback lambda 43 | get_handler(this->io, ""); 44 | } 45 | bool connected() const { 46 | // Please check weather specific client is connected here, 47 | return true; 48 | } 49 | private: 50 | boost::asio::io_service &io; 51 | }; 52 | 53 | } 54 | 55 | #endif /* EMPTY_ASIO_CLIENT_ADAPTER_HPP */ 56 | 57 | -------------------------------------------------------------------------------- /rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Returns number of code points in a encoded string. 49 | template 50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 51 | RAPIDJSON_ASSERT(s != 0); 52 | RAPIDJSON_ASSERT(outCount != 0); 53 | GenericStringStream is(s); 54 | const typename Encoding::Ch* end = s + length; 55 | SizeType count = 0; 56 | while (is.src_ < end) { 57 | unsigned codepoint; 58 | if (!Encoding::Decode(is, &codepoint)) 59 | return false; 60 | count++; 61 | } 62 | *outCount = count; 63 | return true; 64 | } 65 | 66 | } // namespace internal 67 | RAPIDJSON_NAMESPACE_END 68 | 69 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 70 | -------------------------------------------------------------------------------- /rtb/DSL/rapid_mapper.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: rapid_mapper.hpp 3 | * Author: Vladimir Venediktov vvenedict@gmail.com 4 | * Copyright (c) 2016-2018 Venediktes Gruppe, LLC 5 | * 6 | * Created on July 30, 2017, 10:01 PM 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | */ 18 | 19 | #pragma once 20 | #ifndef RTB_DSL_RAPID_MAPPER_HPP 21 | #define RTB_DSL_RAPID_MAPPER_HPP 22 | 23 | #include "extractors.hpp" 24 | #include "rapid_serializer.hpp" 25 | #include "rapidjson/document.h" 26 | #include "rapidjson/writer.h" 27 | 28 | namespace DSL { 29 | 30 | template 31 | class rapid_mapper { 32 | protected: 33 | using encoded_type = rapidjson::Document; 34 | public : 35 | using deserialized_type = openrtb::BidRequest; 36 | using serialized_type = openrtb::BidResponse; 37 | using parse_error_type = std::exception; 38 | 39 | using Impression = openrtb::Impression; 40 | using Bid = openrtb::Bid; 41 | using SeatBid = openrtb::SeatBid; 42 | 43 | template 44 | Deserialized extract(const string_view_type &bid_request) { 45 | thread_local encoded_type encoded; 46 | clear(encoded); 47 | encoded.Parse(bid_request.c_str()); 48 | return extractors::extract(encoded); 49 | } 50 | 51 | template 52 | auto serialize(const Serialized &bid_response) { 53 | rapidjson::StringBuffer sb; 54 | rapidjson::Writer writer(sb); 55 | serializer::template serialize(bid_response, writer); 56 | return std::string(sb.GetString(),sb.GetSize()); 57 | } 58 | 59 | void clear(encoded_type &encoded) { 60 | encoded_type tmp; 61 | std::swap(encoded,tmp); 62 | } 63 | }; 64 | } 65 | 66 | 67 | #endif /* RTB_DSL_RAPID_MAPPER_HPP */ 68 | 69 | -------------------------------------------------------------------------------- /CRUD/service/connection_manager.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // connection_manager.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Modified by Vladimir Venediktov : 11 | // 1.) adding template parameter for connection_ptr type , minimum changes required to work with 12 | // any handler, removing connection_manager.cpp from my project. 13 | // 2.) adding multi-threading support spin_lock/std::mutex conditional compilation 14 | 15 | #ifndef HTTP_CONNECTION_MANAGER_HPP 16 | #define HTTP_CONNECTION_MANAGER_HPP 17 | 18 | #include 19 | #include 20 | #if defined(CRUD_SPIN_LOCK) 21 | #include "spin_lock.hpp" 22 | #endif 23 | 24 | namespace http { 25 | namespace server { 26 | 27 | /// Manages open connections so that they may be cleanly stopped when the server 28 | /// needs to shut down. 29 | template 30 | class connection_manager 31 | { 32 | public: 33 | connection_manager(const connection_manager&) = delete; 34 | connection_manager& operator=(const connection_manager&) = delete; 35 | 36 | /// Construct a connection manager. 37 | connection_manager() {} 38 | 39 | /// Add the specified connection to the manager and start it. 40 | void start(connection_ptr c) 41 | { 42 | std::lock_guard guard(lock_); 43 | { 44 | connections_.insert(c); 45 | } 46 | c->start(); 47 | } 48 | 49 | /// Stop the specified connection. 50 | void stop(connection_ptr c) 51 | { 52 | std::lock_guard guard(lock_); 53 | { 54 | connections_.erase(c); 55 | } 56 | c->stop(); 57 | } 58 | 59 | /// Stop all connections. 60 | void stop_all() 61 | { 62 | for (auto c: connections_) 63 | c->stop(); 64 | std::lock_guard guard(lock_); 65 | connections_.clear(); 66 | } 67 | 68 | private: 69 | /// The managed connections. 70 | std::set connections_; 71 | /// adding multi-threading support 72 | #if defined(CRUD_SPIN_LOCK) 73 | using connection_lock_type = spin_lock; 74 | #else 75 | using connection_lock_type = std::mutex; 76 | #endif 77 | connection_lock_type lock_; 78 | }; 79 | 80 | } // namespace server 81 | } // namespace http 82 | 83 | #endif // HTTP_CONNECTION_MANAGER_HPP 84 | 85 | -------------------------------------------------------------------------------- /benchmarks/audit_benchmarks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "audit_codec.hpp" 4 | #include "audit_buffer.hpp" 5 | 6 | #include 7 | 8 | namespace { 9 | 10 | struct AuditBufferBenchmarkFixture: benchmark::Fixture 11 | { 12 | asio::io_service io_service; 13 | 14 | std::thread thread {[&] { 15 | asio::io_service::work work_{io_service}; 16 | io_service.run(); 17 | }}; 18 | 19 | auditor::segmented_log_buffer logbuf {io_service, ".", 1 << 25}; 20 | 21 | ~AuditBufferBenchmarkFixture() 22 | { 23 | io_service.stop(); 24 | if (thread.joinable()) { 25 | thread.join(); 26 | } 27 | } 28 | }; // AuditBufferBenchmarkFixture 29 | 30 | static auto rec = std::make_tuple(int8_t('a'), 1, "abcdef", 2.3, std::string_view("hello", sizeof("hello")-1)); 31 | static auto memory = std::array{}; 32 | 33 | void audit_encoder_benchmark(benchmark::State& state) 34 | { 35 | auto const encoder = [](auto&&... args) { 36 | return auditor::encode_record(memory.data(), std::forward(args)...); 37 | }; 38 | 39 | while (state.KeepRunning()) 40 | { 41 | benchmark::DoNotOptimize(std::apply(encoder, rec)); 42 | } 43 | 44 | //state.SetBytesProcessed(static_cast(state.iterations()) * input.size()); 45 | } 46 | 47 | BENCHMARK(audit_encoder_benchmark); 48 | 49 | 50 | void audit_size_calc_benchmark(benchmark::State& state) 51 | { 52 | auto const size_calculator = [](auto&&... args) { 53 | return auditor::full_record_size(std::forward(args)...); 54 | }; 55 | 56 | while (state.KeepRunning()) 57 | { 58 | benchmark::DoNotOptimize(std::apply(size_calculator, rec)); 59 | } 60 | } 61 | 62 | BENCHMARK(audit_size_calc_benchmark); 63 | 64 | BENCHMARK_DEFINE_F(AuditBufferBenchmarkFixture, audit_buffer_benchmark)(benchmark::State& state) 65 | { 66 | while (state.KeepRunning()) 67 | { 68 | uint32_t const required_size = std::apply([] (auto&&... args) { 69 | return auditor::full_record_size(std::forward(args)...); 70 | }, rec); 71 | 72 | std::apply([addr = logbuf.reserve(required_size)] (auto&&... args) { 73 | auditor::encode_record(addr.get(), std::forward(args)...); 74 | }, rec); 75 | } 76 | } 77 | 78 | BENCHMARK_REGISTER_F(AuditBufferBenchmarkFixture, audit_buffer_benchmark)->DenseThreadRange(1, 4); 79 | 80 | } // local namespace 81 | --------------------------------------------------------------------------------