event_string.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
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
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 
20 
22 
23 #include <algorithm>
24 #include <vector>
25 
26 #include "absl/strings/str_format.h"
27 #include "absl/strings/str_join.h"
28 
29 static void addhdr(grpc_event* ev, std::vector<std::string>* buf) {
30  buf->push_back(absl::StrFormat("tag:%p", ev->tag));
31 }
32 
33 static const char* errstr(int success) { return success ? "OK" : "ERROR"; }
34 
35 static void adderr(int success, std::vector<std::string>* buf) {
36  buf->push_back(absl::StrFormat(" %s", errstr(success)));
37 }
38 
40  if (ev == nullptr) return "null";
41  std::vector<std::string> out;
42  switch (ev->type) {
43  case GRPC_QUEUE_TIMEOUT:
44  out.push_back("QUEUE_TIMEOUT");
45  break;
47  out.push_back("QUEUE_SHUTDOWN");
48  break;
49  case GRPC_OP_COMPLETE:
50  out.push_back("OP_COMPLETE: ");
51  addhdr(ev, &out);
52  adderr(ev->success, &out);
53  break;
54  }
55  return absl::StrJoin(out, "");
56 }
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
GRPC_QUEUE_SHUTDOWN
@ GRPC_QUEUE_SHUTDOWN
Definition: grpc_types.h:554
GRPC_OP_COMPLETE
@ GRPC_OP_COMPLETE
Definition: grpc_types.h:558
absl::StrJoin
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
Definition: abseil-cpp/absl/strings/str_join.h:239
addhdr
static void addhdr(grpc_event *ev, std::vector< std::string > *buf)
Definition: event_string.cc:29
grpc_event
Definition: grpc_types.h:564
event_string.h
errstr
static const char * errstr(int success)
Definition: event_string.cc:33
adderr
static void adderr(int success, std::vector< std::string > *buf)
Definition: event_string.cc:35
grpc_event_string
std::string grpc_event_string(grpc_event *ev)
Definition: event_string.cc:39
grpc_event::type
grpc_completion_type type
Definition: grpc_types.h:566
grpc_event::success
int success
Definition: grpc_types.h:572
GRPC_QUEUE_TIMEOUT
@ GRPC_QUEUE_TIMEOUT
Definition: grpc_types.h:556
grpc_event::tag
void * tag
Definition: grpc_types.h:576
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:16