File tree 2 files changed +9
-19
lines changed
2 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ using TransportReportFunc = std::function<void(
40
40
const ::istio::mixer::v1::ReportRequest& request,
41
41
::istio::mixer::v1::ReportResponse* response, DoneFunc on_done)>;
42
42
43
+ // Defines a function prototype to generate an UUID
44
+ using UUIDGenerateFunc = std::function<std::string()>;
45
+
43
46
// Defines the options to create an instance of MixerClient interface.
44
47
struct MixerClientOptions {
45
48
// Default constructor with default values.
@@ -69,6 +72,9 @@ struct MixerClientOptions {
69
72
// Don't call it at program start, or init time, it is not ready.
70
73
// It is safe to call during Check() or Report() calls.
71
74
TimerCreateFunc timer_create_func;
75
+
76
+ // UUID generating function
77
+ UUIDGenerateFunc uuid_generate_func;
72
78
};
73
79
74
80
class MixerClient {
Original file line number Diff line number Diff line change 15
15
#include " src/client_impl.h"
16
16
#include " utils/protobuf.h"
17
17
18
- #include < uuid/uuid.h>
19
-
20
- using namespace std ::chrono;
21
18
using ::istio::mixer::v1::CheckRequest;
22
19
using ::istio::mixer::v1::CheckResponse;
23
20
using ::istio::mixer::v1::ReportRequest;
@@ -27,21 +24,6 @@ using ::google::protobuf::util::error::Code;
27
24
28
25
namespace istio {
29
26
namespace mixer_client {
30
- namespace {
31
-
32
- // Maximum 36 byte string for UUID
33
- const int kMaxUUIDBufSize = 40 ;
34
-
35
- // Genereates a UUID string
36
- std::string GenerateUUID () {
37
- char uuid_buf[kMaxUUIDBufSize ];
38
- uuid_t uuid;
39
- uuid_generate (uuid);
40
- uuid_unparse (uuid, uuid_buf);
41
- return uuid_buf;
42
- }
43
-
44
- } // namespace
45
27
46
28
MixerClientImpl::MixerClientImpl (const MixerClientOptions &options)
47
29
: options_(options) {
@@ -53,7 +35,9 @@ MixerClientImpl::MixerClientImpl(const MixerClientOptions &options)
53
35
quota_cache_ =
54
36
std::unique_ptr<QuotaCache>(new QuotaCache (options.quota_options ));
55
37
56
- deduplication_id_base_ = GenerateUUID ();
38
+ if (options_.uuid_generate_func ) {
39
+ deduplication_id_base_ = options_.uuid_generate_func ();
40
+ }
57
41
}
58
42
59
43
MixerClientImpl::~MixerClientImpl () {}
You can’t perform that action at this time.
0 commit comments