Skip to content

Commit

Permalink
re #26 -- Update manual use-case examples to the latest riak::client …
Browse files Browse the repository at this point in the history
…interface.
  • Loading branch information
ajtack committed Nov 17, 2014
1 parent b36c77b commit 4c73d57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
21 changes: 12 additions & 9 deletions test/use-cases/fetch-and-store.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include <boost/format.hpp>
#include <functional>
#include <riak/client.hxx>
#include <riak/transports/single_serial_socket.hxx>
#include <riak/transports/single_serial_socket/delivery_provider.hxx>
#include <riak/utility/boost_deadline_timer_factory.hxx>
#include <test/tools/use-case-control.hxx>

using namespace boost;
Expand All @@ -23,8 +24,8 @@ void handle_put_result (const std::error_code& error)
void print_object_value (
const std::string& new_value,
const std::error_code& error,
std::shared_ptr<riak::object> object,
riak::value_updater& update_value)
std::shared_ptr<riak::object>& object,
riak::value_updater update_value)
{
if (not error) {
if (!! object)
Expand All @@ -50,14 +51,16 @@ int main (int argc, const char* argv[])
boost::asio::io_service ios;

announce_with_pause("Connecting!");
auto connection = riak::make_single_socket_transport("localhost", 8082, ios);
auto my_store = riak::make_client(connection, &no_sibling_resolution, ios);
auto connection = riak::transport::make_single_socket_transport("localhost", 8082, ios);
auto timer_factory = std::make_shared<riak::utility::boost_deadline_timer_factory>(ios);
riak::client my_store(std::move(connection), &no_sibling_resolution, timer_factory);

announce_with_pause("Ready to fetch item test/doc...");
if (argc > 1)
my_store->get_object("test", "doc", std::bind(&print_object_value, argv[1], _1, _2, _3));
else
my_store->get_object("test", "doc", std::bind(&print_object_value, "Some nonsense!", _1, _2, _3));
if (argc > 1) {
my_store.get_object("test", "doc", std::bind(&print_object_value, argv[1], _1, _2, _3));
} else {
my_store.get_object("test", "doc", std::bind(&print_object_value, "Some nonsense", _1, _2, _3));
}

ios.run();
return 0;
Expand Down
10 changes: 6 additions & 4 deletions test/use-cases/simple-deletion.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include <boost/format.hpp>
#include <functional>
#include <riak/client.hxx>
#include <riak/transports/single_serial_socket.hxx>
#include <riak/transports/single_serial_socket/delivery_provider.hxx>
#include <riak/utility/boost_deadline_timer_factory.hxx>
#include <test/tools/use-case-control.hxx>

using namespace boost;
Expand All @@ -25,11 +26,12 @@ int main (int argc, const char* argv[])
boost::asio::io_service ios;

announce_with_pause("Connecting!");
auto connection = riak::make_single_socket_transport("localhost", 8082, ios);
auto my_store = riak::make_client(connection, &no_sibling_resolution, ios);
auto connection = riak::transport::make_single_socket_transport("localhost", 8082, ios);
auto timer_factory = std::make_shared<riak::utility::boost_deadline_timer_factory>(ios);
riak::client my_store(std::move(connection), &no_sibling_resolution, timer_factory);

announce_with_pause("Ready to delete item test/doc");
my_store->delete_object("test", "doc", std::bind(&handle_deletion_result, _1));
my_store.delete_object("test", "doc", std::bind(&handle_deletion_result, _1));
ios.run();
return 0;
}
Expand Down
12 changes: 7 additions & 5 deletions test/use-cases/simple-fetch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include <boost/format.hpp>
#include <functional>
#include <riak/client.hxx>
#include <riak/transports/single_serial_socket.hxx>
#include <riak/transports/single_serial_socket/delivery_provider.hxx>
#include <riak/utility/boost_deadline_timer_factory.hxx>
#include <test/tools/use-case-control.hxx>

using namespace boost;
Expand All @@ -11,7 +12,7 @@ using namespace std::placeholders;

std::shared_ptr<riak::object> no_sibling_resolution (const ::riak::siblings&);

void print_object_value (const std::error_code& error, std::shared_ptr<riak::object> object, riak::value_updater&)
void print_object_value (const std::error_code& error, std::shared_ptr<riak::object> object, riak::value_updater)
{
if (not error) {
if (!! object)
Expand All @@ -29,11 +30,12 @@ int main (int argc, const char* argv[])
boost::asio::io_service ios;

announce_with_pause("Connecting!");
auto connection = riak::make_single_socket_transport("localhost", 8082, ios);
auto my_store = riak::make_client(connection, &no_sibling_resolution, ios);
auto connection = riak::transport::make_single_socket_transport("localhost", 8082, ios);
auto timer_factory = std::make_shared<riak::utility::boost_deadline_timer_factory>(ios);
riak::client my_store(std::move(connection), &no_sibling_resolution, timer_factory);

announce_with_pause("Ready to fetch item test/doc");
my_store->get_object("test", "doc", std::bind(&print_object_value, _1, _2, _3));
my_store.get_object("test", "doc", std::bind(&print_object_value, _1, _2, _3));
ios.run();
return 0;
}
Expand Down

0 comments on commit 4c73d57

Please sign in to comment.