From 84223ead8d9c26ce33e0029044284a3ffbb36f32 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 18 Nov 2025 22:43:28 -0800 Subject: [PATCH] chore: services in polystore --- include/boost/http_proto/parser.hpp | 6 +-- include/boost/http_proto/request_parser.hpp | 2 +- include/boost/http_proto/response_parser.hpp | 2 +- include/boost/http_proto/serializer.hpp | 6 +-- src/parser.cpp | 24 +++++------ src/request_parser.cpp | 2 +- src/response_parser.cpp | 2 +- src/serializer.cpp | 24 +++++------ test/unit/compression.cpp | 18 ++++----- test/unit/parser.cpp | 42 ++++++++++---------- test/unit/request_parser.cpp | 20 +++++----- test/unit/response_parser.cpp | 10 ++--- test/unit/serializer.cpp | 28 ++++++------- 13 files changed, 91 insertions(+), 95 deletions(-) diff --git a/include/boost/http_proto/parser.hpp b/include/boost/http_proto/parser.hpp index b87ddafb..029b441f 100644 --- a/include/boost/http_proto/parser.hpp +++ b/include/boost/http_proto/parser.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -617,7 +617,7 @@ class parser BOOST_HTTP_PROTO_DECL ~parser(); BOOST_HTTP_PROTO_DECL parser() noexcept; BOOST_HTTP_PROTO_DECL parser(parser&& other) noexcept; - BOOST_HTTP_PROTO_DECL parser(rts::context const&, detail::kind); + BOOST_HTTP_PROTO_DECL parser(rts::polystore&, detail::kind); BOOST_HTTP_PROTO_DECL void assign(parser&& other) noexcept; BOOST_HTTP_PROTO_DECL @@ -769,7 +769,7 @@ struct parser::config_base BOOST_HTTP_PROTO_DECL void install_parser_service( - rts::context& ctx, + rts::polystore& ctx, parser::config_base const& cfg); } // http_proto diff --git a/include/boost/http_proto/request_parser.hpp b/include/boost/http_proto/request_parser.hpp index f6cee2ee..bcdd06c2 100644 --- a/include/boost/http_proto/request_parser.hpp +++ b/include/boost/http_proto/request_parser.hpp @@ -140,7 +140,7 @@ class request_parser */ BOOST_HTTP_PROTO_DECL explicit - request_parser(rts::context const& ctx); + request_parser(rts::polystore& ctx); /** Return a reference to the parsed request headers. diff --git a/include/boost/http_proto/response_parser.hpp b/include/boost/http_proto/response_parser.hpp index 7e96b957..3b1d6e14 100644 --- a/include/boost/http_proto/response_parser.hpp +++ b/include/boost/http_proto/response_parser.hpp @@ -140,7 +140,7 @@ class response_parser */ BOOST_HTTP_PROTO_DECL explicit - response_parser(rts::context const& ctx); + response_parser(rts::polystore& ctx); /** Prepare for the next message on the stream. diff --git a/include/boost/http_proto/serializer.hpp b/include/boost/http_proto/serializer.hpp index a0dce023..282a60e1 100644 --- a/include/boost/http_proto/serializer.hpp +++ b/include/boost/http_proto/serializer.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -171,7 +171,7 @@ class serializer BOOST_HTTP_PROTO_DECL explicit serializer( - const rts::context& ctx); + rts::polystore& ctx); /** Reset the serializer for a new message. @@ -668,7 +668,7 @@ struct serializer::config BOOST_HTTP_PROTO_DECL void install_serializer_service( - rts::context& ctx, + rts::polystore& ctx, serializer::config const& cfg); //------------------------------------------------ diff --git a/src/parser.cpp b/src/parser.cpp index 9b31bcc6..fad95e6b 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -309,11 +309,11 @@ class zlib_filter public: zlib_filter( - const rts::context& ctx, + const rts::polystore& ctx, http_proto::detail::workspace& ws, int window_bits) : zlib_filter_base(ws) - , svc_(ctx.get_service()) + , svc_(ctx.get()) { system::error_code ec = static_cast( svc_.init2(strm_, window_bits)); @@ -359,9 +359,9 @@ class brotli_filter public: brotli_filter( - const rts::context& ctx, + const rts::polystore& ctx, http_proto::detail::workspace&) - : svc_(ctx.get_service()) + : svc_(ctx.get()) { // TODO: use custom allocator state_ = svc_.create_instance(nullptr, nullptr, nullptr); @@ -413,7 +413,6 @@ class brotli_filter }; class parser_service - : public rts::service { public: parser::config_base cfg; @@ -421,7 +420,6 @@ class parser_service std::size_t max_codec = 0; parser_service( - const rts::context&, parser::config_base const& cfg_) : cfg(cfg_) { @@ -507,10 +505,10 @@ class parser_service void install_parser_service( - rts::context& ctx, + rts::polystore& ctx, parser::config_base const& cfg) { - ctx.make_service(cfg); + ctx.emplace(cfg); } //------------------------------------------------ @@ -536,7 +534,7 @@ class parser::impl elastic, }; - const rts::context& ctx_; + const rts::polystore& ctx_; parser_service& svc_; detail::workspace ws_; @@ -569,9 +567,9 @@ class parser::impl bool chunked_body_ended; public: - impl(const rts::context& ctx, detail::kind k) + impl(const rts::polystore& ctx, detail::kind k) : ctx_(ctx) - , svc_(ctx.get_service()) + , svc_(ctx.get()) , ws_(svc_.space_needed) , m_(ws_.data(), ws_.size()) , state_(state::reset) @@ -1868,7 +1866,7 @@ parser(parser&& other) noexcept parser:: parser( - rts::context const& ctx, + rts::polystore& ctx, detail::kind k) : impl_(new impl(ctx, k)) { diff --git a/src/request_parser.cpp b/src/request_parser.cpp index 2834b4ae..4778a428 100644 --- a/src/request_parser.cpp +++ b/src/request_parser.cpp @@ -14,7 +14,7 @@ namespace http_proto { request_parser:: request_parser( - const rts::context& ctx) + rts::polystore& ctx) : parser( ctx, detail::kind::request) diff --git a/src/response_parser.cpp b/src/response_parser.cpp index c1baeefe..443003eb 100644 --- a/src/response_parser.cpp +++ b/src/response_parser.cpp @@ -14,7 +14,7 @@ namespace http_proto { response_parser:: response_parser( - const rts::context& ctx) + rts::polystore& ctx) : parser( ctx, detail::kind::response) diff --git a/src/serializer.cpp b/src/serializer.cpp index 14ea4547..07035451 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -94,13 +94,13 @@ class zlib_filter public: zlib_filter( - const rts::context& ctx, + const rts::polystore& ctx, http_proto::detail::workspace& ws, int comp_level, int window_bits, int mem_level) : zlib_filter_base(ws) - , svc_(ctx.get_service()) + , svc_(ctx.get()) { system::error_code ec = static_cast(svc_.init2( strm_, @@ -160,11 +160,11 @@ class brotli_filter public: brotli_filter( - const rts::context& ctx, + const rts::polystore& ctx, http_proto::detail::workspace&, std::uint32_t comp_quality, std::uint32_t comp_window) - : svc_(ctx.get_service()) + : svc_(ctx.get()) { // TODO: use custom allocator state_ = svc_.create_instance(nullptr, nullptr, nullptr); @@ -231,14 +231,12 @@ clamp( } class serializer_service - : public rts::service { public: serializer::config cfg; std::size_t space_needed = 0; serializer_service( - const rts::context&, serializer::config const& cfg_) : cfg(cfg_) { @@ -269,10 +267,10 @@ class serializer_service void install_serializer_service( - rts::context& ctx, + rts::polystore& ctx, serializer::config const& cfg) { - ctx.make_service(cfg); + ctx.emplace(cfg); } //------------------------------------------------ @@ -297,7 +295,7 @@ class serializer::impl stream }; - const rts::context& ctx_; + const rts::polystore& ctx_; serializer_service& svc_; detail::workspace ws_; @@ -319,9 +317,9 @@ class serializer::impl bool filter_done_ = false; public: - impl(const rts::context& ctx) + impl(const rts::polystore& ctx) : ctx_(ctx) - , svc_(ctx_.get_service()) + , svc_(ctx_.get()) , ws_(svc_.space_needed) { } @@ -957,7 +955,7 @@ operator=(serializer&& other) noexcept } serializer:: -serializer(rts::context const& ctx) +serializer(rts::polystore& ctx) : impl_(new impl(ctx)) { // TODO: use a single allocation for diff --git a/test/unit/compression.cpp b/test/unit/compression.cpp index 5dd75647..241f0064 100644 --- a/test/unit/compression.cpp +++ b/test/unit/compression.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include "test_helpers.hpp" @@ -55,7 +55,7 @@ struct zlib_test static std::string compress( - const rts::context& ctx, + const rts::polystore& ctx, core::string_view encoding, core::string_view body) { @@ -65,7 +65,7 @@ struct zlib_test if(encoding == "deflate" || encoding == "gzip") { namespace zlib = rts::zlib; - auto& svc = ctx.get_service(); + auto& svc = ctx.get(); zlib::stream zs{}; auto ret = static_cast( @@ -101,7 +101,7 @@ struct zlib_test else if(encoding == "br") { namespace brotli = rts::brotli; - auto& svc = ctx.get_service(); + auto& svc = ctx.get(); brotli::encoder_state* state = svc.create_instance(nullptr, nullptr, nullptr); @@ -145,7 +145,7 @@ struct zlib_test static void verify_compressed( - const rts::context& ctx, + const rts::polystore& ctx, core::string_view encoding, core::string_view compressed_body, core::string_view body) @@ -153,7 +153,7 @@ struct zlib_test if(encoding == "deflate" || encoding == "gzip") { namespace zlib = rts::zlib; - auto& svc = ctx.get_service(); + auto& svc = ctx.get(); zlib::stream zs{}; auto ret = static_cast( @@ -192,7 +192,7 @@ struct zlib_test else if(encoding == "br") { namespace brotli = rts::brotli; - auto& svc = ctx.get_service(); + auto& svc = ctx.get(); brotli::decoder_state* state = svc.create_instance(nullptr, nullptr, nullptr); @@ -376,7 +376,7 @@ struct zlib_test void test_serializer() { - rts::context ctx; + rts::polystore ctx; std::vector encodings; serializer::config cfg; @@ -612,7 +612,7 @@ struct zlib_test void test_parser() { - rts::context ctx; + rts::polystore ctx; std::vector encodings; response_parser::config cfg; diff --git a/test/unit/parser.cpp b/test/unit/parser.cpp index 55f8ee95..cc796eaa 100644 --- a/test/unit/parser.cpp +++ b/test/unit/parser.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "test_helpers.hpp" @@ -194,13 +194,13 @@ struct parser_test using pieces = std::vector< core::string_view>; - rts::context ctx_; + rts::polystore ctx_; core::string_view sh_; core::string_view sb_; request_parser req_pr_; response_parser res_pr_; parser* pr_ = nullptr; - opt ctx_opt_; + opt ctx_opt_; opt req_pr_opt_; opt res_pr_opt_; pieces in_; @@ -208,7 +208,7 @@ struct parser_test parser_test() : ctx_() , req_pr_( - [&]() -> rts::context& + [&]() -> rts::polystore& { request_parser::config cfg; cfg.body_limit = 5; @@ -337,7 +337,7 @@ struct parser_test { // parser(parser&&) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, {}); core::string_view header = @@ -379,7 +379,7 @@ struct parser_test void testStart() { - rts::context ctx; + rts::polystore ctx; request_parser::config_base cfg; install_parser_service(ctx, cfg); @@ -460,7 +460,7 @@ struct parser_test request_parser::config const& cfg, std::size_t n) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); request_parser pr(ctx); @@ -503,7 +503,7 @@ struct parser_test std::size_t n, core::string_view s) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); system::error_code ec; request_parser pr(ctx); @@ -556,7 +556,7 @@ struct parser_test core::string_view s, system::error_code ex = error::need_data) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); system::error_code ec; request_parser req_pr(ctx); @@ -673,7 +673,7 @@ struct parser_test { // fill capacity first - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); system::error_code ec; @@ -718,7 +718,7 @@ struct parser_test request_parser::config cfg; pieces in({ "GET / HTTP/1.1\r\n\r\n"}); - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); system::error_code ec; request_parser pr(ctx); @@ -830,7 +830,7 @@ struct parser_test // VFALCO missing chunked implementation { // buffered payload - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); request_parser pr(ctx_); @@ -852,7 +852,7 @@ struct parser_test bool is_complete, pieces&& in) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); system::error_code ec; response_parser pr(ctx); @@ -917,7 +917,7 @@ struct parser_test { // no-op - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); system::error_code ec; @@ -943,7 +943,7 @@ struct parser_test { // commit too large - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); system::error_code ec; @@ -1142,7 +1142,7 @@ struct parser_test bool is_complete, pieces&& in) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, cfg); system::error_code ec; response_parser pr(ctx); @@ -1625,7 +1625,7 @@ struct parser_test void testChunkedInPlace() { - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); @@ -1861,7 +1861,7 @@ struct parser_test testMultipleMessageInPlace() { request_parser::config cfg; - rts::context ctx; + rts::polystore ctx; cfg.headers.max_size = 500; cfg.min_buffer = 500; @@ -1972,7 +1972,7 @@ struct parser_test }; request_parser::config cfg; - rts::context ctx; + rts::polystore ctx; cfg.min_buffer = 500; cfg.headers.max_size = 500; @@ -2052,7 +2052,7 @@ struct parser_test void testSetBodyLimit() { - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; cfg.body_limit = 7; install_parser_service(ctx, cfg); @@ -2140,7 +2140,7 @@ struct parser_test // the parsed header must remain valid and // accessible if an error occurs during body parsing. - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); response_parser pr(ctx); diff --git a/test/unit/request_parser.cpp b/test/unit/request_parser.cpp index b9d93365..a6373042 100644 --- a/test/unit/request_parser.cpp +++ b/test/unit/request_parser.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "test_suite.hpp" @@ -86,7 +86,7 @@ struct request_parser_test void good( - rts::context& ctx, + rts::polystore& ctx, core::string_view s, core::string_view expected = {}) { @@ -107,7 +107,7 @@ struct request_parser_test } void - bad(rts::context& ctx, core::string_view s) + bad(rts::polystore& ctx, core::string_view s) { for(std::size_t nmax = 1; nmax < s.size(); ++nmax) @@ -135,7 +135,7 @@ struct request_parser_test BOOST_TEST(req.version() == v); }; - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); @@ -213,16 +213,16 @@ struct request_parser_test { request_parser pr; - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); BOOST_TEST_NO_THROW(pr = request_parser(ctx)); } - // request_parser(rts::context&) + // request_parser(rts::polystore&) { - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); request_parser pr(ctx); @@ -230,7 +230,7 @@ struct request_parser_test // request_parser(request_parser&&) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, {}); request_parser pr1(ctx); request_parser pr2(std::move(pr1)); @@ -266,7 +266,7 @@ struct request_parser_test "\r\n\r\n"; }; - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); @@ -325,7 +325,7 @@ struct request_parser_test void testGet() { - rts::context ctx; + rts::polystore ctx; request_parser::config cfg; install_parser_service(ctx, cfg); request_parser pr(ctx); diff --git a/test/unit/response_parser.cpp b/test/unit/response_parser.cpp index c440eabc..31b86582 100644 --- a/test/unit/response_parser.cpp +++ b/test/unit/response_parser.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include +#include #include "test_suite.hpp" @@ -32,7 +32,7 @@ class response_parser_test { response_parser pr; - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); @@ -43,9 +43,9 @@ class response_parser_test BOOST_TEST_NO_THROW(pr = response_parser()); } - // response_parser(rts::context&) + // response_parser(rts::polystore&) { - rts::context ctx; + rts::polystore ctx; response_parser::config cfg; install_parser_service(ctx, cfg); response_parser pr(ctx); @@ -53,7 +53,7 @@ class response_parser_test // response_parser(response_parser&&) { - rts::context ctx; + rts::polystore ctx; install_parser_service(ctx, {}); response_parser pr1(ctx); response_parser pr2(std::move(pr1)); diff --git a/test/unit/serializer.cpp b/test/unit/serializer.cpp index 9aba02cd..79c166b4 100644 --- a/test/unit/serializer.cpp +++ b/test/unit/serializer.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "test_helpers.hpp" @@ -180,7 +180,7 @@ struct serializer_test void testSyntax() { - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); response res; @@ -213,7 +213,7 @@ struct serializer_test void testSpecial() { - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); response res; res.set_chunked(true); @@ -281,7 +281,7 @@ struct serializer_test core::string_view expected) { response res(headers); - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); sr.start(res); @@ -338,7 +338,7 @@ struct serializer_test body.remove_prefix(buf_size); } - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); sr.start(res, buf); @@ -364,7 +364,7 @@ struct serializer_test response res(headers); // we limit the buffer size of the serializer, requiring // it to make multiple calls to source::read - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); sr.start(res, std::forward< @@ -381,7 +381,7 @@ struct serializer_test F f) { response res(headers); - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); auto stream = sr.start_stream(res); @@ -569,7 +569,7 @@ struct serializer_test response res( "HTTP/1.1 200 OK\r\n" "\r\n"); - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); @@ -723,7 +723,7 @@ struct serializer_test { // request { - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); request req( @@ -769,7 +769,7 @@ struct serializer_test // empty body { - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); request req( @@ -814,7 +814,7 @@ struct serializer_test "Expect: 100-continue\r\n" "\r\n"; - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); response res(sv); @@ -844,7 +844,7 @@ struct serializer_test "HTTP/1.1 200 OK\r\n" "\r\n"; response res(sv); - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); auto stream = sr.start_stream(res); @@ -896,7 +896,7 @@ struct serializer_test "Transfer-Encoding: chunked\r\n" "\r\n"; response res(sv); - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); auto stream = sr.start_stream(res); @@ -957,7 +957,7 @@ struct serializer_test void testOverConsume() { - rts::context ctx; + rts::polystore ctx; install_serializer_service(ctx, {}); serializer sr(ctx); request req;