From 4a1474f12f106123462cfcaf92c3c2e22a0b1404 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 17 Aug 2015 14:00:31 -0700 Subject: [PATCH] Moved write flag constants to base module --- src/node/ext/call.cc | 4 ---- src/node/ext/node_grpc.cc | 11 +++++++++++ src/node/index.js | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index 3256f41dc7a..a720f9eed65 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -464,10 +464,6 @@ void Call::Init(Handle exports) { NanNew(GetPeer)->GetFunction()); NanAssignPersistent(fun_tpl, tpl); Handle ctr = tpl->GetFunction(); - ctr->Set(NanNew("WRITE_BUFFER_HINT"), - NanNew(GRPC_WRITE_BUFFER_HINT)); - ctr->Set(NanNew("WRITE_NO_COMPRESS"), - NanNew(GRPC_WRITE_NO_COMPRESS)); exports->Set(NanNew("Call"), ctr); constructor = new NanCallback(ctr); } diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc index d93dafda79f..0cf30da9228 100644 --- a/src/node/ext/node_grpc.cc +++ b/src/node/ext/node_grpc.cc @@ -196,6 +196,16 @@ void InitConnectivityStateConstants(Handle exports) { channel_state->Set(NanNew("FATAL_FAILURE"), FATAL_FAILURE); } +void InitWriteFlags(Handle exports) { + NanScope(); + Handle write_flags = NanNew(); + exports->Set(NanNew("writeFlags"), write_flags); + Handle BUFFER_HINT(NanNew(GRPC_WRITE_BUFFER_HINT)); + write_flags->Set(NanNew("BUFFER_HINT"), BUFFER_HINT); + Handle NO_COMPRESS(NanNew(GRPC_WRITE_NO_COMPRESS)); + write_flags->Set(NanNew("NO_COMPRESS"), NO_COMPRESS); +} + void init(Handle exports) { NanScope(); grpc_init(); @@ -204,6 +214,7 @@ void init(Handle exports) { InitOpTypeConstants(exports); InitPropagateConstants(exports); InitConnectivityStateConstants(exports); + InitWriteFlags(exports); grpc::node::Call::Init(exports); grpc::node::Channel::Init(exports); diff --git a/src/node/index.js b/src/node/index.js index 93c65ac5c43..889b0ac0e92 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -144,6 +144,11 @@ exports.propagate = grpc.propagate; */ exports.callError = grpc.callError; +/** + * Write flag name to code number mapping + */ +exports.writeFlags = grpc.writeFlags; + /** * Credentials factories */