diff --git a/mixerclient/include/client.h b/mixerclient/include/client.h index 52e40e84d22d..6963eba949e2 100644 --- a/mixerclient/include/client.h +++ b/mixerclient/include/client.h @@ -16,6 +16,7 @@ #ifndef MIXERCLIENT_CLIENT_H #define MIXERCLIENT_CLIENT_H +#include #include #include #include @@ -58,11 +59,42 @@ struct MixerClientOptions { TransportInterface* transport; }; +struct Attributes { + // A structure to hold different types of value. + struct Value { + // Data type + enum ValueType { STRING, INT64, DOUBLE, BOOL, TIME, BYTES } type; + + // Data value + union { + std::string str_v; // for both STRING and BYTES + int64_t int64_v; + double double_v; + bool bool_v; + std::chrono::time_point time_v; + } value; + }; + + std::map attributes; +}; + class MixerClient { public: // Destructor virtual ~MixerClient() {} + // Attribute based calls will be used. + // The protobuf message based calls will be removed. + // Callers should pass in the full set of attributes for the call. + // The client will use the full set attributes to check cache. If cache + // miss, an attribute context based on the underline gRPC stream will + // be used to generate attribute_update and send that to Mixer server. + // Callers don't need response data, they only need success or failure. + // The response data from mixer will be consumed by mixer client. + virtual void Check(const Attributes& attributes, DoneFunc on_done) = 0; + virtual void Report(const Attributes& attributes, DoneFunc on_done) = 0; + virtual void Quota(const Attributes& attributes, DoneFunc on_done) = 0; + // The async call. // on_check_done is called with the check status after cached // check_response is returned in case of cache hit, otherwise called after diff --git a/mixerclient/src/client_impl.cc b/mixerclient/src/client_impl.cc index 38f20ba0e879..14f40c723822 100644 --- a/mixerclient/src/client_impl.cc +++ b/mixerclient/src/client_impl.cc @@ -36,6 +36,18 @@ MixerClientImpl::MixerClientImpl(const MixerClientOptions &options) MixerClientImpl::~MixerClientImpl() {} +void MixerClientImpl::Check(const Attributes &attributes, DoneFunc on_done) { + on_done(Status(Code::UNIMPLEMENTED, "Method not implemented.")); +} + +void MixerClientImpl::Report(const Attributes &attributes, DoneFunc on_done) { + on_done(Status(Code::UNIMPLEMENTED, "Method not implemented.")); +} + +void MixerClientImpl::Quota(const Attributes &attributes, DoneFunc on_done) { + on_done(Status(Code::UNIMPLEMENTED, "Method not implemented.")); +} + void MixerClientImpl::Check(const CheckRequest &request, CheckResponse *response, DoneFunc on_done) { check_transport_.Call(request, response, on_done); diff --git a/mixerclient/src/client_impl.h b/mixerclient/src/client_impl.h index c447f056e397..de2d76ab50ee 100644 --- a/mixerclient/src/client_impl.h +++ b/mixerclient/src/client_impl.h @@ -30,6 +30,10 @@ class MixerClientImpl : public MixerClient { // Destructor virtual ~MixerClientImpl(); + virtual void Check(const Attributes& attributes, DoneFunc on_done); + virtual void Report(const Attributes& attributes, DoneFunc on_done); + virtual void Quota(const Attributes& attributes, DoneFunc on_done); + // The async call. // on_check_done is called with the check status after cached // check_response is returned in case of cache hit, otherwise called after