-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcommon.hpp
More file actions
62 lines (49 loc) · 1.39 KB
/
common.hpp
File metadata and controls
62 lines (49 loc) · 1.39 KB
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
#pragma once
#include <boost/uuid/uuid.hpp>
#include <folly/Expected.h>
#include <folly/Unit.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#include <folly/futures/Future.h>
#pragma GCC diagnostic pop
#include <sisl/logging/logging.h>
#include <random>
SISL_LOGGING_DECL(homeobject);
#define HOMEOBJECT_LOG_MODS homeobject, blobmgr, shardmgr, gcmgr, scrubmgr
#ifndef Ki
constexpr uint64_t Ki = 1024ul;
#endif
#ifndef Mi
constexpr uint64_t Mi = Ki * Ki;
#endif
#ifndef Gi
constexpr uint64_t Gi = Ki * Mi;
#endif
namespace homeobject {
using blob_id_t = uint64_t;
using peer_id_t = boost::uuids::uuid;
using pg_id_t = uint16_t;
using shard_id_t = uint64_t;
using snp_batch_id_t = uint16_t;
using snp_obj_id_t = uint64_t;
using trace_id_t = uint64_t;
using uuid_t = boost::uuids::uuid;
inline uint64_t generateRandomTraceId() {
std::random_device rd;
std::mt19937_64 gen(rd());
std::uniform_int_distribution< uint64_t > dis;
return dis(gen);
}
template < class E >
class Manager {
public:
template < typename T >
using Result = folly::Expected< T, E >;
template < typename T >
using AsyncResult = folly::SemiFuture< Result< T > >;
using NullResult = Result< folly::Unit >;
using NullAsyncResult = AsyncResult< folly::Unit >;
virtual ~Manager() = default;
};
} // namespace homeobject