Commit 3b2e4e16 authored by Manuel Wudka-Robles's avatar Manuel Wudka-Robles
Browse files

Removed legacy async example

parent 7c166ea4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ macro(add_example_target NAME)
endmacro(add_example_target)

add_example_target(kineticstat)
#add_example_target(async)
add_example_target(ise)
add_example_target(setclusterversion)
#add_example_target(setpin)

src/async.cc

deleted100644 → 0
+0 −62
Original line number Diff line number Diff line
// This is shows a minimal example of issuing an async request and processing the result

#include <fcntl.h>
#include <sys/select.h>

#include "kinetic/kinetic_connection_factory.h"
#include "socket_wrapper.h"
#include "value_factory.h"

using com::seagate::kinetic::HmacProvider;
using com::seagate::kinetic::ValueFactory;
using kinetic::ConnectionOptions;
using kinetic::GetCallbackInterface;
using kinetic::Message;
using kinetic::NonblockingKineticConnection;
using kinetic::NonblockingError;
using palominolabs::protobufutil::MessageStreamFactory;

class TestCallback : public GetCallbackInterface {
    public:
    void Success(const std::string &key, const std::string &value,
            const std::string &version, const std::string &tag) {
        printf("The callback got called!\n");
    }
    virtual void Failure(NonblockingError error) {
        printf("Error!\n");
        exit(1);
    }
};

int main(int argc, char* argv[]) {
    ConnectionOptions options = {
        .host = "localhost",
        .port = 8123,
        .use_ssl = false,
        .user_id = 1,
        .hmac_key = "asdfasdf"
    };

    HmacProvider hmac_provider;
    ValueFactory value_factory;
    MessageStreamFactory message_stream_factory(NULL, value_factory);
    kinetic::KineticConnectionFactory kinetic_connection_factory = kinetic::NewKineticConnectionFactory();

    kinetic::NonblockingKineticConnection *connection;
    if(!kinetic_connection_factory.NewNonblockingConnection(options, &connection).ok()) {
        printf("Unable to connect");
        return 1;
    }

    TestCallback *callback = new TestCallback;
    connection->Get("key", callback);

    fd_set read_fds, write_fds;
    int num_fds = 0;
    connection->Run(&read_fds, &write_fds, &num_fds);
    connection->Run(&read_fds, &write_fds, &num_fds);

    delete callback;
    delete connection;
    return 0;
}