Skip to content
Snippets Groups Projects
Commit 6668d51b authored by Stanley Cheung's avatar Stanley Cheung
Browse files

php: add call getTrailingMetadata API

parent a47acad0
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ abstract class AbstractCall
protected $call;
protected $deserialize;
protected $metadata;
protected $trailing_metadata;
/**
* Create a new Call wrapper object.
......@@ -66,6 +67,7 @@ abstract class AbstractCall
$this->call = new Call($channel, $method, $deadline);
$this->deserialize = $deserialize;
$this->metadata = null;
$this->trailing_metadata = null;
if (isset($options['call_credentials_callback']) &&
is_callable($call_credentials_callback =
$options['call_credentials_callback'])) {
......@@ -83,6 +85,14 @@ abstract class AbstractCall
return $this->metadata;
}
/**
* @return The trailing metadata sent by the server.
*/
public function getTrailingMetadata()
{
return $this->trailing_metadata;
}
/**
* @return string The URI of the endpoint.
*/
......
......@@ -112,6 +112,7 @@ class BidiStreamingCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
$this->trailing_metadata = $status_event->status->metadata;
return $status_event->status;
}
}
......@@ -86,6 +86,8 @@ class ClientStreamingCall extends AbstractCall
]);
$this->metadata = $event->metadata;
return [$this->deserializeResponse($event->message), $event->status];
$status = $event->status;
$this->trailing_metadata = $status->metadata;
return [$this->deserializeResponse($event->message), $status];
}
}
......@@ -91,6 +91,7 @@ class ServerStreamingCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
$this->trailing_metadata = $status_event->status->metadata;
return $status_event->status;
}
}
......@@ -75,6 +75,8 @@ class UnaryCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
return [$this->deserializeResponse($event->message), $event->status];
$status = $event->status;
$this->trailing_metadata = $status->metadata;
return [$this->deserializeResponse($event->message), $status];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment