blob: d4e6cce03ff5644c841530a72b3497c5a49220c5 [file] [log] [blame]
Rolf Badorekef2bf512019-08-20 11:17:15 +03001/*
2 Copyright (c) 2018-2019 Nokia.
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#ifndef SHAREDDATALAYER_REDIS_DATABASEINFO_HPP_
18#define SHAREDDATALAYER_REDIS_DATABASEINFO_HPP_
19
20#include <algorithm>
21#include <string>
22#include <vector>
23#include "private/databaseconfiguration.hpp"
24#include <boost/optional.hpp>
25
26namespace shareddatalayer
27{
28 namespace redis
29 {
30 struct DatabaseInfo
31 {
32 enum class Type
33 {
34 SINGLE,
35 REDUNDANT,
36 CLUSTER
37 };
38 enum class Discovery
39 {
40 HIREDIS,
Rolf Badorek8324d022019-09-17 16:47:20 +030041 SENTINEL
Rolf Badorekef2bf512019-08-20 11:17:15 +030042 };
43
44 DatabaseConfiguration::Addresses hosts;
45 Type type;
46 boost::optional<std::string> ns;
47 Discovery discovery;
48
49 bool operator==(const DatabaseInfo& di) const
50 {
51 DatabaseConfiguration::Addresses hosts1 = hosts;
52 DatabaseConfiguration::Addresses hosts2 = di.hosts;
53
54 std::sort(hosts1.begin(), hosts1.end());
55 std::sort(hosts2.begin(), hosts2.end());
56
57 return (hosts1 == hosts2 &&
58 type == di.type &&
59 ns == di.ns);
60 }
61
62 bool operator!=(const DatabaseInfo& di) const
63 {
64 return !(di == *this);
65 }
66 };
67 }
68}
69
70#endif