Skip to content

Expose LATENCY RESET to python client #127

Open
@ctandon11

Description

@ctandon11

Description

Give the python client access to the Redis command LATENCY RESET by exposing it through the Pybindings.

Justification

Users will be able to reset the latency spike times series of all, or only some events.

Implementation Strategy

LATENCY RESET will need two implementations, one with no arguments that will reset all the events and one with an argument (the event to reset) that will only reset that event. It will be an AddressAtCommand.

The implementation for the no argument case will look something like this in client.cpp (Note the argument case will be the same except it will add the event argument as a field):

unit64_t Client::latency_reset(std::string address)
{
    std::string host = address.substr(0, address.find(":"));
    uint64_t port = std::stoul(address.substr(address.find(":") + 1),
                                nullptr, 0);
    if (host.empty() or port == 0){
        throw std::runtime_error(std::string(address) +
                                 "is not a valid database node address.");
    }
    AddressAtCommand cmd;
    cmd.set_exec_address_port(host, port);

    cmd.add_field("LATENCY");
    cmd.add_field("RESETSTAT");

    CommandReply reply = _run(cmd);
    if (reply.has_error() > 0)
        throw std::runtime_error("LATENCY RESET command failed");

    return reply.integer();
}

This functionality then needs to be exposed through the Pybindings and pyclient.cpp file to the python client layer. For testing, call LATENCY RESET then LATENCY LATEST and ensure that the appropriate event(s) are reset. For unit testing, make sure an invalid address throws an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: pythonIssues related to the Python Clienttype: featureIssues that include feature request or feature idea

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions