otherwise when compiling with the new seastar, which removed
`#include <variant>` from `std-compat.hh`, the {mode}-headers
target would fail to build, like:
```
./data_dictionary/storage_options.hh:34:29: error: no template named 'variant' in namespace 'std'
10:45:15 using value_type = std::variant<local, s3>;
10:45:15 ~~~~~^
10:45:15 ./data_dictionary/storage_options.hh:35:5: error: unknown type name 'value_type'; did you mean 'std::_Bit_const_iterator::value_type'?
10:45:15 value_type value = local{};
10:45:15 ^~~~~~~~~~
10:45:15 std::_Bit_const_iterator::value_type
```
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Closes scylladb/scylladb#18921
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <variant>
|
|
#include <seastar/core/sstring.hh>
|
|
#include "seastarx.hh"
|
|
|
|
namespace data_dictionary {
|
|
|
|
struct storage_options {
|
|
struct local {
|
|
static constexpr std::string_view name = "LOCAL";
|
|
|
|
static local from_map(const std::map<sstring, sstring>&);
|
|
std::map<sstring, sstring> to_map() const;
|
|
bool operator==(const local&) const = default;
|
|
};
|
|
struct s3 {
|
|
sstring bucket;
|
|
sstring endpoint;
|
|
static constexpr std::string_view name = "S3";
|
|
|
|
static s3 from_map(const std::map<sstring, sstring>&);
|
|
std::map<sstring, sstring> to_map() const;
|
|
bool operator==(const s3&) const = default;
|
|
};
|
|
using value_type = std::variant<local, s3>;
|
|
value_type value = local{};
|
|
|
|
storage_options() = default;
|
|
|
|
bool is_local_type() const noexcept;
|
|
std::string_view type_string() const;
|
|
std::map<sstring, sstring> to_map() const;
|
|
|
|
bool can_update_to(const storage_options& new_options);
|
|
|
|
static value_type from_map(std::string_view type, std::map<sstring, sstring> values);
|
|
};
|
|
|
|
} // namespace data_dictionary
|