Craig Tiller | 1a61b17 | 2015-02-16 11:53:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Craig Tiller | 1a61b17 | 2015-02-16 11:53:47 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Craig Tiller | 1a61b17 | 2015-02-16 11:53:47 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | 1a61b17 | 2015-02-16 11:53:47 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Craig Tiller | 1a61b17 | 2015-02-16 11:53:47 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 19 | #include "channel.h" |
| 20 | |
| 21 | #ifdef HAVE_CONFIG_H |
| 22 | #include "config.h" |
| 23 | #endif |
| 24 | |
murgatroid99 | 8242ba7 | 2015-04-01 15:29:44 -0700 | [diff] [blame] | 25 | #include <php.h> |
| 26 | #include <php_ini.h> |
| 27 | #include <ext/standard/info.h> |
| 28 | #include <ext/spl/spl_exceptions.h> |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 29 | #include "php_grpc.h" |
| 30 | |
murgatroid99 | 8242ba7 | 2015-04-01 15:29:44 -0700 | [diff] [blame] | 31 | #include <zend_exceptions.h> |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 32 | |
| 33 | #include <stdbool.h> |
| 34 | |
murgatroid99 | 8242ba7 | 2015-04-01 15:29:44 -0700 | [diff] [blame] | 35 | #include <grpc/grpc.h> |
murgatroid99 | 8242ba7 | 2015-04-01 15:29:44 -0700 | [diff] [blame] | 36 | #include <grpc/grpc_security.h> |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 37 | |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 38 | #include "completion_queue.h" |
Stanley Cheung | 9c0b35e | 2015-10-21 17:07:56 -0700 | [diff] [blame] | 39 | #include "channel_credentials.h" |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 40 | #include "server.h" |
| 41 | #include "timeval.h" |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 42 | |
Xiaoguang Sun | 8a929a9 | 2015-03-13 14:22:31 +0800 | [diff] [blame] | 43 | zend_class_entry *grpc_ce_channel; |
thinkerou | dba5b0c | 2016-07-27 18:39:16 +0800 | [diff] [blame] | 44 | #if PHP_MAJOR_VERSION >= 7 |
| 45 | static zend_object_handlers channel_ce_handlers; |
| 46 | #endif |
Xiaoguang Sun | 8a929a9 | 2015-03-13 14:22:31 +0800 | [diff] [blame] | 47 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 48 | /* Frees and destroys an instance of wrapped_grpc_channel */ |
thinkerou | 011d1ef | 2016-07-27 09:44:49 +0800 | [diff] [blame] | 49 | PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_channel) |
| 50 | if (p->wrapped != NULL) { |
| 51 | grpc_channel_destroy(p->wrapped); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 52 | } |
thinkerou | 011d1ef | 2016-07-27 09:44:49 +0800 | [diff] [blame] | 53 | PHP_GRPC_FREE_WRAPPED_FUNC_END() |
| 54 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 55 | /* Initializes an instance of wrapped_grpc_channel to be associated with an |
| 56 | * object of a class specified by class_type */ |
thinkerou | dba5b0c | 2016-07-27 18:39:16 +0800 | [diff] [blame] | 57 | php_grpc_zend_object create_wrapped_grpc_channel(zend_class_entry *class_type |
| 58 | TSRMLS_DC) { |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 59 | PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_channel); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 60 | zend_object_std_init(&intern->std, class_type TSRMLS_CC); |
| 61 | object_properties_init(&intern->std, class_type); |
thinkerou | dc673c5 | 2016-07-28 09:49:38 +0800 | [diff] [blame] | 62 | PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_channel, channel_ce_handlers); |
thinkerou | dba5b0c | 2016-07-27 18:39:16 +0800 | [diff] [blame] | 63 | } |
thinkerou | 6f9d30b | 2016-07-27 03:19:03 +0800 | [diff] [blame] | 64 | |
Stanley Cheung | bae0cf1 | 2016-07-20 14:02:33 -0700 | [diff] [blame] | 65 | void php_grpc_read_args_array(zval *args_array, |
| 66 | grpc_channel_args *args TSRMLS_DC) { |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 67 | HashTable *array_hash; |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 68 | int args_index; |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 69 | array_hash = Z_ARRVAL_P(args_array); |
thinkerou | 6f9d30b | 2016-07-27 03:19:03 +0800 | [diff] [blame] | 70 | if (!array_hash) { |
| 71 | zend_throw_exception(spl_ce_InvalidArgumentException, |
Stanley Cheung | c1f25fb | 2016-07-29 13:41:22 -0700 | [diff] [blame] | 72 | "array_hash is NULL", 1 TSRMLS_CC); |
thinkerou | 6f9d30b | 2016-07-27 03:19:03 +0800 | [diff] [blame] | 73 | return; |
| 74 | } |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 75 | args->num_args = zend_hash_num_elements(array_hash); |
| 76 | args->args = ecalloc(args->num_args, sizeof(grpc_arg)); |
| 77 | args_index = 0; |
thinkerou | 6f9d30b | 2016-07-27 03:19:03 +0800 | [diff] [blame] | 78 | |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 79 | char *key = NULL; |
| 80 | zval *data; |
| 81 | int key_type; |
| 82 | |
| 83 | PHP_GRPC_HASH_FOREACH_STR_KEY_VAL_START(array_hash, key, key_type, data) |
| 84 | if (key_type != HASH_KEY_IS_STRING) { |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 85 | zend_throw_exception(spl_ce_InvalidArgumentException, |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 86 | "args keys must be strings", 1 TSRMLS_CC); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 87 | return; |
| 88 | } |
| 89 | args->args[args_index].key = key; |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 90 | switch (Z_TYPE_P(data)) { |
| 91 | case IS_LONG: |
| 92 | args->args[args_index].value.integer = (int)Z_LVAL_P(data); |
| 93 | args->args[args_index].type = GRPC_ARG_INTEGER; |
| 94 | break; |
| 95 | case IS_STRING: |
| 96 | args->args[args_index].value.string = Z_STRVAL_P(data); |
| 97 | args->args[args_index].type = GRPC_ARG_STRING; |
| 98 | break; |
| 99 | default: |
| 100 | zend_throw_exception(spl_ce_InvalidArgumentException, |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 101 | "args values must be int or string", 1 TSRMLS_CC); |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 102 | return; |
| 103 | } |
| 104 | args_index++; |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 105 | PHP_GRPC_HASH_FOREACH_END() |
thinkerou | 6f9d30b | 2016-07-27 03:19:03 +0800 | [diff] [blame] | 106 | } |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 107 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 108 | /** |
| 109 | * Construct an instance of the Channel class. If the $args array contains a |
Stanley Cheung | 9c0b35e | 2015-10-21 17:07:56 -0700 | [diff] [blame] | 110 | * "credentials" key mapping to a ChannelCredentials object, a secure channel |
| 111 | * will be created with those credentials. |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 112 | * @param string $target The hostname to associate with this channel |
thinkerou | efbc9e7 | 2016-08-16 20:00:36 +0800 | [diff] [blame] | 113 | * @param array $args_array The arguments to pass to the Channel |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 114 | */ |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 115 | PHP_METHOD(Channel, __construct) { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 116 | wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); |
| 117 | zval *creds_obj = NULL; |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 118 | char *target; |
thinkerou | 1930468 | 2016-07-22 02:43:19 +0800 | [diff] [blame] | 119 | php_grpc_int target_length; |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 120 | zval *args_array = NULL; |
| 121 | grpc_channel_args args; |
| 122 | HashTable *array_hash; |
Stanley Cheung | aeea102 | 2015-10-21 17:00:49 -0700 | [diff] [blame] | 123 | wrapped_grpc_channel_credentials *creds = NULL; |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 124 | |
Stanley Cheung | f77a4ad | 2016-02-16 09:45:51 -0800 | [diff] [blame] | 125 | /* "sa" == 1 string, 1 array */ |
| 126 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa", &target, |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 127 | &target_length, &args_array) == FAILURE) { |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 128 | zend_throw_exception(spl_ce_InvalidArgumentException, |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 129 | "Channel expects a string and an array", 1 TSRMLS_CC); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 130 | return; |
| 131 | } |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 132 | array_hash = Z_ARRVAL_P(args_array); |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 133 | if (php_grpc_zend_hash_find(array_hash, "credentials", sizeof("credentials"), |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 134 | (void **)&creds_obj) == SUCCESS) { |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 135 | if (Z_TYPE_P(creds_obj) == IS_NULL) { |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 136 | creds = NULL; |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 137 | php_grpc_zend_hash_del(array_hash, "credentials", sizeof("credentials")); |
| 138 | } else if (PHP_GRPC_GET_CLASS_ENTRY(creds_obj) != |
| 139 | grpc_ce_channel_credentials) { |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 140 | zend_throw_exception(spl_ce_InvalidArgumentException, |
| 141 | "credentials must be a ChannelCredentials object", |
| 142 | 1 TSRMLS_CC); |
| 143 | return; |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 144 | } else { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 145 | creds = Z_WRAPPED_GRPC_CHANNEL_CREDS_P(creds_obj); |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 146 | php_grpc_zend_hash_del(array_hash, "credentials", sizeof("credentials")); |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 147 | } |
| 148 | } |
Michael Bausor | 4f8e40b | 2016-05-16 11:41:25 -0700 | [diff] [blame] | 149 | php_grpc_read_args_array(args_array, &args TSRMLS_CC); |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 150 | if (creds == NULL) { |
| 151 | channel->wrapped = grpc_insecure_channel_create(target, &args, NULL); |
| 152 | } else { |
Stanley Cheung | cccf929 | 2016-02-12 16:37:19 -0800 | [diff] [blame] | 153 | channel->wrapped = |
| 154 | grpc_secure_channel_create(creds->wrapped, target, &args, NULL); |
| 155 | } |
| 156 | efree(args.args); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /** |
Stanley Cheung | db98e08 | 2015-07-27 10:19:45 -0700 | [diff] [blame] | 160 | * Get the endpoint this call/stream is connected to |
| 161 | * @return string The URI of the endpoint |
| 162 | */ |
| 163 | PHP_METHOD(Channel, getTarget) { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 164 | wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); |
thinkerou | 1930468 | 2016-07-22 02:43:19 +0800 | [diff] [blame] | 165 | PHP_GRPC_RETURN_STRING(grpc_channel_get_target(channel->wrapped), 1); |
Stanley Cheung | db98e08 | 2015-07-27 10:19:45 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /** |
Stanley Cheung | e63354a | 2015-08-10 15:46:42 -0700 | [diff] [blame] | 169 | * Get the connectivity state of the channel |
thinkerou | efbc9e7 | 2016-08-16 20:00:36 +0800 | [diff] [blame] | 170 | * @param bool $try_to_connect Try to connect on the channel (optional) |
Stanley Cheung | e63354a | 2015-08-10 15:46:42 -0700 | [diff] [blame] | 171 | * @return long The grpc connectivity state |
| 172 | */ |
| 173 | PHP_METHOD(Channel, getConnectivityState) { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 174 | wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 175 | bool try_to_connect = false; |
| 176 | |
Stanley Cheung | e63354a | 2015-08-10 15:46:42 -0700 | [diff] [blame] | 177 | /* "|b" == 1 optional bool */ |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 178 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &try_to_connect) |
| 179 | == FAILURE) { |
Stanley Cheung | e63354a | 2015-08-10 15:46:42 -0700 | [diff] [blame] | 180 | zend_throw_exception(spl_ce_InvalidArgumentException, |
| 181 | "getConnectivityState expects a bool", 1 TSRMLS_CC); |
| 182 | return; |
| 183 | } |
| 184 | RETURN_LONG(grpc_channel_check_connectivity_state(channel->wrapped, |
| 185 | (int)try_to_connect)); |
| 186 | } |
| 187 | |
| 188 | /** |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 189 | * Watch the connectivity state of the channel until it changed |
thinkerou | efbc9e7 | 2016-08-16 20:00:36 +0800 | [diff] [blame] | 190 | * @param long $last_state The previous connectivity state of the channel |
| 191 | * @param Timeval $deadline_obj The deadline this function should wait until |
Stanley Cheung | 4c5c7b8 | 2015-08-12 16:28:58 -0700 | [diff] [blame] | 192 | * @return bool If the connectivity state changes from last_state |
| 193 | * before deadline |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 194 | */ |
| 195 | PHP_METHOD(Channel, watchConnectivityState) { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 196 | wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); |
thinkerou | 1930468 | 2016-07-22 02:43:19 +0800 | [diff] [blame] | 197 | php_grpc_long last_state; |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 198 | zval *deadline_obj; |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 199 | |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 200 | /* "lO" == 1 long 1 object */ |
| 201 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lO", |
| 202 | &last_state, &deadline_obj, grpc_ce_timeval) == FAILURE) { |
| 203 | zend_throw_exception(spl_ce_InvalidArgumentException, |
thinkerou | ba75c01 | 2016-07-28 02:30:08 +0800 | [diff] [blame] | 204 | "watchConnectivityState expects 1 long 1 timeval", 1 TSRMLS_CC); |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 208 | wrapped_grpc_timeval *deadline = Z_WRAPPED_GRPC_TIMEVAL_P(deadline_obj); |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 209 | grpc_channel_watch_connectivity_state(channel->wrapped, |
| 210 | (grpc_connectivity_state)last_state, |
| 211 | deadline->wrapped, completion_queue, |
| 212 | NULL); |
| 213 | grpc_event event = |
| 214 | grpc_completion_queue_pluck(completion_queue, NULL, |
| 215 | gpr_inf_future(GPR_CLOCK_REALTIME), NULL); |
Stanley Cheung | 1567c0c | 2015-08-13 11:12:54 -0700 | [diff] [blame] | 216 | RETURN_BOOL(event.success); |
Stanley Cheung | a63fdd0 | 2015-08-11 15:11:11 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /** |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 220 | * Close the channel |
thinkerou | 03dc219 | 2016-08-16 19:31:44 +0800 | [diff] [blame] | 221 | * @return void |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 222 | */ |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 223 | PHP_METHOD(Channel, close) { |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 224 | wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 225 | if (channel->wrapped != NULL) { |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 226 | grpc_channel_destroy(channel->wrapped); |
| 227 | channel->wrapped = NULL; |
| 228 | } |
| 229 | } |
| 230 | |
Stanley Cheung | 6a5c83d | 2017-02-16 12:25:32 -0800 | [diff] [blame] | 231 | ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2) |
| 232 | ZEND_ARG_INFO(0, target) |
| 233 | ZEND_ARG_INFO(0, args) |
| 234 | ZEND_END_ARG_INFO() |
| 235 | |
| 236 | ZEND_BEGIN_ARG_INFO_EX(arginfo_getTarget, 0, 0, 0) |
| 237 | ZEND_END_ARG_INFO() |
| 238 | |
| 239 | ZEND_BEGIN_ARG_INFO_EX(arginfo_getConnectivityState, 0, 0, 0) |
| 240 | ZEND_ARG_INFO(0, try_to_connect) |
| 241 | ZEND_END_ARG_INFO() |
| 242 | |
| 243 | ZEND_BEGIN_ARG_INFO_EX(arginfo_watchConnectivityState, 0, 0, 2) |
| 244 | ZEND_ARG_INFO(0, last_state) |
| 245 | ZEND_ARG_INFO(0, deadline) |
| 246 | ZEND_END_ARG_INFO() |
| 247 | |
| 248 | ZEND_BEGIN_ARG_INFO_EX(arginfo_close, 0, 0, 0) |
| 249 | ZEND_END_ARG_INFO() |
| 250 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 251 | static zend_function_entry channel_methods[] = { |
Stanley Cheung | 6a5c83d | 2017-02-16 12:25:32 -0800 | [diff] [blame] | 252 | PHP_ME(Channel, __construct, arginfo_construct, |
| 253 | ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) |
| 254 | PHP_ME(Channel, getTarget, arginfo_getTarget, |
| 255 | ZEND_ACC_PUBLIC) |
| 256 | PHP_ME(Channel, getConnectivityState, arginfo_getConnectivityState, |
| 257 | ZEND_ACC_PUBLIC) |
| 258 | PHP_ME(Channel, watchConnectivityState, arginfo_watchConnectivityState, |
| 259 | ZEND_ACC_PUBLIC) |
| 260 | PHP_ME(Channel, close, arginfo_close, |
| 261 | ZEND_ACC_PUBLIC) |
thinkerou | a3730b7 | 2016-07-20 16:59:54 +0800 | [diff] [blame] | 262 | PHP_FE_END |
| 263 | }; |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 264 | |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 265 | void grpc_init_channel(TSRMLS_D) { |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 266 | zend_class_entry ce; |
| 267 | INIT_CLASS_ENTRY(ce, "Grpc\\Channel", channel_methods); |
| 268 | ce.create_object = create_wrapped_grpc_channel; |
| 269 | grpc_ce_channel = zend_register_internal_class(&ce TSRMLS_CC); |
thinkerou | 5dafd82 | 2016-07-28 22:43:38 +0800 | [diff] [blame] | 270 | PHP_GRPC_INIT_HANDLER(wrapped_grpc_channel, channel_ce_handlers); |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 271 | } |