本文整理汇总了C++中SubscriptionRequest::add_path_list方法的典型用法代码示例。如果您正苦于以下问题:C++ SubscriptionRequest::add_path_list方法的具体用法?C++ SubscriptionRequest::add_path_list怎么用?C++ SubscriptionRequest::add_path_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubscriptionRequest
的用法示例。
在下文中一共展示了SubscriptionRequest::add_path_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(AgentConsolidatorTest, add) {
AgentConsolidatorHandle *handle;
SubscriptionRequest request;
SubscriptionRequest system_accepted_request;
telemetry::Path *path;
// Build a request of valid paths
path = request.add_path_list();
path->set_path("firewall");
path = request.add_path_list();
path->set_path("port");
// Add it to the consolidator
handle = cons->addRequest(61, &request, &system_accepted_request);
EXPECT_TRUE(handle != NULL);
EXPECT_EQ(2, cons->getSystemRequestCount());
EXPECT_EQ(1, cons->getAddCount());
EXPECT_EQ(0, cons->getErrors());
for (int i = 0; i < request.path_list_size(); i++) {
EXPECT_STREQ(request.path_list(i).path().c_str(),
system_accepted_request.path_list(i).path().c_str());
}
// Simple check get call is good
SubscriptionRequest *test_ptr;
test_ptr = cons->getRequest(handle, false);
EXPECT_TRUE(test_ptr != NULL);
// Remove it now
cons->removeRequest(handle);
EXPECT_EQ(0, cons->getSystemRequestCount());
EXPECT_EQ(1, cons->getRemCount());
EXPECT_EQ(0, cons->getErrors());
}
示例2: sleep
void *
AgentConsolidatorTest::create (void *args)
{
TestArgs *test_args = (TestArgs *) args;
AgentConsolidator *cons = test_args->cons;
AgentConsolidatorHandle *handle;
SubscriptionRequest request;
SubscriptionRequest system_accepted_request;
telemetry::Path *path;
// Build a request
path = request.add_path_list();
path->set_path("firewall");
path = request.add_path_list();
path->set_path("port");
// Add it to the consolidator
id_idx_t subscription_id = test_args->id;
handle = cons->addRequest(subscription_id, &request,
&system_accepted_request);
// Sleep randomly between 0 to 4 seconds
sleep(rand()%5);
// Now remove it
cons->removeRequest(handle);
return NULL;
}
示例3: key_value
void *
Service::proc (void *p_args)
{
ServiceContext *contextp = (ServiceContext *) p_args;
ServiceInterestList *interests = contextp->_interests;
Service *service = contextp->_service;
// Create a reader
SubscriptionRequest request;
Path *path;
path = request.add_path_list();
path->set_path(service->getName());
path->set_sample_frequency(5000);
ClientContext context;
std::multimap<grpc::string_ref, grpc::string_ref> server_metadata;
std::multimap<grpc::string_ref, grpc::string_ref>::iterator metadata_itr;
std::unique_ptr<ClientReader<OpenConfigData>> reader(service->stub_->telemetrySubscribe(&context, request));
// Get the subscription ID from the response
// Wait for the initial meta data to come back
reader->WaitForInitialMetadata();
server_metadata = context.GetServerInitialMetadata();
metadata_itr = server_metadata.find("init-response");
std::string tmp = metadata_itr->second.data();
// Use Textformat Printer APIs to convert to right format
google::protobuf::TextFormat::Parser parser;
SubscriptionReply reply;
SubscriptionResponse *response;
parser.ParseFromString(tmp, &reply);
response = reply.mutable_response();
service->setSubscriptionId(response->subscription_id());
// Create the read channel
OpenConfigData kv;
while (reader->Read(&kv)) {
for (int i = 0; i < kv.kv_size(); i++) {
const KeyValue &kv_data = kv.kv(i);
ServiceCallbackKeyValue key_value(kv_data.key(), kv_data.str_value());
for (ServiceInterestListIterator itr = interests->begin(); itr != interests->end(); itr++) {
Element *element = (*itr)->_element;
(*itr)->_cb(element, &key_value);
}
}
}
// We are done.
return NULL;
}