morganstanley / modern-cpp-kafka

A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
Apache License 2.0
348 stars 88 forks source link

inconsistent parameter of mdLifetime #234

Open leiwang008 opened 3 months ago

leiwang008 commented 3 months ago

In the file KafkaClient.h at line https://github.com/morganstanley/modern-cpp-kafka/blob/a146d10bcf166f55299c7a55728abaaea52cb0e5/include/kafka/KafkaClient.h#L590, we are calling the function rd_kafka_oauthbearer_set_token of rdkafa library https://github.com/confluentinc/librdkafka/blob/0e3128c69a2faec988850da8e78ea077a3fc3019/src/rdkafka.h#L9899

the md_lifetime_ms is in millisecond, but the parameter SaslOauthbearerToken we pass in is microseconds, it is in https://github.com/morganstanley/modern-cpp-kafka/blob/a146d10bcf166f55299c7a55728abaaea52cb0e5/include/kafka/ClientCommon.h#L35

We should probably change mdLifetime's type to std::chrono::milliseconds as below

struct SaslOauthbearerToken
    {
        using KeyValuePairs = std::map<std::string, std::string>;

        std::string               value;
        std::chrono::milliseconds mdLifetime{};
        std::string               mdPrincipalName;
        KeyValuePairs             extensions;
    };