aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/ext
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2015-07-27 10:19:45 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2015-07-27 10:22:33 -0700
commitdb98e085704308bf03b2c68a9183336a3b37b422 (patch)
tree503c9a16ac2ccc9d1a2d17f4eb3d0eb8b5c839f4 /src/php/ext
parent1f21f336ebe032e7dff185d551a3f48c8dcd4b5b (diff)
Exposed channel target and call peer in PHP
Diffstat (limited to 'src/php/ext')
-rw-r--r--src/php/ext/grpc/call.c14
-rw-r--r--src/php/ext/grpc/channel.c14
2 files changed, 26 insertions, 2 deletions
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index b67bae7568..1f76c7359d 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -473,6 +473,16 @@ cleanup:
}
/**
+ * Get the endpoint this call/stream is connected to
+ * @return string The URI of the endpoint
+ */
+PHP_METHOD(Call, getPeer) {
+ wrapped_grpc_call *call =
+ (wrapped_grpc_call *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ RETURN_STRING(grpc_call_get_peer(call->wrapped), 1);
+}
+
+/**
* Cancel the call. This will cause the call to end with STATUS_CANCELLED if it
* has not already ended with another status.
*/
@@ -485,7 +495,9 @@ PHP_METHOD(Call, cancel) {
static zend_function_entry call_methods[] = {
PHP_ME(Call, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Call, startBatch, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Call, cancel, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
+ PHP_ME(Call, getPeer, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Call, cancel, NULL, ZEND_ACC_PUBLIC)
+ PHP_FE_END};
void grpc_init_call(TSRMLS_D) {
zend_class_entry ce;
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index b8262db162..fe69fa5e29 100644
--- a/src/php/ext/grpc/channel.c
+++ b/src/php/ext/grpc/channel.c
@@ -195,6 +195,16 @@ PHP_METHOD(Channel, __construct) {
}
/**
+ * Get the endpoint this call/stream is connected to
+ * @return string The URI of the endpoint
+ */
+PHP_METHOD(Channel, getTarget) {
+ wrapped_grpc_channel *channel =
+ (wrapped_grpc_channel *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ RETURN_STRING(grpc_channel_get_target(channel->wrapped), 1);
+}
+
+/**
* Close the channel
*/
PHP_METHOD(Channel, close) {
@@ -208,7 +218,9 @@ PHP_METHOD(Channel, close) {
static zend_function_entry channel_methods[] = {
PHP_ME(Channel, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
- PHP_ME(Channel, close, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
+ PHP_ME(Channel, getTarget, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Channel, close, NULL, ZEND_ACC_PUBLIC)
+ PHP_FE_END};
void grpc_init_channel(TSRMLS_D) {
zend_class_entry ce;