Seastar
High performance C++ framework for concurrent servers
multi_algo_compressor_factory.hh
1/*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18/*
19 * Copyright (C) 2016 Scylladb, Ltd.
20 */
21
22#pragma once
23
24#include <seastar/core/sstring.hh>
25#include <seastar/rpc/rpc_types.hh>
26
27namespace seastar {
28
29namespace rpc {
30
31// This is meta compressor factory. It gets an array of regular factories that
32// support one compression algorithm each and negotiates common compression algorithm
33// that is supported both by a client and a server. The order of algorithm preferences
34// is the order they appear in clien's list
36 std::vector<const rpc::compressor::factory*> _factories;
37 sstring _features;
38
39public:
40 multi_algo_compressor_factory(std::vector<const rpc::compressor::factory*> factories);
41 multi_algo_compressor_factory(std::initializer_list<const rpc::compressor::factory*> factories) :
42 multi_algo_compressor_factory(std::vector<const rpc::compressor::factory*>(std::move(factories))) {}
44 // return feature string that will be sent as part of protocol negotiation
45 const sstring& supported() const override {
46 return _features;
47 }
48 // negotiate compress algorithm
49 std::unique_ptr<compressor> negotiate(sstring feature, bool is_server) const override {
50 return negotiate(feature, is_server, nullptr);
51 }
52 std::unique_ptr<compressor> negotiate(sstring feature, bool is_server, std::function<future<>()> send_empty_frame) const override;
53};
54
55}
56
57}
A representation of a possibly not-yet-computed value.
Definition: future.hh:1198
Definition: rpc_types.hh:291
Definition: multi_algo_compressor_factory.hh:35
Seastar API namespace.
Definition: abort_on_ebadf.hh:26