Google Cloud Pub/Sub C++ Client  1.32.1
A C++ Client Library for Google Cloud Pub/Sub
subscriber_options.cc
Go to the documentation of this file.
1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "google/cloud/pubsub/subscriber_options.h"
16 #include "google/cloud/pubsub/internal/defaults.h"
17 #include <algorithm>
18 
19 namespace google {
20 namespace cloud {
21 namespace pubsub {
22 inline namespace GOOGLE_CLOUD_CPP_PUBSUB_NS {
23 
24 using seconds = std::chrono::seconds;
25 
27  internal::CheckExpectedOptions<SubscriberOptionList>(opts, __func__);
28  opts_ = pubsub_internal::DefaultSubscriberOptionsOnly(std::move(opts));
29 }
30 
32  seconds extension) {
34  (std::max)((std::min)(extension, seconds(600)), seconds(10)));
35  return *this;
36 }
37 
39  std::int64_t message_count) {
41  (std::max<std::int64_t>)(0, message_count));
42  return *this;
43 }
44 
46  std::int64_t bytes) {
47  opts_.set<MaxOutstandingBytesOption>((std::max<std::int64_t>)(0, bytes));
48  return *this;
49 }
50 
52  opts_.set<MaxConcurrencyOption>(v == 0 ? pubsub_internal::DefaultThreadCount()
53  : v);
54  return *this;
55 }
56 
57 } // namespace GOOGLE_CLOUD_CPP_PUBSUB_NS
58 } // namespace pubsub
59 } // namespace cloud
60 } // namespace google