aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2015-08-27 09:41:59 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2015-09-02 13:34:40 -0700
commit5331776c17f775911fedcadfcb530bd46af024ea (patch)
treef340726941cdc640d3a051189163888f2618d12b /src/php/lib
parent3ab8e79b0111dc93696d72e815531b5ee3124230 (diff)
php: clean up api around flags
Diffstat (limited to 'src/php/lib')
-rw-r--r--src/php/lib/Grpc/AbstractCall.php16
-rw-r--r--src/php/lib/Grpc/BidiStreamingCall.php7
-rw-r--r--src/php/lib/Grpc/ClientStreamingCall.php7
-rw-r--r--src/php/lib/Grpc/ServerStreamingCall.php7
-rw-r--r--src/php/lib/Grpc/UnaryCall.php7
5 files changed, 16 insertions, 28 deletions
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php
index 3fdaf2e487..a3c7a9e017 100644
--- a/src/php/lib/Grpc/AbstractCall.php
+++ b/src/php/lib/Grpc/AbstractCall.php
@@ -92,20 +92,4 @@ abstract class AbstractCall {
}
return call_user_func($this->deserialize, $value);
}
-
- /**
- * Get the list of Grpc Write Flags
- * @param array $options an array of options
- * @return The list of Grpc Write Flags contained in the input
- */
- protected static function getGrpcWriteFlags($options) {
- $grpc_write_flags = [];
- foreach ([WRITE_BUFFER_HINT,
- WRITE_NO_COMPRESS] as $flag) {
- if (in_array($flag, $options)) {
- $grpc_write_flags[] = $flag;
- }
- }
- return $grpc_write_flags;
- }
}
diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php
index 80b7a66a76..2b19f031ec 100644
--- a/src/php/lib/Grpc/BidiStreamingCall.php
+++ b/src/php/lib/Grpc/BidiStreamingCall.php
@@ -66,12 +66,13 @@ class BidiStreamingCall extends AbstractCall {
* Write a single message to the server. This cannot be called after
* writesDone is called.
* @param ByteBuffer $data The data to write
- * @param array $options an array of options
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
public function write($data, $options = array()) {
$message_array = ['message' => $data->serialize()];
- if ($grpc_write_flags = self::getGrpcWriteFlags($options)) {
- $message_array['flags'] = $grpc_write_flags;
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
}
$this->call->startBatch([OP_SEND_MESSAGE => $message_array]);
}
diff --git a/src/php/lib/Grpc/ClientStreamingCall.php b/src/php/lib/Grpc/ClientStreamingCall.php
index 97c241a087..29b9185411 100644
--- a/src/php/lib/Grpc/ClientStreamingCall.php
+++ b/src/php/lib/Grpc/ClientStreamingCall.php
@@ -50,12 +50,13 @@ class ClientStreamingCall extends AbstractCall {
* Write a single message to the server. This cannot be called after
* wait is called.
* @param ByteBuffer $data The data to write
- * @param array $options an array of options
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
public function write($data, $options = array()) {
$message_array = ['message' => $data->serialize()];
- if ($grpc_write_flags = self::getGrpcWriteFlags($options)) {
- $message_array['flags'] = $grpc_write_flags;
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
}
$this->call->startBatch([OP_SEND_MESSAGE => $message_array]);
}
diff --git a/src/php/lib/Grpc/ServerStreamingCall.php b/src/php/lib/Grpc/ServerStreamingCall.php
index 159561b43a..a93c1a5d5e 100644
--- a/src/php/lib/Grpc/ServerStreamingCall.php
+++ b/src/php/lib/Grpc/ServerStreamingCall.php
@@ -42,12 +42,13 @@ class ServerStreamingCall extends AbstractCall {
* Start the call
* @param $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
- * @param array $options an array of options
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
public function start($data, $metadata = array(), $options = array()) {
$message_array = ['message' => $data->serialize()];
- if ($grpc_write_flags = self::getGrpcWriteFlags($options)) {
- $message_array['flags'] = $grpc_write_flags;
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
}
$event = $this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata,
diff --git a/src/php/lib/Grpc/UnaryCall.php b/src/php/lib/Grpc/UnaryCall.php
index 5ca7d9ed65..38af6b1d74 100644
--- a/src/php/lib/Grpc/UnaryCall.php
+++ b/src/php/lib/Grpc/UnaryCall.php
@@ -42,12 +42,13 @@ class UnaryCall extends AbstractCall {
* Start the call
* @param $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
- * @param array $options an array of options
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
public function start($data, $metadata = array(), $options = array()) {
$message_array = ['message' => $data->serialize()];
- if ($grpc_write_flags = self::getGrpcWriteFlags($options)) {
- $message_array['flags'] = $grpc_write_flags;
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
}
$event = $this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata,