Commits

Sean Cribbs committed be7e486

Add ping request, restructure some stuff.

Comments (0)

Files changed (3)

 ripple/spec/support/test_server.yml
 Gemfile.lock
 **/bin
+*.o
+*.so
+*.bundle
+Makefile

riak-client/ext/mri/riakpb-ruby.cc

 #include <ruby.h>
-#include "riakpb-ruby.h"
+#include "riakclient.pb.h"
+#include <arpa/inet.h>
+#include <string>
 
 // We're using google's protobufs, so we have to compile in C++. MRI
 // is in C, so we need C calling conventions in our extension
 // functions for it all to hook up.
 extern "C" {
-
+#include "riakpb-ruby.h"
   static VALUE cTCPSocket;
   static VALUE ivar_socket;
   static VALUE eFailedRequest;
     rb_exc_raise(err);
   }
 
+  VALUE rpb_ping(VALUE self){
+    WriteProtobuff(SOCKET, PingReq, NULL);
+    return rpb_decode_response(self);
+  }
+
   VALUE rpb_get_client_id(VALUE self){
     WriteProtobuff(SOCKET, GetClientIdReq, NULL);
     return rpb_decode_response(self);
     cRiakClient = rb_define_class_under(cRiakClient, "Client", rb_cObject);
     mProtobufs = rb_define_module_under(cRiakClient, "Protobufs");
     rb_define_method(mProtobufs, "initialize", RUBY_METHOD_FUNC(rpb_init), 1);
+    rb_define_method(mProtobufs, "ping", RUBY_METHOD_FUNC(rpb_ping), 0);
     rb_define_method(mProtobufs, "get_client_id", RUBY_METHOD_FUNC(rpb_get_client_id), 0);
     rb_alias(mProtobufs, rb_intern("client_id"), rb_intern("get_client_id"));
     rb_define_method(mProtobufs, "set_client_id", RUBY_METHOD_FUNC(rpb_set_client_id), 1);

riak-client/ext/mri/riakpb-ruby.h

-#include <arpa/inet.h>
-#include "riakclient.pb.h"
-#include <string>
 
 enum RpbMessageCodes {
-  ErrorResp,
-  PingReq,
-  PingResp,
-  GetClientIdReq,
-  GetClientIdResp,
-  SetClientIdReq,
-  SetClientIdResp,
-  GetServerInfoReq,
-  GetServerInfoResp,
+  ErrorResp,            //
+  PingReq,              //
+  PingResp,             //
+  GetClientIdReq,       //
+  GetClientIdResp,      //
+  SetClientIdReq,       //
+  SetClientIdResp,      //
+  GetServerInfoReq,     //
+  GetServerInfoResp,    //
   GetReq,
   GetResp,
   PutReq,
   PutResp,
-  DelReq,
-  DelResp,
-  ListBucketsReq,
-  ListBucketsResp,
-  ListKeysReq,
-  ListKeysResp,
-  GetBucketReq,
-  GetBucketResp,
-  SetBucketReq,
-  SetBucketResp,
+  DelReq,               //
+  DelResp,              //
+  ListBucketsReq,       //
+  ListBucketsResp,      //
+  ListKeysReq,          //
+  ListKeysResp,         //
+  GetBucketReq,         //
+  GetBucketResp,        //
+  SetBucketReq,         //
+  SetBucketResp,        //
   MapRedReq,
   MapRedResp
 };
 }
 
 #define SOCKET rb_ivar_get(self, ivar_socket)
+extern "C" {
+  VALUE rpb_decode_error(VALUE);
 
-extern "C" {
-
-  VALUE rpb_decode_error(VALUE);
+  VALUE rpb_ping(VALUE);
 
   VALUE rbp_get_client_id(VALUE);
   VALUE rpb_decode_get_client_id(VALUE);
 
   VALUE rpb_decode_response(VALUE);
   VALUE rpb_init(VALUE, VALUE);
+
 }