Skip to content

Commit f5a9e7e

Browse files
authored
impl(pubsub): add default message batch impl (#12676)
1 parent 0829f24 commit f5a9e7e

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

google/cloud/pubsub/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ add_library(
7575
internal/flow_controlled_publisher_connection.h
7676
internal/flow_controlled_publisher_tracing_connection.cc
7777
internal/flow_controlled_publisher_tracing_connection.h
78+
internal/noop_message_batch.h
7879
internal/ordering_key_publisher_connection.cc
7980
internal/ordering_key_publisher_connection.h
8081
internal/publisher_auth_decorator.cc

google/cloud/pubsub/google_cloud_cpp_pubsub.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ google_cloud_cpp_pubsub_hdrs = [
3838
"internal/extend_leases_with_retry.h",
3939
"internal/flow_controlled_publisher_connection.h",
4040
"internal/flow_controlled_publisher_tracing_connection.h",
41+
"internal/noop_message_batch.h",
4142
"internal/ordering_key_publisher_connection.h",
4243
"internal/publisher_auth_decorator.h",
4344
"internal/publisher_logging_decorator.h",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2023 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+
// https://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+
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_NOOP_MESSAGE_BATCH_H
16+
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_NOOP_MESSAGE_BATCH_H
17+
18+
#include "google/cloud/pubsub/internal/message_batch.h"
19+
20+
namespace google {
21+
namespace cloud {
22+
namespace pubsub_internal {
23+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
24+
25+
/**
26+
* A no-op implementation of `MessageBatch`
27+
*/
28+
class NoOpMessageBatch : public MessageBatch {
29+
public:
30+
NoOpMessageBatch() = default;
31+
32+
~NoOpMessageBatch() override = default;
33+
34+
void SaveMessage(pubsub::Message m) override{};
35+
36+
void Flush() override{};
37+
38+
void FlushCallback() override{};
39+
};
40+
41+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
42+
} // namespace pubsub_internal
43+
} // namespace cloud
44+
} // namespace google
45+
46+
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_NOOP_MESSAGE_BATCH_H

0 commit comments

Comments
 (0)