Skip to content

Commit

Permalink
Modifying hack thrift generator to pass tServiceName param to preSend…
Browse files Browse the repository at this point in the history
… method

Summary: This is in continuation to D62442012. This change is being made to gain parity between Policy Zones and IPF privacy frameworks. See post for more details https://fb.workplace.com/groups/thriftusers/permalink/1466494777393263/

Differential Revision: D63633378

fbshipit-source-id: c826782c2037af84a46e06d834c06b2112e1c44e
  • Loading branch information
Mohit Dhuper authored and facebook-github-bot committed Oct 4, 2024
1 parent f2b0a18 commit 4798f51
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
8 changes: 6 additions & 2 deletions thrift/compiler/generate/t_hack_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5551,11 +5551,13 @@ void t_hack_generator::_generate_sendImplHelper(
std::ofstream& out,
const t_function* tfunction,
const t_service* tservice) {
const std::string& tservice_name =
(tservice->is_interaction() ? service_name_ : tservice->name());
out << "$this->sendImplHelper($args, " << "\"" << find_hack_name(tfunction)
<< "\", "
<< (tfunction->qualifier() == t_function_qualifier::oneway ? "true"
: "false")
<< ", \"" << tservice->name() << "\" " << ");\n";
<< ", \"" << tservice_name << "\" " << ");\n";
}

/**
Expand Down Expand Up @@ -6896,6 +6898,8 @@ void t_hack_generator::_generate_sendImpl(
const std::string& funname = tfunction->name();
const std::string& rpc_function_name =
generate_rpc_function_name(tservice, tfunction);
const std::string& tservice_name =
(tservice->is_interaction() ? service_name_ : tservice->name());

if (nullable_everything_) {
indent(out) << "protected function sendImpl_" << funname << "("
Expand All @@ -6913,7 +6917,7 @@ void t_hack_generator::_generate_sendImpl(
out << indent() << "try {\n";
indent_up();
out << indent() << "$this->eventHandler_->preSend('" << rpc_function_name
<< "', $args, $currentseqid);\n";
<< "', $args, $currentseqid, '" << tservice_name << "');\n";
out << indent() << "if ($this->output_ is \\TBinaryProtocolAccelerated)\n";
scope_up(out);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected function sendImpl_foo(): int {
$currentseqid = $this->getNextSequenceID();
$args = BadService_BadInteraction_foo_args::withDefaultValues();
try {
$this->eventHandler_->preSend('BadInteraction.foo', $args, $currentseqid);
$this->eventHandler_->preSend('BadInteraction.foo', $args, $currentseqid, 'BadService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'BadInteraction.foo', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function sendImpl_init(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractLocally_SharedInteraction_init_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.init', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.init', $args, $currentseqid, 'InteractLocally');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.init', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -153,7 +153,7 @@ protected function sendImpl_do_something(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractLocally_SharedInteraction_do_something_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.do_something', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.do_something', $args, $currentseqid, 'InteractLocally');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.do_something', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -209,7 +209,7 @@ protected function sendImpl_tear_down(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractLocally_SharedInteraction_tear_down_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.tear_down', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.tear_down', $args, $currentseqid, 'InteractLocally');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.tear_down', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_MyInteraction_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -219,7 +219,7 @@ protected function sendImpl_ping(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_MyInteraction_ping_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.ping', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), true);
Expand Down Expand Up @@ -275,7 +275,7 @@ protected function sendImpl_truthify(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_MyInteraction_truthify_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.truthify', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -331,7 +331,7 @@ protected function sendImpl_encode(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_MyInteraction_encode_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.encode', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -401,7 +401,7 @@ protected function sendImpl_init(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_SharedInteraction_init_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.init', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.init', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.init', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -457,7 +457,7 @@ protected function sendImpl_do_something(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_SharedInteraction_do_something_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.do_something', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.do_something', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.do_something', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -513,7 +513,7 @@ protected function sendImpl_tear_down(): int {
$currentseqid = $this->getNextSequenceID();
$args = InteractWithShared_SharedInteraction_tear_down_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SharedInteraction.tear_down', $args, $currentseqid);
$this->eventHandler_->preSend('SharedInteraction.tear_down', $args, $currentseqid, 'InteractWithShared');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SharedInteraction.tear_down', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteraction_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -225,7 +225,7 @@ protected function sendImpl_ping(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteraction_ping_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.ping', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), true);
Expand Down Expand Up @@ -281,7 +281,7 @@ protected function sendImpl_truthify(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteraction_truthify_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.truthify', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function sendImpl_encode(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteraction_encode_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.encode', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -407,7 +407,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteractionFast_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.frobnicate', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -463,7 +463,7 @@ protected function sendImpl_ping(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteractionFast_ping_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.ping', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.ping', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.ping', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), true);
Expand Down Expand Up @@ -519,7 +519,7 @@ protected function sendImpl_truthify(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteractionFast_truthify_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.truthify', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.truthify', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.truthify', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -575,7 +575,7 @@ protected function sendImpl_encode(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_MyInteractionFast_encode_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.encode', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.encode', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.encode', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -645,7 +645,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = MyService_SerialInteraction_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SerialInteraction.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('SerialInteraction.frobnicate', $args, $currentseqid, 'MyService');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SerialInteraction.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteraction_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.frobnicate', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -225,7 +225,7 @@ protected function sendImpl_ping(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteraction_ping_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.ping', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.ping', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), true);
Expand Down Expand Up @@ -281,7 +281,7 @@ protected function sendImpl_truthify(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteraction_truthify_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.truthify', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.truthify', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function sendImpl_encode(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteraction_encode_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteraction.encode', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteraction.encode', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -407,7 +407,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteractionFast_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.frobnicate', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -463,7 +463,7 @@ protected function sendImpl_ping(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteractionFast_ping_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.ping', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.ping', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.ping', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), true);
Expand Down Expand Up @@ -519,7 +519,7 @@ protected function sendImpl_truthify(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteractionFast_truthify_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.truthify', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.truthify', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.truthify', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -575,7 +575,7 @@ protected function sendImpl_encode(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_MyInteractionFast_encode_args::withDefaultValues();
try {
$this->eventHandler_->preSend('MyInteractionFast.encode', $args, $currentseqid);
$this->eventHandler_->preSend('MyInteractionFast.encode', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'MyInteractionFast.encode', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down Expand Up @@ -645,7 +645,7 @@ protected function sendImpl_frobnicate(): int {
$currentseqid = $this->getNextSequenceID();
$args = Perform_SerialInteraction_frobnicate_args::withDefaultValues();
try {
$this->eventHandler_->preSend('SerialInteraction.frobnicate', $args, $currentseqid);
$this->eventHandler_->preSend('SerialInteraction.frobnicate', $args, $currentseqid, 'Perform');
if ($this->output_ is \TBinaryProtocolAccelerated)
{
\thrift_protocol_write_binary($this->output_, 'SerialInteraction.frobnicate', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false);
Expand Down

0 comments on commit 4798f51

Please sign in to comment.