Working on node.

pull/2612/head
Nicolas "Pixel" Noble 9 years ago
parent 6002a4f67b
commit 8e6bab5e11
  1. 6
      src/node/ext/call.cc
  2. 4
      src/node/ext/channel.cc
  3. 4
      src/node/ext/completion_queue_async_worker.cc
  4. 14
      src/node/ext/server.cc

@ -510,7 +510,7 @@ NAN_METHOD(Call::New) {
grpc_channel *wrapped_channel = channel->GetWrappedChannel(); grpc_channel *wrapped_channel = channel->GetWrappedChannel();
grpc_call *wrapped_call = grpc_channel_create_call( grpc_call *wrapped_call = grpc_channel_create_call(
wrapped_channel, CompletionQueueAsyncWorker::GetQueue(), *method, wrapped_channel, CompletionQueueAsyncWorker::GetQueue(), *method,
channel->GetHost(), MillisecondsToTimespec(deadline)); channel->GetHost(), MillisecondsToTimespec(deadline), NULL);
call = new Call(wrapped_call); call = new Call(wrapped_call);
args.This()->SetHiddenValue(NanNew("channel_"), channel_object); args.This()->SetHiddenValue(NanNew("channel_"), channel_object);
} }
@ -587,7 +587,7 @@ NAN_METHOD(Call::StartBatch) {
NanCallback *callback = new NanCallback(callback_func); NanCallback *callback = new NanCallback(callback_func);
grpc_call_error error = grpc_call_start_batch( grpc_call_error error = grpc_call_start_batch(
call->wrapped_call, &ops[0], nops, new struct tag( call->wrapped_call, &ops[0], nops, new struct tag(
callback, op_vector.release(), resources)); callback, op_vector.release(), resources), NULL);
if (error != GRPC_CALL_OK) { if (error != GRPC_CALL_OK) {
return NanThrowError("startBatch failed", error); return NanThrowError("startBatch failed", error);
} }
@ -601,7 +601,7 @@ NAN_METHOD(Call::Cancel) {
return NanThrowTypeError("cancel can only be called on Call objects"); return NanThrowTypeError("cancel can only be called on Call objects");
} }
Call *call = ObjectWrap::Unwrap<Call>(args.This()); Call *call = ObjectWrap::Unwrap<Call>(args.This());
grpc_call_error error = grpc_call_cancel(call->wrapped_call); grpc_call_error error = grpc_call_cancel(call->wrapped_call, NULL);
if (error != GRPC_CALL_OK) { if (error != GRPC_CALL_OK) {
return NanThrowError("cancel failed", error); return NanThrowError("cancel failed", error);
} }

@ -103,7 +103,7 @@ NAN_METHOD(Channel::New) {
NanUtf8String *host = new NanUtf8String(args[0]); NanUtf8String *host = new NanUtf8String(args[0]);
NanUtf8String *host_override = NULL; NanUtf8String *host_override = NULL;
if (args[1]->IsUndefined()) { if (args[1]->IsUndefined()) {
wrapped_channel = grpc_channel_create(**host, NULL); wrapped_channel = grpc_channel_create(**host, NULL, NULL);
} else if (args[1]->IsObject()) { } else if (args[1]->IsObject()) {
grpc_credentials *creds = NULL; grpc_credentials *creds = NULL;
Handle<Object> args_hash(args[1]->ToObject()->Clone()); Handle<Object> args_hash(args[1]->ToObject()->Clone());
@ -148,7 +148,7 @@ NAN_METHOD(Channel::New) {
} }
} }
if (creds == NULL) { if (creds == NULL) {
wrapped_channel = grpc_channel_create(**host, &channel_args); wrapped_channel = grpc_channel_create(**host, &channel_args, NULL);
} else { } else {
wrapped_channel = wrapped_channel =
grpc_secure_channel_create(creds, **host, &channel_args); grpc_secure_channel_create(creds, **host, &channel_args);

@ -63,7 +63,7 @@ CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {}
void CompletionQueueAsyncWorker::Execute() { void CompletionQueueAsyncWorker::Execute() {
result = result =
grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
if (!result.success) { if (!result.success) {
SetErrorMessage("The batch encountered an error"); SetErrorMessage("The batch encountered an error");
} }
@ -85,7 +85,7 @@ void CompletionQueueAsyncWorker::Init(Handle<Object> exports) {
NanScope(); NanScope();
current_threads = 0; current_threads = 0;
waiting_next_calls = 0; waiting_next_calls = 0;
queue = grpc_completion_queue_create(); queue = grpc_completion_queue_create(NULL);
} }
void CompletionQueueAsyncWorker::HandleOKCallback() { void CompletionQueueAsyncWorker::HandleOKCallback() {

@ -113,8 +113,8 @@ class NewCallOp : public Op {
}; };
Server::Server(grpc_server *server) : wrapped_server(server) { Server::Server(grpc_server *server) : wrapped_server(server) {
shutdown_queue = grpc_completion_queue_create(); shutdown_queue = grpc_completion_queue_create(NULL);
grpc_server_register_completion_queue(server, shutdown_queue); grpc_server_register_completion_queue(server, shutdown_queue, NULL);
} }
Server::~Server() { Server::~Server() {
@ -162,7 +162,7 @@ void Server::ShutdownServer() {
this->shutdown_queue, this->shutdown_queue,
NULL); NULL);
grpc_completion_queue_pluck(this->shutdown_queue, NULL, grpc_completion_queue_pluck(this->shutdown_queue, NULL,
gpr_inf_future(GPR_CLOCK_REALTIME)); gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
this->wrapped_server = NULL; this->wrapped_server = NULL;
} }
} }
@ -180,7 +180,7 @@ NAN_METHOD(Server::New) {
grpc_server *wrapped_server; grpc_server *wrapped_server;
grpc_completion_queue *queue = CompletionQueueAsyncWorker::GetQueue(); grpc_completion_queue *queue = CompletionQueueAsyncWorker::GetQueue();
if (args[0]->IsUndefined()) { if (args[0]->IsUndefined()) {
wrapped_server = grpc_server_create(NULL); wrapped_server = grpc_server_create(NULL, NULL);
} else if (args[0]->IsObject()) { } else if (args[0]->IsObject()) {
Handle<Object> args_hash(args[0]->ToObject()); Handle<Object> args_hash(args[0]->ToObject());
Handle<Array> keys(args_hash->GetOwnPropertyNames()); Handle<Array> keys(args_hash->GetOwnPropertyNames());
@ -209,12 +209,12 @@ NAN_METHOD(Server::New) {
return NanThrowTypeError("Arg values must be strings"); return NanThrowTypeError("Arg values must be strings");
} }
} }
wrapped_server = grpc_server_create(&channel_args); wrapped_server = grpc_server_create(&channel_args, NULL);
free(channel_args.args); free(channel_args.args);
} else { } else {
return NanThrowTypeError("Server expects an object"); return NanThrowTypeError("Server expects an object");
} }
grpc_server_register_completion_queue(wrapped_server, queue); grpc_server_register_completion_queue(wrapped_server, queue, NULL);
Server *server = new Server(wrapped_server); Server *server = new Server(wrapped_server);
server->Wrap(args.This()); server->Wrap(args.This());
NanReturnValue(args.This()); NanReturnValue(args.This());
@ -237,7 +237,7 @@ NAN_METHOD(Server::RequestCall) {
CompletionQueueAsyncWorker::GetQueue(), CompletionQueueAsyncWorker::GetQueue(),
CompletionQueueAsyncWorker::GetQueue(), CompletionQueueAsyncWorker::GetQueue(),
new struct tag(new NanCallback(args[0].As<Function>()), ops.release(), new struct tag(new NanCallback(args[0].As<Function>()), ops.release(),
shared_ptr<Resources>(nullptr))); shared_ptr<Resources>(NULL)));
if (error != GRPC_CALL_OK) { if (error != GRPC_CALL_OK) {
return NanThrowError("requestCall failed", error); return NanThrowError("requestCall failed", error);
} }

Loading…
Cancel
Save