forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage_options.hh
72 lines (56 loc) · 1.99 KB
/
storage_options.hh
1
2
3
4
5
6
7
8
9
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (C) 2021-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include <filesystem>
#include <map>
#include <variant>
#include <seastar/core/sstring.hh>
#include "schema/schema_fwd.hh"
#include "seastarx.hh"
namespace seastar {
class abort_source;
}
namespace data_dictionary {
struct storage_options {
struct local {
std::filesystem::path dir;
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;
std::variant<sstring, table_id> location;
seastar::abort_source* abort_source = nullptr;
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);
storage_options append_to_s3_prefix(const sstring& s) const;
};
inline storage_options make_local_options(std::filesystem::path dir) {
storage_options so;
so.value = data_dictionary::storage_options::local { .dir = std::move(dir) };
return so;
}
} // namespace data_dictionary
template <>
struct fmt::formatter<data_dictionary::storage_options> {
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
auto format(const data_dictionary::storage_options&, fmt::format_context& ctx) const -> decltype(ctx.out());
};