├── .asf.yaml ├── .clang-format ├── .clang-tidy ├── .github ├── ISSUE_TEMPLATE │ └── bug-report.yml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ci-build-binary-artifacts.yaml │ ├── ci-pr-validation.yaml │ └── codeql-analysis.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Doxyfile ├── LEGACY_BUILD.md ├── LICENSE ├── LegacyFindPackages.cmake ├── NOTICE ├── README.md ├── SECURITY.md ├── build-support ├── Dockerfile.format ├── clang_format_exclusions.txt ├── copy-deps-versionfile.sh ├── dep-version.py ├── docker-format.sh ├── download-release-artifacts.py ├── gen-pulsar-version-macro.py ├── generate-source-archive.sh ├── merge_archives.sh ├── merge_archives_vcpkg.sh ├── run_clang_format.py ├── run_clang_tidy.sh ├── setup-test-service-container.sh ├── sign-files.sh ├── stage-release.sh ├── start-mim-test-service-inside-container.sh └── start-test-service-inside-container.sh ├── cmake_modules └── FindClangTools.cmake ├── dependencies.yaml ├── eclipse-formatter.xml ├── examples ├── CMakeLists.txt ├── SampleAsyncConsumerCApi.c ├── SampleAsyncProducer.cc ├── SampleConsumer.cc ├── SampleConsumerCApi.c ├── SampleConsumerListener.cc ├── SampleConsumerListenerCApi.c ├── SampleCustomLoggerCApi.c ├── SampleFileLogger.cc ├── SampleKeyValueSchemaConsumer.cc ├── SampleKeyValueSchemaProducer.cc ├── SampleProducer.cc ├── SampleProducerCApi.c └── SampleReaderCApi.c ├── include └── pulsar │ ├── Authentication.h │ ├── BatchReceivePolicy.h │ ├── BrokerConsumerStats.h │ ├── Client.h │ ├── ClientConfiguration.h │ ├── CompressionType.h │ ├── ConsoleLoggerFactory.h │ ├── Consumer.h │ ├── ConsumerConfiguration.h │ ├── ConsumerCryptoFailureAction.h │ ├── ConsumerEventListener.h │ ├── ConsumerInterceptor.h │ ├── ConsumerType.h │ ├── CryptoKeyReader.h │ ├── DeadLetterPolicy.h │ ├── DeadLetterPolicyBuilder.h │ ├── DeprecatedException.h │ ├── EncryptionKeyInfo.h │ ├── FileLoggerFactory.h │ ├── InitialPosition.h │ ├── KeySharedPolicy.h │ ├── KeyValue.h │ ├── Logger.h │ ├── Message.h │ ├── MessageBatch.h │ ├── MessageBuilder.h │ ├── MessageId.h │ ├── MessageIdBuilder.h │ ├── MessageRoutingPolicy.h │ ├── Producer.h │ ├── ProducerConfiguration.h │ ├── ProducerCryptoFailureAction.h │ ├── ProducerInterceptor.h │ ├── ProtobufNativeSchema.h │ ├── Reader.h │ ├── ReaderConfiguration.h │ ├── RegexSubscriptionMode.h │ ├── Result.h │ ├── Schema.h │ ├── TableView.h │ ├── TableViewConfiguration.h │ ├── TopicMetadata.h │ ├── TypedMessage.h │ ├── TypedMessageBuilder.h │ ├── c │ ├── authentication.h │ ├── client.h │ ├── client_configuration.h │ ├── consumer.h │ ├── consumer_configuration.h │ ├── message.h │ ├── message_id.h │ ├── message_router.h │ ├── messages.h │ ├── producer.h │ ├── producer_configuration.h │ ├── reader.h │ ├── reader_configuration.h │ ├── result.h │ ├── string_list.h │ ├── string_map.h │ ├── table_view.h │ ├── table_view_configuration.h │ └── version.h │ └── defines.h ├── lib ├── AckGroupingTracker.cc ├── AckGroupingTracker.h ├── AckGroupingTrackerDisabled.cc ├── AckGroupingTrackerDisabled.h ├── AckGroupingTrackerEnabled.cc ├── AckGroupingTrackerEnabled.h ├── AsioDefines.h ├── AsioTimer.h ├── Authentication.cc ├── Backoff.cc ├── Backoff.h ├── Base64Utils.h ├── BatchMessageAcker.h ├── BatchMessageContainer.cc ├── BatchMessageContainer.h ├── BatchMessageContainerBase.cc ├── BatchMessageContainerBase.h ├── BatchMessageKeyBasedContainer.cc ├── BatchMessageKeyBasedContainer.h ├── BatchReceivePolicy.cc ├── BatchReceivePolicyImpl.h ├── BatchedMessageIdImpl.h ├── BinaryProtoLookupService.cc ├── BinaryProtoLookupService.h ├── BitSet.h ├── BlockingQueue.h ├── BoostHash.cc ├── BoostHash.h ├── BrokerConsumerStats.cc ├── BrokerConsumerStatsImpl.cc ├── BrokerConsumerStatsImpl.h ├── BrokerConsumerStatsImplBase.h ├── CMakeLists.txt ├── ChunkMessageIdImpl.h ├── Client.cc ├── ClientConfiguration.cc ├── ClientConfigurationImpl.h ├── ClientConnection.cc ├── ClientConnection.h ├── ClientConnectionAdaptor.h ├── ClientImpl.cc ├── ClientImpl.h ├── Commands.cc ├── Commands.h ├── CompressionCodec.cc ├── CompressionCodec.h ├── CompressionCodecLZ4.cc ├── CompressionCodecLZ4.h ├── CompressionCodecSnappy.cc ├── CompressionCodecSnappy.h ├── CompressionCodecZLib.cc ├── CompressionCodecZLib.h ├── CompressionCodecZstd.cc ├── CompressionCodecZstd.h ├── ConnectionPool.cc ├── ConnectionPool.h ├── ConsoleLoggerFactory.cc ├── ConsoleLoggerFactoryImpl.h ├── Consumer.cc ├── ConsumerConfiguration.cc ├── ConsumerConfigurationImpl.h ├── ConsumerImpl.cc ├── ConsumerImpl.h ├── ConsumerImplBase.cc ├── ConsumerImplBase.h ├── ConsumerInterceptors.cc ├── ConsumerInterceptors.h ├── CryptoKeyReader.cc ├── CurlWrapper.h ├── DeadLetterPolicyBuilder.cc ├── DeadLetterPolicyImpl.cc ├── DeadLetterPolicyImpl.h ├── DeprecatedException.cc ├── EncryptionKeyInfo.cc ├── EncryptionKeyInfoImpl.cc ├── EncryptionKeyInfoImpl.h ├── ExecutorService.cc ├── ExecutorService.h ├── FileLoggerFactory.cc ├── FileLoggerFactoryImpl.h ├── Future.h ├── GetLastMessageIdResponse.h ├── HTTPLookupService.cc ├── HTTPLookupService.h ├── HandlerBase.cc ├── HandlerBase.h ├── Hash.h ├── Int64SerDes.h ├── JavaStringHash.cc ├── JavaStringHash.h ├── JsonUtils.h ├── KeySharedPolicy.cc ├── KeySharedPolicyImpl.h ├── KeyValue.cc ├── KeyValueImpl.cc ├── KeyValueImpl.h ├── Latch.cc ├── Latch.h ├── LogUtils.cc ├── LogUtils.h ├── LookupDataResult.h ├── LookupService.h ├── MapCache.h ├── MemoryLimitController.cc ├── MemoryLimitController.h ├── Message.cc ├── MessageAndCallbackBatch.cc ├── MessageAndCallbackBatch.h ├── MessageBatch.cc ├── MessageBuilder.cc ├── MessageCrypto.cc ├── MessageCrypto.h ├── MessageId.cc ├── MessageIdBuilder.cc ├── MessageIdImpl.h ├── MessageIdUtil.h ├── MessageImpl.cc ├── MessageImpl.h ├── MessageRouterBase.cc ├── MessageRouterBase.h ├── MessagesImpl.cc ├── MessagesImpl.h ├── MultiTopicsBrokerConsumerStatsImpl.cc ├── MultiTopicsBrokerConsumerStatsImpl.h ├── MultiTopicsConsumerImpl.cc ├── MultiTopicsConsumerImpl.h ├── Murmur3_32Hash.cc ├── Murmur3_32Hash.h ├── NamedEntity.cc ├── NamedEntity.h ├── NamespaceName.cc ├── NamespaceName.h ├── NegativeAcksTracker.cc ├── NegativeAcksTracker.h ├── ObjectPool.h ├── OpSendMsg.h ├── PartitionedProducerImpl.cc ├── PartitionedProducerImpl.h ├── PatternMultiTopicsConsumerImpl.cc ├── PatternMultiTopicsConsumerImpl.h ├── PendingFailures.h ├── PeriodicTask.cc ├── PeriodicTask.h ├── Producer.cc ├── ProducerConfiguration.cc ├── ProducerConfigurationImpl.h ├── ProducerImpl.cc ├── ProducerImpl.h ├── ProducerImplBase.h ├── ProducerInterceptors.cc ├── ProducerInterceptors.h ├── ProtoApiEnums.h ├── ProtobufNativeSchema.cc ├── PulsarScheme.h ├── Reader.cc ├── ReaderConfiguration.cc ├── ReaderConfigurationImpl.h ├── ReaderImpl.cc ├── ReaderImpl.h ├── Result.cc ├── ResultUtils.h ├── RetryableLookupService.h ├── RetryableOperation.h ├── RetryableOperationCache.h ├── RoundRobinMessageRouter.cc ├── RoundRobinMessageRouter.h ├── Schema.cc ├── SchemaUtils.h ├── Semaphore.cc ├── Semaphore.h ├── ServiceNameResolver.h ├── ServiceURI.cc ├── ServiceURI.h ├── ServiceUnitId.h ├── SharedBuffer.h ├── SimpleLogger.h ├── SinglePartitionMessageRouter.cc ├── SinglePartitionMessageRouter.h ├── Synchronized.h ├── SynchronizedHashMap.h ├── TableView.cc ├── TableViewImpl.cc ├── TableViewImpl.h ├── TestUtil.h ├── TimeUtils.h ├── TopicMetadataImpl.cc ├── TopicMetadataImpl.h ├── TopicName.cc ├── TopicName.h ├── UnAckedMessageTrackerDisabled.h ├── UnAckedMessageTrackerEnabled.cc ├── UnAckedMessageTrackerEnabled.h ├── UnAckedMessageTrackerInterface.h ├── UnboundedBlockingQueue.h ├── Url.cc ├── Url.h ├── UtilAllocator.h ├── Utils.h ├── auth │ ├── AuthAthenz.cc │ ├── AuthAthenz.h │ ├── AuthBasic.cc │ ├── AuthBasic.h │ ├── AuthOauth2.cc │ ├── AuthOauth2.h │ ├── AuthTls.cc │ ├── AuthTls.h │ ├── AuthToken.cc │ ├── AuthToken.h │ ├── InitialAuthData.h │ └── athenz │ │ ├── ZTSClient.cc │ │ └── ZTSClient.h ├── c │ ├── cStringList.cc │ ├── cStringMap.cc │ ├── c_Authentication.cc │ ├── c_Client.cc │ ├── c_ClientConfiguration.cc │ ├── c_Consumer.cc │ ├── c_ConsumerConfiguration.cc │ ├── c_Message.cc │ ├── c_MessageId.cc │ ├── c_MessageRouter.cc │ ├── c_Messages.cc │ ├── c_Producer.cc │ ├── c_ProducerConfiguration.cc │ ├── c_Reader.cc │ ├── c_ReaderConfiguration.cc │ ├── c_Result.cc │ ├── c_TableView.cc │ ├── c_TableViewConfiguration.cc │ └── c_structs.h ├── checksum │ ├── ChecksumProvider.cc │ ├── ChecksumProvider.h │ ├── crc32c_arm.cc │ ├── crc32c_arm.h │ ├── crc32c_sse42.cc │ ├── crc32c_sse42.h │ ├── crc32c_sw.cc │ ├── crc32c_sw.h │ ├── gf2.hpp │ └── int_types.h ├── lz4 │ ├── lz4.cc │ └── lz4.h └── stats │ ├── ConsumerStatsBase.h │ ├── ConsumerStatsDisabled.h │ ├── ConsumerStatsImpl.cc │ ├── ConsumerStatsImpl.h │ ├── ProducerStatsBase.h │ ├── ProducerStatsDisabled.h │ ├── ProducerStatsImpl.cc │ └── ProducerStatsImpl.h ├── log4cxx.conf ├── perf ├── BuildPerf.cmake ├── CMakeLists.txt ├── LegacyBuildPerf.cmake ├── PerfConsumer.cc ├── PerfProducer.cc └── RateLimiter.h ├── pkg ├── apk │ ├── .gitignore │ ├── APKBUILD │ ├── Dockerfile │ ├── build-apk.sh │ ├── create-images.sh │ ├── docker-build-apk-arm64.sh │ └── docker-build-apk-x86_64.sh ├── deb │ ├── .gitignore │ ├── Dockerfile │ ├── build-deb.sh │ ├── create-images.sh │ ├── docker-build-deb-arm64.sh │ └── docker-build-deb-x86_64.sh ├── licenses │ ├── LICENSE-boost.txt │ ├── LICENSE-jsoncpp.txt │ ├── LICENSE-libcurl.txt │ ├── LICENSE-protobuf.txt │ ├── LICENSE-zlib.txt │ └── LICENSE.txt ├── mac │ ├── build-static-library.sh │ └── vcpkg-curl-patch.diff └── rpm │ ├── .gitignore │ ├── Dockerfile │ ├── SPECS │ └── pulsar-client.spec │ ├── build-rpm.sh │ ├── create-images.sh │ ├── docker-build-rpm-arm64.sh │ └── docker-build-rpm-x86_64.sh ├── proto └── PulsarApi.proto ├── pulsar-test-service-start.sh ├── pulsar-test-service-stop.sh ├── run-unit-tests.sh ├── templates └── Version.h.in ├── test-conf ├── .htpasswd ├── broker-cert.pem ├── broker-key.pem ├── cacert.pem ├── cakey.pem ├── chained-client-cert.pem ├── chained-client-key.pem ├── client-cert.pem ├── client-key.pem ├── client-ssl-mim.conf ├── client-ssl.conf ├── client.conf ├── cpp_credentials_file.json ├── hn-verification │ ├── broker-cert.pem │ ├── broker-key.pem │ └── cacert.pem ├── intermediate-cacert.pem ├── intermediate-cakey.pem ├── private-key.client-ecdsa.pem ├── private-key.client-mismatch-rsa.pem ├── private-key.client-rsa.pem ├── public-key.client-ecdsa.pem ├── public-key.client-mismatch-rsa.pem ├── public-key.client-rsa.pem ├── standalone-ssl-mim.conf ├── standalone-ssl.conf └── standalone.conf ├── tests ├── AcknowledgeTest.cc ├── AuthBasicTest.cc ├── AuthPluginTest.cc ├── AuthTokenTest.cc ├── BackoffTest.cc ├── Base64Test.cc ├── BasicEndToEndTest.cc ├── BatchMessageTest.cc ├── BatchReceivePolicyTest.cc ├── BitSetTest.cc ├── BlockingQueueTest.cc ├── BuildTests.cmake ├── CMakeLists.txt ├── ClientDeduplicationTest.cc ├── ClientTest.cc ├── CompressionCodecSnappyTest.cc ├── ConnectionTest.cc ├── ConsumerConfigurationTest.cc ├── ConsumerSeekTest.cc ├── ConsumerStatsTest.cc ├── ConsumerTest.cc ├── ConsumerTest.h ├── ConsumerWrapper.cc ├── ConsumerWrapper.h ├── CustomLoggerTest.cc ├── CustomRoutingPolicy.h ├── DeadLetterPolicyTest.cc ├── DeadLetterQueueTest.cc ├── HashTest.cc ├── HttpHelper.cc ├── HttpHelper.h ├── Int64SerDesTest.cc ├── InterceptorsTest.cc ├── KeyBasedBatchingTest.cc ├── KeySharedConsumerTest.cc ├── KeySharedPolicyTest.cc ├── KeyValueImplTest.cc ├── KeyValueSchemaTest.cc ├── LatchTest.cc ├── LegacyBuildTests.cmake ├── LogHelper.h ├── LoggerTest.cc ├── LookupServiceTest.cc ├── MapCacheTest.cc ├── MemoryLimitControllerTest.cc ├── MemoryLimitTest.cc ├── MessageChunkingTest.cc ├── MessageIdTest.cc ├── MessageTest.cc ├── MessagesImplTest.cc ├── MockClientImpl.h ├── MultiTopicsConsumerTest.cc ├── NamespaceNameTest.cc ├── NoOpsCryptoKeyReader.h ├── PaddingDemo.proto ├── PartitionsUpdateTest.cc ├── PeriodicTaskTest.cc ├── ProducerConfigurationTest.cc ├── ProducerTest.cc ├── PromiseTest.cc ├── ProtobufNativeSchemaTest.cc ├── PulsarAdminHelper.h ├── PulsarFriend.h ├── PulsarWrapper.h ├── ReaderConfigurationTest.cc ├── ReaderTest.cc ├── RetryableOperationCacheTest.cc ├── RoundRobinMessageRouterTest.cc ├── SchemaTest.cc ├── SemaphoreTest.cc ├── ServiceURITest.cc ├── ShutdownTest.cc ├── SinglePartitionMessageRouterTest.cc ├── SynchronizedHashMapTest.cc ├── SynchronizedQueue.h ├── TableViewTest.cc ├── ThreadSafeMessages.h ├── TopicMetadataImplTest.cc ├── TopicNameTest.cc ├── TypedMessageTest.cc ├── UnboundedBlockingQueueTest.cc ├── UrlTest.cc ├── VersionTest.cc ├── WaitUtils.h ├── ZLibCompressionTest.cc ├── ZTSClientTest.cc ├── ZeroQueueSizeTest.cc ├── blue-green │ └── docker-compose.yml ├── brokermetadata │ ├── BrokerMetadataTest.cc │ └── docker-compose.yml ├── c │ ├── c_BasicEndToEndTest.cc │ ├── c_ClientConfigurationTest.cc │ ├── c_ConsumerConfigurationTest.cc │ ├── c_ConsumerTest.cc │ ├── c_MessageTest.cc │ ├── c_ProducerConfigurationTest.cc │ ├── c_ReaderConfigurationTest.cc │ ├── c_SeekTest.cc │ └── c_TableViewTest.cc ├── chunkdedup │ ├── ChunkDedupTest.cc │ └── docker-compose.yml ├── extensibleLM │ ├── ExtensibleLoadManagerTest.cc │ └── docker-compose.yml ├── main.cc ├── mocks │ └── GMockMessage.h ├── oauth2 │ ├── Oauth2Test.cc │ └── docker-compose.yml ├── proto │ ├── ExternalTest.proto │ └── Test.proto ├── standalone.conf └── unix │ └── ConnectionFailTest.cc ├── vcpkg-example ├── CMakeLists.txt ├── README.md ├── main.cc └── vcpkg.json ├── vcpkg-triplets ├── arm64-osx.cmake └── x64-osx.cmake ├── vcpkg.json ├── version.txt ├── win-examples ├── CMakeLists.txt └── example.cc └── wireshark ├── CMakeLists.txt ├── README.md ├── pulsar-dissector-example.jpg ├── pulsarDissector.cc └── wireshark-plugins.jpg /.clang-format: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. 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, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | 19 | BasedOnStyle: Google 20 | IndentWidth: 4 21 | ColumnLimit: 110 22 | SortIncludes: true 23 | BreakBeforeBraces: Custom 24 | BraceWrapping: 25 | AfterEnum: true 26 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. 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, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | --- 19 | # TODO: add more checks 20 | # - bugprone 21 | # - cppcoreguidelines 22 | # - portability 23 | # - readability 24 | Checks: > 25 | -*, 26 | clang-analyzer-*, 27 | -clang-analyzer-security.insecureAPI.rand, 28 | performance-*, 29 | -performance-inefficient-string-concatenation 30 | WarningsAsErrors: '*' 31 | HeaderFilterRegex: '^(?!.*PulsarApi\.pb\.h$).*$' 32 | FormatStyle: none 33 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vcpkg"] 2 | path = vcpkg 3 | url = https://github.com/microsoft/vcpkg.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | ## Contributing to Apache Pulsar 23 | 24 | We would love for you to contribute to Apache Pulsar and make it even better! 25 | Please check the [Contributing to Apache Pulsar](https://pulsar.apache.org/contributing/) 26 | page before starting to work on the project. 27 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache Pulsar 2 | Copyright 2017-2022 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Security Vulnerability Process 4 | 5 | The Pulsar community follows the ASF [security vulnerability handling process](https://apache.org/security/#vulnerability-handling). 6 | 7 | To report a new vulnerability you have discovered, please follow the [ASF security vulnerability reporting process](https://apache.org/security/#reporting-a-vulnerability). To report a vulnerability for Pulsar, contact the [Apache Security Team](https://www.apache.org/security/). When reporting a vulnerability to [security@apache.org](mailto:security@apache.org), you can copy your email to [private@pulsar.apache.org](mailto:private@pulsar.apache.org) to send your report to the Apache Pulsar Project Management Committee. This is a private mailing list. 8 | 9 | It is the responsibility of the security vulnerability handling project team (Apache Pulsar PMC in most cases) to make public security vulnerability announcements. You can follow announcements on the [users@pulsar.apache.org](mailto:users@pulsar.apache.org) mailing list. For instructions on how to subscribe, please see https://pulsar.apache.org/contact/. 10 | 11 | ## Security Policy details and supported versions of Apache Pulsar 12 | 13 | The security policy and supported versions are outlined on the Pulsar website under [Security > Security Policy and Supported Versions](https://pulsar.apache.org/docs/security-policy-and-supported-versions/). 14 | 15 | ## Security Advisories 16 | 17 | Please visit the [Security Advisories](https://github.com/apache/pulsar/wiki/Security-advisories) page. -------------------------------------------------------------------------------- /build-support/Dockerfile.format: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | 21 | FROM ubuntu:20.04 22 | 23 | WORKDIR /app 24 | 25 | RUN apt update -y && apt install -y python3 clang-format-11 26 | ENTRYPOINT ["python3", "./build-support/run_clang_format.py", \ 27 | "clang-format-11", \ 28 | "0", \ 29 | "./build-support/clang_format_exclusions.txt", \ 30 | "./lib", \ 31 | "./perf", \ 32 | "./examples", \ 33 | "./tests", \ 34 | "./include", \ 35 | "./wireshark"] 36 | -------------------------------------------------------------------------------- /build-support/clang_format_exclusions.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | *.pb.h 21 | *.pb.cc 22 | -------------------------------------------------------------------------------- /build-support/copy-deps-versionfile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | for dir in apk deb rpm; do 26 | mkdir -p pkg/$dir/.build 27 | cp $ROOT_DIR/dependencies.yaml pkg/$dir/.build 28 | cp $ROOT_DIR/build-support/dep-version.py pkg/$dir/.build 29 | done 30 | -------------------------------------------------------------------------------- /build-support/dep-version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | import yaml, sys 22 | 23 | deps = yaml.safe_load(open('dependencies.yaml')) 24 | print(deps[sys.argv[1]]) 25 | -------------------------------------------------------------------------------- /build-support/docker-format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | ROOT_DIR=$(git rev-parse --show-toplevel) 22 | cd $ROOT_DIR/build-support 23 | 24 | IMAGE_NAME=apachepulsar/cpp-client-format 25 | docker image inspect apachepulsar/cpp-client-format 1>/dev/null 2>&1 26 | OK=$? 27 | set -e 28 | if [[ $OK -ne 0 ]]; then 29 | echo "The image $IMAGE_NAME doesn't exist, build it" 30 | docker build -t $IMAGE_NAME -f ./Dockerfile.format . 31 | fi 32 | docker run -v $ROOT_DIR:/app --rm $IMAGE_NAME 33 | -------------------------------------------------------------------------------- /build-support/gen-pulsar-version-macro.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | import re, sys, os 22 | 23 | dirname = os.path.abspath(os.path.dirname(sys.argv[0])) 24 | version_file = os.path.join(dirname, "..", "version.txt") 25 | version = open(version_file).read() 26 | m = re.search(r'^(\d+)\.(\d+)\.(\d+)', version) 27 | 28 | version_macro = 0 29 | for i in range(3): 30 | version_macro += int(m.group(3 - i)) * (1000 ** i) 31 | print(version_macro) 32 | -------------------------------------------------------------------------------- /build-support/generate-source-archive.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | ROOT_DIR=$(git rev-parse --show-toplevel) 21 | 22 | VERSION=$(cat ${ROOT_DIR}/version.txt) 23 | 24 | NAME=apache-pulsar-client-cpp-$VERSION 25 | 26 | OUT_DIR=${1:-.} 27 | 28 | git archive --format=tar.gz --prefix ${NAME}/ -o ${OUT_DIR}/${NAME}.tar.gz HEAD 29 | -------------------------------------------------------------------------------- /build-support/merge_archives.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | 23 | MERGED_LIBRARY=$1 24 | shift 25 | ITEMS=$* 26 | 27 | echo "MERGED_LIBRARY=$MERGED_LIBRARY" 28 | 29 | rm -rf merged-library 30 | mkdir -p merged-library 31 | 32 | cd merged-library 33 | 34 | LIBS="" 35 | 36 | for ITEM in $ITEMS; do 37 | LIB_NAME=$(basename $ITEM .a) 38 | echo "Packing $LIB_NAME -- '$ITEM'" 39 | 40 | mkdir $LIB_NAME 41 | cd $LIB_NAME 42 | ar -x $ITEM 43 | 44 | LIBS="$LIBS $LIB_NAME/*.o" 45 | cd .. 46 | done 47 | 48 | ar -qc $MERGED_LIBRARY $LIBS 49 | 50 | 51 | -------------------------------------------------------------------------------- /build-support/merge_archives_vcpkg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | cd `dirname $0` 23 | 24 | if [[ $# -lt 1 ]]; then 25 | echo "Usage: $0 " 26 | exit 1 27 | fi 28 | 29 | CMAKE_BUILD_DIRECTORY=$1 30 | if [[ $VCPKG_TRIPLET ]]; then 31 | ./merge_archives.sh $CMAKE_BUILD_DIRECTORY/libpulsarwithdeps.a \ 32 | $CMAKE_BUILD_DIRECTORY/lib/libpulsar.a \ 33 | $(find "$CMAKE_BUILD_DIRECTORY/vcpkg_installed/$VCPKG_TRIPLET" -name "*.a" | grep -v debug) 34 | else 35 | ./merge_archives.sh $CMAKE_BUILD_DIRECTORY/libpulsarwithdeps.a \ 36 | $CMAKE_BUILD_DIRECTORY/lib/libpulsar.a \ 37 | $(find "$CMAKE_BUILD_DIRECTORY/vcpkg_installed" -name "*.a" | grep -v debug) 38 | fi 39 | -------------------------------------------------------------------------------- /build-support/run_clang_tidy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | cd `dirname $0`/.. 23 | 24 | FILES=$(find $PWD/include $PWD/lib $PWD/tests $PWD/examples -name "*.h" -o -name "*.cc" \ 25 | | grep -v "lib\/c\/" | grep -v "lib\/checksum\/" | grep -v "lib\/lz4\/" \ 26 | | grep -v "include\/pulsar\/c\/" | grep -v "tests\/c\/") 27 | 28 | rm -f files.txt 29 | for FILE in $FILES; do 30 | echo $FILE >> files.txt 31 | done 32 | # run-clang-tidy from older version of LLVM requires python but not python3 as the env, so we cannot run it directly 33 | SCRIPT=$(which run-clang-tidy) 34 | set +e 35 | nproc 36 | if [[ $? == 0 ]]; then 37 | python3 $SCRIPT -p build -j$(nproc) $(cat files.txt) 38 | else 39 | python3 $SCRIPT -p build -j8 $(cat files.txt) 40 | fi 41 | rm -f files.txt 42 | -------------------------------------------------------------------------------- /build-support/setup-test-service-container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | if [ $# -ne 2 ]; then 24 | echo "Usage: $0 \$CONTAINER_ID \$START_TEST_SERVICE_INSIDE_CONTAINER" 25 | exit 1 26 | fi 27 | 28 | CONTAINER_ID=$1 29 | START_TEST_SERVICE_INSIDE_CONTAINER=$2 30 | 31 | echo $CONTAINER_ID >> .tests-container-id.txt 32 | 33 | docker cp test-conf $CONTAINER_ID:/pulsar/test-conf 34 | docker cp build-support/$START_TEST_SERVICE_INSIDE_CONTAINER $CONTAINER_ID:$START_TEST_SERVICE_INSIDE_CONTAINER 35 | 36 | docker exec -i $CONTAINER_ID /$START_TEST_SERVICE_INSIDE_CONTAINER 37 | -------------------------------------------------------------------------------- /build-support/sign-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | 23 | FILES=$* 24 | 25 | for FILE in $FILES 26 | do 27 | echo "Signing $FILE" 28 | gpg --armor --output $FILE.asc --detach-sig $FILE 29 | 30 | # SHA-512 signature 31 | shasum -a 512 $FILE > $FILE.sha512 32 | done 33 | -------------------------------------------------------------------------------- /dependencies.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Note: GCC 4.8 is incompatible with Boost >= 1.84 for the missed std::align 21 | boost: 1.83.0 22 | cmake: 3.28.3 23 | protobuf: 3.20.0 24 | zlib: 1.3.1 25 | zstd: 1.5.5 26 | snappy: 1.1.10 27 | openssl: 1.1.1w 28 | curl: 8.6.0 29 | -------------------------------------------------------------------------------- /examples/SampleConsumer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include 22 | 23 | #include "lib/LogUtils.h" 24 | 25 | DECLARE_LOG_OBJECT() 26 | 27 | using namespace pulsar; 28 | 29 | int main() { 30 | Client client("pulsar://localhost:6650"); 31 | 32 | Consumer consumer; 33 | Result result = client.subscribe("persistent://public/default/my-topic", "consumer-1", consumer); 34 | if (result != ResultOk) { 35 | LOG_ERROR("Failed to subscribe: " << result); 36 | return -1; 37 | } 38 | 39 | Message msg; 40 | 41 | while (true) { 42 | consumer.receive(msg); 43 | LOG_INFO("Received: " << msg << " with payload '" << msg.getDataAsString() << "'"); 44 | 45 | consumer.acknowledge(msg); 46 | } 47 | 48 | client.close(); 49 | } 50 | -------------------------------------------------------------------------------- /examples/SampleFileLogger.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | using namespace pulsar; 22 | 23 | int main(int argc, char* argv[]) { 24 | ClientConfiguration clientConf; 25 | // The logs whose level is >= INFO will be written to pulsar-cpp-client.log 26 | clientConf.setLogger(new FileLoggerFactory(Logger::Level::LEVEL_INFO, "pulsar-cpp-client.log")); 27 | 28 | Client client("pulsar://localhost:6650", clientConf); 29 | Producer producer; 30 | client.createProducer("my-topic", producer); // just to create some logs 31 | client.close(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /examples/SampleProducer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include 22 | 23 | #include "lib/LogUtils.h" 24 | 25 | DECLARE_LOG_OBJECT() 26 | 27 | using namespace pulsar; 28 | 29 | int main() { 30 | Client client("pulsar://localhost:6650"); 31 | 32 | Producer producer; 33 | Result result = client.createProducer("persistent://public/default/my-topic", producer); 34 | if (result != ResultOk) { 35 | LOG_ERROR("Error creating producer: " << result); 36 | return -1; 37 | } 38 | 39 | // Send synchronously 40 | Message msg = MessageBuilder().setContent("content").build(); 41 | Result res = producer.send(msg); 42 | LOG_INFO("Message sent: " << res); 43 | 44 | client.close(); 45 | } 46 | -------------------------------------------------------------------------------- /include/pulsar/CompressionType.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_COMPRESSIONTYPE_H_ 20 | #define PULSAR_COMPRESSIONTYPE_H_ 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | enum CompressionType : std::uint8_t 26 | { 27 | CompressionNone = 0, 28 | CompressionLZ4 = 1, 29 | CompressionZLib = 2, 30 | CompressionZSTD = 3, 31 | CompressionSNAPPY = 4 32 | }; 33 | } 34 | 35 | #endif /* PULSAR_COMPRESSIONTYPE_H_ */ 36 | -------------------------------------------------------------------------------- /include/pulsar/ConsumerCryptoFailureAction.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef CONSUMERCRYPTOFAILUREACTION_H_ 20 | #define CONSUMERCRYPTOFAILUREACTION_H_ 21 | 22 | namespace pulsar { 23 | 24 | enum class ConsumerCryptoFailureAction 25 | { 26 | FAIL, // This is the default option to fail consume until crypto succeeds 27 | DISCARD, // Message is silently acknowledged and not delivered to the application 28 | CONSUME // Deliver the encrypted message to the application. It's the application's 29 | // responsibility to decrypt the message. If message is also compressed, 30 | // decompression will fail. If message contain batch messages, client will 31 | // not be able to retrieve individual messages in the batch 32 | }; 33 | 34 | } /* namespace pulsar */ 35 | 36 | #endif /* CONSUMERCRYPTOFAILUREACTION_H_ */ 37 | -------------------------------------------------------------------------------- /include/pulsar/DeprecatedException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef DEPRECATED_EXCEPTION_HPP_ 20 | #define DEPRECATED_EXCEPTION_HPP_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace pulsar { 28 | class PULSAR_PUBLIC DeprecatedException : public std::runtime_error { 29 | public: 30 | explicit DeprecatedException(const std::string& __arg); 31 | 32 | private: 33 | static const std::string message_prefix; 34 | }; 35 | } // namespace pulsar 36 | 37 | #endif // DEPRECATED_EXCEPTION_HPP_ 38 | -------------------------------------------------------------------------------- /include/pulsar/InitialPosition.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_CPP_INITIAL_POSITION_H 20 | #define PULSAR_CPP_INITIAL_POSITION_H 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | enum InitialPosition : uint8_t 26 | { 27 | InitialPositionLatest, 28 | InitialPositionEarliest 29 | }; 30 | } 31 | 32 | #endif // PULSAR_CPP_INITIAL_POSITION_H 33 | -------------------------------------------------------------------------------- /include/pulsar/MessageBatch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef LIB_MESSAGE_BATCH_H 21 | #define LIB_MESSAGE_BATCH_H 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace pulsar { 28 | 29 | class PULSAR_PUBLIC MessageBatch { 30 | public: 31 | MessageBatch(); 32 | 33 | MessageBatch& withMessageId(const MessageId& messageId); 34 | 35 | MessageBatch& parseFrom(const std::string& payload, uint32_t batchSize); 36 | 37 | MessageBatch& parseFrom(const SharedBuffer& payload, uint32_t batchSize); 38 | 39 | const std::vector& messages(); 40 | 41 | private: 42 | typedef std::shared_ptr MessageImplPtr; 43 | MessageImplPtr impl_; 44 | Message batchMessage_; 45 | 46 | std::vector batch_; 47 | }; 48 | } // namespace pulsar 49 | #endif // LIB_MESSAGE_BATCH_H 50 | -------------------------------------------------------------------------------- /include/pulsar/ProducerCryptoFailureAction.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PRODUCERCRYPTOFAILUREACTION_H_ 20 | #define PRODUCERCRYPTOFAILUREACTION_H_ 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | enum class ProducerCryptoFailureAction : uint8_t 27 | { 28 | FAIL, // This is the default option to fail send if crypto operation fails 29 | SEND // Ignore crypto failure and proceed with sending unencrypted messages 30 | }; 31 | 32 | } /* namespace pulsar */ 33 | 34 | #endif /* PRODUCERCRYPTOFAILUREACTION_H_ */ 35 | -------------------------------------------------------------------------------- /include/pulsar/ProtobufNativeSchema.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | /** 27 | * Create a protobuf native schema using a descriptor. 28 | * 29 | * @param descriptor the Descriptor object of the target class 30 | * @return the protobuf native schema 31 | * @throw std::invalid_argument if descriptor is nullptr 32 | */ 33 | PULSAR_PUBLIC SchemaInfo createProtobufNativeSchema(const google::protobuf::Descriptor* descriptor); 34 | 35 | } // namespace pulsar 36 | -------------------------------------------------------------------------------- /include/pulsar/RegexSubscriptionMode.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_CPP_REGEX_SUB_MODE_H 20 | #define PULSAR_CPP_REGEX_SUB_MODE_H 21 | 22 | namespace pulsar { 23 | enum RegexSubscriptionMode 24 | { 25 | /** 26 | * Only subscribe to persistent topics. 27 | */ 28 | PersistentOnly = 0, 29 | 30 | /** 31 | * Only subscribe to non-persistent topics. 32 | */ 33 | NonPersistentOnly = 1, 34 | 35 | /** 36 | * Subscribe to both persistent and non-persistent topics. 37 | */ 38 | AllTopics = 2 39 | }; 40 | } 41 | 42 | #endif // PULSAR_CPP_REGEX_SUB_MODE_H 43 | -------------------------------------------------------------------------------- /include/pulsar/TableViewConfiguration.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_TABLEVIEW_CONFIGURATION_H_ 20 | #define PULSAR_TABLEVIEW_CONFIGURATION_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace pulsar { 26 | 27 | struct TableViewConfiguration { 28 | // Declare the schema of the data that this table view will be accepting. 29 | // The schema will be checked against the schema of the topic, and the 30 | // table view creation will fail if it's not compatible. 31 | SchemaInfo schemaInfo; 32 | // The name of the subscription to the topic. Default value is reader-{random string}. 33 | std::string subscriptionName; 34 | }; 35 | } // namespace pulsar 36 | #endif /* PULSAR_TABLEVIEW_CONFIGURATION_H_ */ 37 | -------------------------------------------------------------------------------- /include/pulsar/TopicMetadata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef TOPIC_METADATA_HPP_ 20 | #define TOPIC_METADATA_HPP_ 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | /** 26 | * Metadata of a topic that can be used for message routing. 27 | */ 28 | class PULSAR_PUBLIC TopicMetadata { 29 | public: 30 | virtual ~TopicMetadata() {} 31 | 32 | /** 33 | * @return the number of partitions 34 | */ 35 | virtual int getNumPartitions() const = 0; 36 | }; 37 | } // namespace pulsar 38 | 39 | #endif /* TOPIC_METADATA_HPP_ */ 40 | -------------------------------------------------------------------------------- /include/pulsar/TypedMessage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | 25 | namespace pulsar { 26 | 27 | template 28 | class TypedMessage : public Message { 29 | public: 30 | using Decoder = std::function; 31 | 32 | TypedMessage() = default; 33 | 34 | TypedMessage( 35 | const Message& message, Decoder decoder = [](const char*, std::size_t) { return T{}; }) 36 | : Message(message), decoder_(decoder) {} 37 | 38 | T getValue() const { return decoder_(static_cast(getData()), getLength()); } 39 | 40 | TypedMessage& setDecoder(Decoder decoder) { 41 | decoder_ = decoder; 42 | return *this; 43 | } 44 | 45 | private: 46 | Decoder decoder_; 47 | }; 48 | 49 | } // namespace pulsar 50 | -------------------------------------------------------------------------------- /include/pulsar/c/message_router.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | typedef struct _pulsar_topic_metadata pulsar_topic_metadata_t; 30 | 31 | typedef int (*pulsar_message_router)(pulsar_message_t *msg, pulsar_topic_metadata_t *topicMetadata, 32 | void *ctx); 33 | 34 | PULSAR_PUBLIC int pulsar_topic_metadata_get_num_partitions(pulsar_topic_metadata_t *topicMetadata); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif -------------------------------------------------------------------------------- /include/pulsar/c/string_list.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct _pulsar_string_list pulsar_string_list_t; 29 | 30 | PULSAR_PUBLIC pulsar_string_list_t *pulsar_string_list_create(); 31 | PULSAR_PUBLIC void pulsar_string_list_free(pulsar_string_list_t *list); 32 | 33 | PULSAR_PUBLIC int pulsar_string_list_size(pulsar_string_list_t *list); 34 | 35 | PULSAR_PUBLIC void pulsar_string_list_append(pulsar_string_list_t *list, const char *item); 36 | 37 | PULSAR_PUBLIC const char *pulsar_string_list_get(pulsar_string_list_t *map, int index); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif -------------------------------------------------------------------------------- /include/pulsar/c/string_map.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct _pulsar_string_map pulsar_string_map_t; 29 | 30 | PULSAR_PUBLIC pulsar_string_map_t *pulsar_string_map_create(); 31 | PULSAR_PUBLIC void pulsar_string_map_free(pulsar_string_map_t *map); 32 | 33 | PULSAR_PUBLIC int pulsar_string_map_size(pulsar_string_map_t *map); 34 | 35 | PULSAR_PUBLIC void pulsar_string_map_put(pulsar_string_map_t *map, const char *key, const char *value); 36 | 37 | PULSAR_PUBLIC const char *pulsar_string_map_get(pulsar_string_map_t *map, const char *key); 38 | 39 | PULSAR_PUBLIC const char *pulsar_string_map_get_key(pulsar_string_map_t *map, int idx); 40 | PULSAR_PUBLIC const char *pulsar_string_map_get_value(pulsar_string_map_t *map, int idx); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif -------------------------------------------------------------------------------- /include/pulsar/c/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | -------------------------------------------------------------------------------- /include/pulsar/defines.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_DEFINES_H_ 20 | #define PULSAR_DEFINES_H_ 21 | 22 | #ifdef PULSAR_STATIC 23 | 24 | #define PULSAR_PUBLIC 25 | 26 | #else 27 | 28 | #ifdef _WIN32 29 | 30 | #ifdef BUILDING_PULSAR 31 | #define PULSAR_PUBLIC __declspec(dllexport) 32 | #else 33 | #define PULSAR_PUBLIC __declspec(dllimport) 34 | #endif /*BUILDING_PULSAR*/ 35 | 36 | #else 37 | 38 | #define PULSAR_PUBLIC __attribute__((visibility("default"))) 39 | 40 | #endif /*_WIN32*/ 41 | 42 | #endif /*PULSAR_STATIC*/ 43 | 44 | #endif /* PULSAR_DEFINES_H_ */ 45 | -------------------------------------------------------------------------------- /lib/AsioDefines.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | // This header defines common macros to use Asio or Boost.Asio. 20 | #pragma once 21 | 22 | #ifdef USE_ASIO 23 | #define ASIO ::asio 24 | #define ASIO_ERROR asio::error_code 25 | #define ASIO_SUCCESS (ASIO_ERROR{}) 26 | #define ASIO_SYSTEM_ERROR asio::system_error 27 | #else 28 | #define ASIO boost::asio 29 | #define ASIO_ERROR boost::system::error_code 30 | #define ASIO_SUCCESS boost::system::errc::make_error_code(boost::system::errc::success) 31 | #define ASIO_SYSTEM_ERROR boost::system::system_error 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/AsioTimer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #ifdef USE_ASIO 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #include 28 | 29 | #include "AsioDefines.h" 30 | 31 | using DeadlineTimerPtr = std::shared_ptr; 32 | -------------------------------------------------------------------------------- /lib/Backoff.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef _PULSAR_BACKOFF_HEADER_ 20 | #define _PULSAR_BACKOFF_HEADER_ 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "TimeUtils.h" 27 | 28 | namespace pulsar { 29 | 30 | class PULSAR_PUBLIC Backoff { 31 | public: 32 | Backoff(const TimeDuration&, const TimeDuration&, const TimeDuration&); 33 | TimeDuration next(); 34 | void reset(); 35 | 36 | private: 37 | const TimeDuration initial_; 38 | const TimeDuration max_; 39 | TimeDuration next_; 40 | TimeDuration mandatoryStop_; 41 | decltype(std::chrono::high_resolution_clock::now()) firstBackoffTime_; 42 | std::mt19937 rng_; 43 | bool mandatoryStopMade_ = false; 44 | 45 | friend class PulsarFriend; 46 | }; 47 | } // namespace pulsar 48 | 49 | #endif //_PULSAR_BACKOFF_HEADER_ 50 | -------------------------------------------------------------------------------- /lib/BatchReceivePolicyImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | namespace pulsar { 22 | 23 | struct BatchReceivePolicyImpl { 24 | int maxNumMessage; 25 | long maxNumBytes; 26 | long timeoutMs; 27 | }; 28 | 29 | } // namespace pulsar 30 | -------------------------------------------------------------------------------- /lib/BoostHash.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "BoostHash.h" 20 | 21 | namespace pulsar { 22 | 23 | BoostHash::BoostHash() : hash() {} 24 | 25 | int32_t BoostHash::makeHash(const std::string& key) { 26 | return static_cast(hash(key) & std::numeric_limits::max()); 27 | } 28 | 29 | } // namespace pulsar 30 | -------------------------------------------------------------------------------- /lib/BoostHash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef BOOST_HASH_HPP_ 20 | #define BOOST_HASH_HPP_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "Hash.h" 29 | 30 | namespace pulsar { 31 | class PULSAR_PUBLIC BoostHash : public Hash { 32 | public: 33 | BoostHash(); 34 | int32_t makeHash(const std::string &key); 35 | 36 | private: 37 | boost::hash hash; 38 | }; 39 | } // namespace pulsar 40 | 41 | #endif /* BOOST_HASH_HPP_ */ 42 | -------------------------------------------------------------------------------- /lib/CompressionCodecLZ4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef LIB_COMPRESSIONCODECLZ4_H_ 20 | #define LIB_COMPRESSIONCODECLZ4_H_ 21 | 22 | #include "CompressionCodec.h" 23 | 24 | namespace pulsar { 25 | 26 | class CompressionCodecLZ4 : public CompressionCodec { 27 | public: 28 | SharedBuffer encode(const SharedBuffer& raw); 29 | 30 | bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded); 31 | }; 32 | } // namespace pulsar 33 | #endif /* LIB_COMPRESSIONCODECLZ4_H_ */ 34 | -------------------------------------------------------------------------------- /lib/CompressionCodecSnappy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include "CompressionCodec.h" 22 | 23 | namespace pulsar { 24 | 25 | class PULSAR_PUBLIC CompressionCodecSnappy : public CompressionCodec { 26 | public: 27 | SharedBuffer encode(const SharedBuffer& raw); 28 | 29 | bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded); 30 | }; 31 | } // namespace pulsar 32 | -------------------------------------------------------------------------------- /lib/CompressionCodecZLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef LIB_COMPRESSIONCODECZLIB_H_ 20 | #define LIB_COMPRESSIONCODECZLIB_H_ 21 | 22 | #include "CompressionCodec.h" 23 | 24 | // Make symbol visible to unit tests 25 | 26 | namespace pulsar { 27 | 28 | class PULSAR_PUBLIC CompressionCodecZLib : public CompressionCodec { 29 | public: 30 | SharedBuffer encode(const SharedBuffer& raw); 31 | 32 | bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded); 33 | }; 34 | 35 | } // namespace pulsar 36 | 37 | #endif /* LIB_COMPRESSIONCODECZLIB_H_ */ 38 | -------------------------------------------------------------------------------- /lib/CompressionCodecZstd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include "CompressionCodec.h" 22 | 23 | namespace pulsar { 24 | 25 | class CompressionCodecZstd : public CompressionCodec { 26 | public: 27 | SharedBuffer encode(const SharedBuffer& raw); 28 | 29 | bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded); 30 | }; 31 | } // namespace pulsar 32 | -------------------------------------------------------------------------------- /lib/ConsoleLoggerFactory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | 22 | #include "ConsoleLoggerFactoryImpl.h" 23 | 24 | namespace pulsar { 25 | 26 | ConsoleLoggerFactory::ConsoleLoggerFactory(Logger::Level level) 27 | : impl_(new ConsoleLoggerFactoryImpl(level)) {} 28 | 29 | ConsoleLoggerFactory::~ConsoleLoggerFactory() {} 30 | 31 | Logger* ConsoleLoggerFactory::getLogger(const std::string& fileName) { return impl_->getLogger(fileName); } 32 | 33 | } // namespace pulsar 34 | -------------------------------------------------------------------------------- /lib/ConsoleLoggerFactoryImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include "SimpleLogger.h" 25 | 26 | namespace pulsar { 27 | 28 | class ConsoleLoggerFactoryImpl { 29 | public: 30 | ConsoleLoggerFactoryImpl(Logger::Level level) : level_(level) {} 31 | 32 | Logger* getLogger(const std::string& fileName) { return new SimpleLogger(std::cout, fileName, level_); } 33 | 34 | private: 35 | Logger::Level level_; 36 | }; 37 | 38 | } // namespace pulsar 39 | -------------------------------------------------------------------------------- /lib/DeadLetterPolicyImpl.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "DeadLetterPolicyImpl.h" 21 | 22 | #include 23 | 24 | using namespace pulsar; 25 | 26 | namespace pulsar { 27 | 28 | DeadLetterPolicy::DeadLetterPolicy() : impl_(std::make_shared()) {} 29 | 30 | const std::string& DeadLetterPolicy::getDeadLetterTopic() const { return impl_->deadLetterTopic; } 31 | 32 | int DeadLetterPolicy::getMaxRedeliverCount() const { return impl_->maxRedeliverCount; } 33 | 34 | const std::string& DeadLetterPolicy::getInitialSubscriptionName() const { 35 | return impl_->initialSubscriptionName; 36 | } 37 | 38 | DeadLetterPolicy::DeadLetterPolicy(const DeadLetterPolicy::DeadLetterPolicyImplPtr& impl) : impl_(impl) {} 39 | 40 | } // namespace pulsar 41 | -------------------------------------------------------------------------------- /lib/DeadLetterPolicyImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | struct DeadLetterPolicyImpl { 27 | std::string deadLetterTopic; 28 | int maxRedeliverCount{INT_MAX}; 29 | std::string initialSubscriptionName; 30 | }; 31 | 32 | } // namespace pulsar 33 | -------------------------------------------------------------------------------- /lib/DeprecatedException.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | namespace pulsar { 22 | const std::string DeprecatedException::message_prefix = "Deprecated: "; 23 | 24 | DeprecatedException::DeprecatedException(const std::string& __arg) 25 | : std::runtime_error(message_prefix + __arg) {} 26 | } // namespace pulsar 27 | -------------------------------------------------------------------------------- /lib/EncryptionKeyInfo.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | 22 | #include "EncryptionKeyInfoImpl.h" 23 | 24 | namespace pulsar { 25 | 26 | EncryptionKeyInfo::EncryptionKeyInfo() : impl_(new EncryptionKeyInfoImpl()) {} 27 | 28 | EncryptionKeyInfo::EncryptionKeyInfo(const EncryptionKeyInfoImplPtr& impl) : impl_(impl) {} 29 | 30 | std::string& EncryptionKeyInfo::getKey() { return impl_->getKey(); } 31 | 32 | void EncryptionKeyInfo::setKey(const std::string& key) { impl_->setKey(key); } 33 | 34 | EncryptionKeyInfo::StringMap& EncryptionKeyInfo::getMetadata() { return impl_->getMetadata(); } 35 | 36 | void EncryptionKeyInfo::setMetadata(StringMap& metadata) { impl_->setMetadata(metadata); } 37 | 38 | }; /* namespace pulsar */ 39 | -------------------------------------------------------------------------------- /lib/EncryptionKeyInfoImpl.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "EncryptionKeyInfoImpl.h" 21 | 22 | namespace pulsar { 23 | 24 | EncryptionKeyInfoImpl::EncryptionKeyInfoImpl(std::string key, StringMap& metadata) 25 | : metadata_(metadata), key_(std::move(key)) {} 26 | 27 | std::string& EncryptionKeyInfoImpl::getKey() { return key_; } 28 | 29 | void EncryptionKeyInfoImpl::setKey(const std::string& key) { key_ = key; } 30 | 31 | EncryptionKeyInfoImpl::StringMap& EncryptionKeyInfoImpl::getMetadata() { return metadata_; } 32 | 33 | void EncryptionKeyInfoImpl::setMetadata(StringMap& metadata) { metadata_ = metadata; } 34 | 35 | }; /* namespace pulsar */ 36 | -------------------------------------------------------------------------------- /lib/EncryptionKeyInfoImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef LIB_ENCRYPTIONKEYINFOIMPL_H_ 20 | #define LIB_ENCRYPTIONKEYINFOIMPL_H_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace pulsar { 28 | 29 | class PULSAR_PUBLIC EncryptionKeyInfoImpl { 30 | public: 31 | using StringMap = std::map; 32 | 33 | EncryptionKeyInfoImpl() = default; 34 | 35 | EncryptionKeyInfoImpl(std::string key, StringMap& metadata); 36 | 37 | std::string& getKey(); 38 | 39 | void setKey(const std::string& key); 40 | 41 | StringMap& getMetadata(void); 42 | 43 | void setMetadata(StringMap& metadata); 44 | 45 | private: 46 | StringMap metadata_; 47 | std::string key_; 48 | }; 49 | 50 | } /* namespace pulsar */ 51 | 52 | #endif /* LIB_ENCRYPTIONKEYINFOIMPL_H_ */ 53 | -------------------------------------------------------------------------------- /lib/FileLoggerFactory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "FileLoggerFactoryImpl.h" 22 | 23 | namespace pulsar { 24 | 25 | FileLoggerFactory::FileLoggerFactory(Logger::Level level, const std::string& logFilePath) 26 | : impl_(new FileLoggerFactoryImpl(level, logFilePath)) {} 27 | 28 | FileLoggerFactory::~FileLoggerFactory() {} 29 | 30 | Logger* FileLoggerFactory::getLogger(const std::string& filename) { return impl_->getLogger(filename); } 31 | 32 | } // namespace pulsar 33 | -------------------------------------------------------------------------------- /lib/FileLoggerFactoryImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "SimpleLogger.h" 28 | 29 | namespace pulsar { 30 | 31 | class FileLoggerFactoryImpl { 32 | public: 33 | FileLoggerFactoryImpl(Logger::Level level, const std::string& logFilePath) 34 | : level_(level), os_(logFilePath, std::ios_base::out | std::ios_base::app) {} 35 | 36 | ~FileLoggerFactoryImpl() { os_.close(); } 37 | 38 | Logger* getLogger(const std::string& filename) { return new SimpleLogger(os_, filename, level_); } 39 | 40 | private: 41 | const Logger::Level level_; 42 | std::ofstream os_; 43 | }; 44 | 45 | } // namespace pulsar 46 | -------------------------------------------------------------------------------- /lib/Hash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef HASH_HPP_ 20 | #define HASH_HPP_ 21 | 22 | #include 23 | #include 24 | 25 | namespace pulsar { 26 | class Hash { 27 | public: 28 | virtual ~Hash() {} 29 | 30 | /** 31 | * Generate the hash of a given String 32 | * 33 | * @return The hash of {@param key}, which is non-negative integer. 34 | */ 35 | virtual int32_t makeHash(const std::string& key) = 0; 36 | }; 37 | } // namespace pulsar 38 | 39 | #endif /* HASH_HPP_ */ 40 | -------------------------------------------------------------------------------- /lib/Int64SerDes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | // for ntohl 24 | #ifdef USE_ASIO 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | namespace pulsar { 31 | 32 | inline int64_t fromBigEndianBytes(const std::string& bytes) { 33 | const auto int32Array = reinterpret_cast(bytes.c_str()); 34 | return (static_cast(ntohl(int32Array[0])) << 32) + static_cast(ntohl(int32Array[1])); 35 | } 36 | 37 | inline std::string toBigEndianBytes(int64_t value) { 38 | union { 39 | char bytes[8]; 40 | uint32_t int32Array[2]; 41 | } u; 42 | u.int32Array[0] = htonl(static_cast(value >> 32)); 43 | u.int32Array[1] = htonl(static_cast(value & 0xFFFFFFFF)); 44 | return {u.bytes, 8}; 45 | } 46 | 47 | } // namespace pulsar 48 | -------------------------------------------------------------------------------- /lib/JavaStringHash.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "JavaStringHash.h" 20 | 21 | #include 22 | 23 | namespace pulsar { 24 | 25 | JavaStringHash::JavaStringHash() {} 26 | 27 | int32_t JavaStringHash::makeHash(const std::string& key) { 28 | uint64_t len = key.length(); 29 | const char* val = key.c_str(); 30 | uint32_t hash = 0; 31 | 32 | for (int i = 0; i < len; i++) { 33 | hash = 31 * hash + val[i]; 34 | } 35 | 36 | hash &= std::numeric_limits::max(); 37 | 38 | return hash; 39 | } 40 | 41 | } // namespace pulsar 42 | -------------------------------------------------------------------------------- /lib/JavaStringHash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef JAVA_DEFAULT_HASH_HPP_ 20 | #define JAVA_DEFAULT_HASH_HPP_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include "Hash.h" 28 | 29 | namespace pulsar { 30 | class PULSAR_PUBLIC JavaStringHash : public Hash { 31 | public: 32 | JavaStringHash(); 33 | int32_t makeHash(const std::string &key); 34 | }; 35 | } // namespace pulsar 36 | 37 | #endif /* JAVA_DEFAULT_HASH_HPP_ */ 38 | -------------------------------------------------------------------------------- /lib/JsonUtils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace pulsar { 26 | 27 | template 28 | inline std::string toJson(const Ptree& pt) { 29 | std::ostringstream oss; 30 | boost::property_tree::write_json(oss, pt, false); 31 | // For Boost < 1.86, boost::property_tree will write a endline at the end 32 | #if BOOST_VERSION < 108600 33 | auto s = oss.str(); 34 | s.pop_back(); 35 | return s; 36 | #else 37 | return oss.str(); 38 | #endif 39 | } 40 | 41 | } // namespace pulsar 42 | -------------------------------------------------------------------------------- /lib/KeySharedPolicyImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace pulsar { 24 | 25 | struct KeySharedPolicyImpl { 26 | bool allowOutOfOrderDelivery; 27 | KeySharedMode keySharedMode; 28 | StickyRanges ranges; 29 | 30 | KeySharedPolicyImpl() : allowOutOfOrderDelivery(false), keySharedMode(AUTO_SPLIT) {} 31 | }; 32 | } // namespace pulsar 33 | -------------------------------------------------------------------------------- /lib/KeyValue.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "KeyValueImpl.h" 22 | 23 | namespace pulsar { 24 | 25 | KeyValue::KeyValue(KeyValueImplPtr impl) : impl_(std::move(impl)) {} 26 | 27 | KeyValue::KeyValue(std::string &&key, std::string &&value) 28 | : impl_(std::make_shared(std::move(key), std::move(value))) {} 29 | 30 | std::string KeyValue::getKey() const { return impl_->getKey(); } 31 | 32 | const void *KeyValue::getValue() const { return impl_->getValue(); } 33 | 34 | size_t KeyValue::getValueLength() const { return impl_->getValueLength(); } 35 | 36 | std::string KeyValue::getValueAsString() const { return impl_->getValueAsString(); } 37 | 38 | } // namespace pulsar 39 | -------------------------------------------------------------------------------- /lib/Latch.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "Latch.h" 20 | 21 | namespace pulsar { 22 | 23 | Latch::Latch(int count) : state_(std::make_shared()) { state_->count = count; } 24 | 25 | void Latch::countdown() { 26 | Lock lock(state_->mutex); 27 | 28 | state_->count--; 29 | 30 | if (state_->count == 0) { 31 | state_->condition.notify_all(); 32 | } 33 | } 34 | 35 | int Latch::getCount() { 36 | Lock lock(state_->mutex); 37 | 38 | return state_->count; 39 | } 40 | 41 | void Latch::wait() { 42 | Lock lock(state_->mutex); 43 | 44 | state_->condition.wait(lock, CountIsZero(state_->count)); 45 | } 46 | 47 | } /* namespace pulsar */ 48 | -------------------------------------------------------------------------------- /lib/MemoryLimitController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace pulsar { 28 | 29 | class MemoryLimitController { 30 | public: 31 | explicit MemoryLimitController(uint64_t memoryLimit); 32 | bool tryReserveMemory(uint64_t size); 33 | bool reserveMemory(uint64_t size); 34 | void releaseMemory(uint64_t size); 35 | uint64_t currentUsage() const; 36 | 37 | void close(); 38 | 39 | private: 40 | const uint64_t memoryLimit_; 41 | std::atomic currentUsage_; 42 | std::mutex mutex_; 43 | std::condition_variable condition_; 44 | bool isClosed_ = false; 45 | }; 46 | 47 | } // namespace pulsar 48 | -------------------------------------------------------------------------------- /lib/MessageIdUtil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | namespace internal { 27 | template 28 | static int compare(T lhs, T rhs) { 29 | return (lhs < rhs) ? -1 : ((lhs == rhs) ? 0 : 1); 30 | } 31 | } // namespace internal 32 | 33 | inline int compareLedgerAndEntryId(const MessageId& lhs, const MessageId& rhs) { 34 | auto result = internal::compare(lhs.ledgerId(), rhs.ledgerId()); 35 | if (result != 0) { 36 | return result; 37 | } 38 | return internal::compare(lhs.entryId(), rhs.entryId()); 39 | } 40 | 41 | inline MessageId discardBatch(const MessageId& messageId) { 42 | return MessageIdBuilder::from(messageId).batchIndex(-1).batchSize(0).build(); 43 | } 44 | 45 | } // namespace pulsar 46 | -------------------------------------------------------------------------------- /lib/MessageRouterBase.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "MessageRouterBase.h" 20 | 21 | #include "BoostHash.h" 22 | #include "JavaStringHash.h" 23 | #include "Murmur3_32Hash.h" 24 | 25 | namespace pulsar { 26 | MessageRouterBase::MessageRouterBase(ProducerConfiguration::HashingScheme hashingScheme) { 27 | switch (hashingScheme) { 28 | case ProducerConfiguration::BoostHash: 29 | hash = HashPtr(new BoostHash()); 30 | break; 31 | case ProducerConfiguration::JavaStringHash: 32 | hash = HashPtr(new JavaStringHash()); 33 | break; 34 | case ProducerConfiguration::Murmur3_32Hash: 35 | default: 36 | hash = HashPtr(new Murmur3_32Hash()); 37 | break; 38 | } 39 | } 40 | } // namespace pulsar 41 | -------------------------------------------------------------------------------- /lib/MessageRouterBase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_CPP_MESSAGEROUTERBASE_H 20 | #define PULSAR_CPP_MESSAGEROUTERBASE_H 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace pulsar { 28 | class Hash; 29 | using HashPtr = std::unique_ptr; 30 | typedef std::unique_ptr HashPtr; 31 | 32 | class MessageRouterBase : public MessageRoutingPolicy { 33 | public: 34 | MessageRouterBase(ProducerConfiguration::HashingScheme hashingScheme); 35 | 36 | protected: 37 | HashPtr hash; 38 | }; 39 | } // namespace pulsar 40 | 41 | #endif // PULSAR_CPP_MESSAGEROUTERBASE_H 42 | -------------------------------------------------------------------------------- /lib/MessagesImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_CPP_MESSAGESIMPL_H 20 | #define PULSAR_CPP_MESSAGESIMPL_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | using namespace pulsar; 27 | 28 | namespace pulsar { 29 | 30 | class MessagesImpl { 31 | public: 32 | MessagesImpl(const int maxNumberOfMessages, const long maxSizeOfMessages); 33 | const std::vector& getMessageList() const; 34 | bool canAdd(const Message& message) const; 35 | void add(const Message& message); 36 | int size() const; 37 | void clear(); 38 | 39 | private: 40 | std::vector messageList_; 41 | const int maxNumberOfMessages_; 42 | const long maxSizeOfMessages_; 43 | long currentSizeOfMessages_; 44 | }; 45 | 46 | } // namespace pulsar 47 | #endif // PULSAR_CPP_MESSAGESIMPL_H 48 | -------------------------------------------------------------------------------- /lib/NamedEntity.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "NamedEntity.h" 20 | 21 | #include 22 | 23 | /** 24 | * Allowed characters for property, namespace, cluster and topic names are 25 | * alphanumeric (a-zA-Z0-9) and these special chars _-=:. 26 | * @param name 27 | * @return 28 | */ 29 | bool NamedEntity::checkName(const std::string& name) { 30 | for (char c : name) { 31 | if (isalnum(c)) { 32 | continue; 33 | } 34 | 35 | switch (c) { 36 | case '_': 37 | case '-': 38 | case '=': 39 | case ':': 40 | case '.': 41 | continue; 42 | default: 43 | // Invalid character was found 44 | return false; 45 | } 46 | } 47 | 48 | return true; 49 | } 50 | -------------------------------------------------------------------------------- /lib/NamedEntity.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | class NamedEntity { 24 | public: 25 | static bool checkName(const std::string& name); 26 | }; 27 | -------------------------------------------------------------------------------- /lib/PendingFailures.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef LIB_PENDINGFAILURES_H_ 20 | #define LIB_PENDINGFAILURES_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace pulsar { 26 | 27 | class PendingFailures { 28 | public: 29 | void add(const std::function& failure) { failures.emplace_back(failure); } 30 | 31 | bool empty() const noexcept { return failures.empty(); } 32 | 33 | void complete() { 34 | for (auto& failure : failures) { 35 | failure(); 36 | } 37 | } 38 | 39 | private: 40 | std::vector> failures; 41 | }; 42 | 43 | } // namespace pulsar 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/Semaphore.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace pulsar { 28 | 29 | class Semaphore { 30 | public: 31 | explicit Semaphore(uint32_t limit); 32 | 33 | bool tryAcquire(int n = 1); 34 | bool acquire(int n = 1); 35 | void release(int n = 1); 36 | uint32_t currentUsage() const; 37 | 38 | void close(); 39 | 40 | private: 41 | const uint32_t limit_; 42 | uint32_t currentUsage_; 43 | mutable std::mutex mutex_; 44 | std::condition_variable condition_; 45 | bool isClosed_ = false; 46 | }; 47 | 48 | } // namespace pulsar 49 | -------------------------------------------------------------------------------- /lib/ServiceUnitId.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef _PULSAR_SERVICE_UNIT_ID_HEADER_ 20 | #define _PULSAR_SERVICE_UNIT_ID_HEADER_ 21 | 22 | class ServiceUnitId { 23 | public: 24 | virtual ~ServiceUnitId() {} 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/Synchronized.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | template 24 | class Synchronized { 25 | public: 26 | explicit Synchronized(const T& value) : value_(value) {} 27 | 28 | T get() const { 29 | std::lock_guard lock(mutex_); 30 | return value_; 31 | } 32 | 33 | T&& release() { 34 | std::lock_guard lock(mutex_); 35 | return std::move(value_); 36 | } 37 | 38 | Synchronized& operator=(const T& value) { 39 | std::lock_guard lock(mutex_); 40 | value_ = value; 41 | return *this; 42 | } 43 | 44 | private: 45 | T value_; 46 | mutable std::mutex mutex_; 47 | }; 48 | -------------------------------------------------------------------------------- /lib/TestUtil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PULSAR_CPP_TESTUTIL_H 21 | #define PULSAR_CPP_TESTUTIL_H 22 | 23 | #define FRIEND_TEST(test_case_name, test_name) friend class test_case_name##_##test_name##_Test 24 | 25 | #endif // PULSAR_CPP_TESTUTIL_H 26 | -------------------------------------------------------------------------------- /lib/TopicMetadataImpl.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "TopicMetadataImpl.h" 21 | 22 | namespace pulsar { 23 | TopicMetadataImpl::TopicMetadataImpl(const int numPartitions) : numPartitions_(numPartitions) {} 24 | 25 | int TopicMetadataImpl::getNumPartitions() const { return numPartitions_; } 26 | } // namespace pulsar 27 | -------------------------------------------------------------------------------- /lib/TopicMetadataImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef TOPIC_METADATA_IMPL_HPP_ 20 | #define TOPIC_METADATA_IMPL_HPP_ 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | class PULSAR_PUBLIC TopicMetadataImpl : public TopicMetadata { 26 | public: 27 | TopicMetadataImpl(const int numPartitions); 28 | virtual int getNumPartitions() const; 29 | 30 | private: 31 | int numPartitions_; 32 | }; 33 | } // namespace pulsar 34 | 35 | #endif /* TOPIC_METADATA_IMPL_HPP_ */ 36 | -------------------------------------------------------------------------------- /lib/UnAckedMessageTrackerDisabled.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef LIB_UNACKEDMESSAGETRACKERDISABLED_H_ 20 | #define LIB_UNACKEDMESSAGETRACKERDISABLED_H_ 21 | #include "UnAckedMessageTrackerInterface.h" 22 | namespace pulsar { 23 | 24 | class UnAckedMessageTrackerDisabled : public UnAckedMessageTrackerInterface { 25 | public: 26 | bool add(const MessageId& m) { return false; } 27 | bool remove(const MessageId& m) { return false; } 28 | void remove(const MessageIdList& msgIds) {} 29 | void removeMessagesTill(const MessageId& msgId) {} 30 | void removeTopicMessage(const std::string& topic) {} 31 | 32 | void clear() {} 33 | }; 34 | } // namespace pulsar 35 | #endif /* LIB_UNACKEDMESSAGETRACKERDISABLED_H_ */ 36 | -------------------------------------------------------------------------------- /lib/auth/AuthAthenz.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef PULSAR_AUTH_ATHENZ_H_ 20 | #define PULSAR_AUTH_ATHENZ_H_ 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | class ZTSClient; 27 | 28 | const std::string ATHENZ_PLUGIN_NAME = "athenz"; 29 | const std::string ATHENZ_JAVA_PLUGIN_NAME = "org.apache.pulsar.client.impl.auth.AuthenticationAthenz"; 30 | 31 | class AuthDataAthenz : public AuthenticationDataProvider { 32 | public: 33 | AuthDataAthenz(ParamMap& params); 34 | bool hasDataForHttp(); 35 | std::string getHttpHeaders(); 36 | bool hasDataFromCommand(); 37 | std::string getCommandData(); 38 | ~AuthDataAthenz(); 39 | 40 | private: 41 | std::shared_ptr ztsClient_; 42 | }; 43 | 44 | } // namespace pulsar 45 | #endif /* PULSAR_AUTH_ATHENZ_H_ */ 46 | -------------------------------------------------------------------------------- /lib/auth/AuthTls.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | const std::string TLS_PLUGIN_NAME = "tls"; 27 | const std::string TLS_JAVA_PLUGIN_NAME = "org.apache.pulsar.client.impl.auth.AuthenticationTls"; 28 | 29 | class AuthDataTls : public AuthenticationDataProvider { 30 | public: 31 | AuthDataTls(const std::string& certificatePath, const std::string& privateKeyPath); 32 | ~AuthDataTls(); 33 | 34 | bool hasDataForTls(); 35 | std::string getTlsCertificates(); 36 | std::string getTlsPrivateKey(); 37 | 38 | private: 39 | std::string tlsCertificate_; 40 | std::string tlsPrivateKey_; 41 | }; 42 | 43 | } // namespace pulsar 44 | -------------------------------------------------------------------------------- /lib/auth/AuthToken.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace pulsar { 25 | 26 | const std::string TOKEN_PLUGIN_NAME = "token"; 27 | const std::string TOKEN_JAVA_PLUGIN_NAME = "org.apache.pulsar.client.impl.auth.AuthenticationToken"; 28 | 29 | class AuthDataToken : public AuthenticationDataProvider { 30 | public: 31 | AuthDataToken(const std::string& token); 32 | AuthDataToken(const TokenSupplier& tokenSupplier); 33 | ~AuthDataToken(); 34 | 35 | bool hasDataForHttp(); 36 | std::string getHttpHeaders(); 37 | bool hasDataFromCommand(); 38 | std::string getCommandData(); 39 | 40 | private: 41 | TokenSupplier tokenSupplier_; 42 | }; 43 | 44 | } // namespace pulsar 45 | -------------------------------------------------------------------------------- /lib/auth/InitialAuthData.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace pulsar { 24 | 25 | class ClientConfiguration; 26 | 27 | struct InitialAuthData : public AuthenticationDataProvider { 28 | const std::string tlsTrustCertsFilePath_; 29 | 30 | InitialAuthData(const std::string& tlsTrustCertsFilePath) 31 | : tlsTrustCertsFilePath_(tlsTrustCertsFilePath) {} 32 | 33 | bool hasDataForHttp() override { return false; } 34 | std::string getHttpHeaders() override { return ""; } 35 | bool hasDataFromCommand() override { return false; } 36 | std::string getCommandData() override { return ""; } 37 | }; 38 | 39 | } // namespace pulsar 40 | -------------------------------------------------------------------------------- /lib/c/cStringList.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | 22 | #include "c_structs.h" 23 | 24 | pulsar_string_list_t *pulsar_string_list_create() { return new pulsar_string_list_t; } 25 | 26 | void pulsar_string_list_free(pulsar_string_list_t *list) { delete list; } 27 | 28 | int pulsar_string_list_size(pulsar_string_list_t *list) { return list->list.size(); } 29 | 30 | void pulsar_string_list_append(pulsar_string_list_t *list, const char *item) { list->list.push_back(item); } 31 | 32 | const char *pulsar_string_list_get(pulsar_string_list_t *list, int index) { 33 | return list->list[index].c_str(); 34 | } 35 | -------------------------------------------------------------------------------- /lib/c/c_MessageRouter.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | 22 | #include "c_structs.h" 23 | 24 | int pulsar_topic_metadata_get_num_partitions(pulsar_topic_metadata_t *topicMetadata) { 25 | return topicMetadata->metadata->getNumPartitions(); 26 | } 27 | -------------------------------------------------------------------------------- /lib/c/c_Messages.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "lib/c/c_structs.h" 22 | 23 | size_t pulsar_messages_size(pulsar_messages_t* msgs) { return msgs->messages.size(); } 24 | 25 | pulsar_message_t* pulsar_messages_get(pulsar_messages_t* msgs, size_t index) { 26 | return &msgs->messages[index]; 27 | } 28 | 29 | void pulsar_messages_free(pulsar_messages_t* msgs) { delete msgs; } 30 | -------------------------------------------------------------------------------- /lib/c/c_Result.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | const char *pulsar_result_str(pulsar_result result) { return pulsar::strResult((pulsar::Result)result); } 24 | -------------------------------------------------------------------------------- /lib/checksum/ChecksumProvider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef _CHECKSUM_PROVIDER_H_ 20 | #define _CHECKSUM_PROVIDER_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace pulsar { 26 | 27 | PULSAR_PUBLIC bool crc32cSupported(); 28 | PULSAR_PUBLIC uint32_t computeChecksum(uint32_t previousChecksum, const void *data, int length); 29 | PULSAR_PUBLIC uint32_t crc32cHw(uint32_t previousChecksum, const void *data, int length); 30 | PULSAR_PUBLIC uint32_t crc32cSw(uint32_t previousChecksum, const void *data, int length); 31 | } // namespace pulsar 32 | 33 | #endif // _CHECKSUM_PROVIDER_H_ 34 | -------------------------------------------------------------------------------- /lib/checksum/crc32c_sse42.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2014 Trevor Robinson 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | #include "int_types.h" 17 | 18 | namespace pulsar { 19 | 20 | bool crc32c_initialize(); 21 | 22 | class chunk_config { 23 | public: 24 | enum 25 | { 26 | min_words = 4 27 | }; 28 | 29 | const size_t words; 30 | const chunk_config *const next; 31 | uint32_t shift1[256]; 32 | uint32_t shift2[256]; 33 | 34 | chunk_config(size_t words, const chunk_config *next = 0); 35 | 36 | size_t loops() const { return (words - 1) / 3; } 37 | 38 | size_t extra() const { return (words - 1) % 3 + 1; } 39 | 40 | private: 41 | chunk_config &operator=(const chunk_config &); 42 | 43 | static void make_shift_table(size_t bytes, uint32_t table[256]); 44 | }; 45 | 46 | uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config *config); 47 | } // namespace pulsar 48 | -------------------------------------------------------------------------------- /lib/checksum/crc32c_sw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace pulsar { 24 | 25 | uint32_t crc32c_sw(uint32_t crc, const void* data, int length); 26 | 27 | } // namespace pulsar 28 | -------------------------------------------------------------------------------- /lib/checksum/int_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2014 Trevor Robinson 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | #include // size_t 17 | 18 | #if defined(_MSC_VER) && _MSC_VER < 1600 // stdint.h added in MSVC 2010 19 | 20 | typedef __int8 int8_t; 21 | typedef __int16 int16_t; 22 | typedef __int32 int32_t; 23 | typedef __int64 int64_t; 24 | typedef unsigned __int8 uint8_t; 25 | typedef unsigned __int16 uint16_t; 26 | typedef unsigned __int32 uint32_t; 27 | typedef unsigned __int64 uint64_t; 28 | 29 | #else 30 | 31 | #include 32 | 33 | #endif 34 | 35 | #if defined(_MSC_VER) && _MSC_VER < 1900 // MSVC 2015 36 | 37 | #define SIZE_T_FORMAT "%Iu" 38 | 39 | #else 40 | 41 | #define SIZE_T_FORMAT "%zu" 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/stats/ConsumerStatsBase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PULSAR_CONSUMER_STATS_BASE_HEADER 21 | #define PULSAR_CONSUMER_STATS_BASE_HEADER 22 | #include 23 | #include 24 | 25 | #include "lib/ProtoApiEnums.h" 26 | 27 | namespace pulsar { 28 | class ConsumerStatsBase { 29 | public: 30 | virtual void start() {} 31 | virtual void stop() {} 32 | virtual void receivedMessage(Message&, Result) = 0; 33 | virtual void messageAcknowledged(Result, CommandAck_AckType, uint32_t ackNums = 1) = 0; 34 | virtual ~ConsumerStatsBase() {} 35 | }; 36 | 37 | typedef std::shared_ptr ConsumerStatsBasePtr; 38 | } // namespace pulsar 39 | 40 | #endif // PULSAR_CONSUMER_STATS_BASE_HEADER 41 | -------------------------------------------------------------------------------- /lib/stats/ConsumerStatsDisabled.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PULSAR_CONSUMER_STATS_DISABLED_H_ 21 | #define PULSAR_CONSUMER_STATS_DISABLED_H_ 22 | 23 | #include "ConsumerStatsBase.h" 24 | 25 | namespace pulsar { 26 | 27 | class ConsumerStatsDisabled : public ConsumerStatsBase { 28 | public: 29 | virtual void receivedMessage(Message&, Result) {} 30 | virtual void messageAcknowledged(Result, CommandAck_AckType, uint32_t ackNums) {} 31 | }; 32 | 33 | } /* namespace pulsar */ 34 | 35 | #endif /* PULSAR_CONSUMER_STATS_DISABLED_H_ */ 36 | -------------------------------------------------------------------------------- /lib/stats/ProducerStatsBase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PULSAR_PRODUCER_STATS_BASE_HEADER 21 | #define PULSAR_PRODUCER_STATS_BASE_HEADER 22 | #include 23 | #include 24 | 25 | #include "lib/TimeUtils.h" 26 | 27 | namespace pulsar { 28 | class ProducerStatsBase { 29 | public: 30 | virtual void start() {} 31 | virtual void messageSent(const Message& msg) = 0; 32 | virtual void messageReceived(Result, const ptime&) = 0; 33 | virtual ~ProducerStatsBase(){}; 34 | }; 35 | 36 | typedef std::shared_ptr ProducerStatsBasePtr; 37 | } // namespace pulsar 38 | 39 | #endif // PULSAR_PRODUCER_STATS_BASE_HEADER 40 | -------------------------------------------------------------------------------- /lib/stats/ProducerStatsDisabled.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PULSAR_PRODUCER_STATS_DISABLED_HEADER 21 | #define PULSAR_PRODUCER_STATS_DISABLED_HEADER 22 | #include "ProducerStatsBase.h" 23 | 24 | namespace pulsar { 25 | class ProducerStatsDisabled : public ProducerStatsBase { 26 | public: 27 | virtual void messageSent(const Message& msg){}; 28 | virtual void messageReceived(Result, const ptime&){}; 29 | }; 30 | } // namespace pulsar 31 | #endif // PULSAR_PRODUCER_STATS_DISABLED_HEADER 32 | -------------------------------------------------------------------------------- /log4cxx.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Set root logger level to INFO and its only appender to A1. 21 | log4j.rootLogger=INFO, A1 22 | 23 | # A1 is set to be a ConsoleAppender. 24 | log4j.appender.A1=org.apache.log4j.ConsoleAppender 25 | 26 | # A1 uses PatternLayout. 27 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout 28 | log4j.appender.A1.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss.SSS} %X{pname}:%X{pid} %-5p %l- %m%n 29 | log4j.appender.A1.serverFileAppender=org.apache.log4j.RollingFileAppender 30 | 31 | # Tweak the timestamp format so that it sorts easier 32 | log4j.appender.A1.serverFileAppender.fileName=/tmp/pulsar_client_cpp.log 33 | -------------------------------------------------------------------------------- /perf/BuildPerf.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | add_executable(perfProducer PerfProducer.cc) 21 | target_link_libraries(perfProducer pulsarShared Boost::program_options) 22 | 23 | add_executable(perfConsumer PerfConsumer.cc) 24 | target_link_libraries(perfConsumer pulsarShared Boost::program_options) 25 | -------------------------------------------------------------------------------- /perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | if (INTEGRATE_VCPKG) 21 | include(BuildPerf.cmake) 22 | else () 23 | include(LegacyBuildPerf.cmake) 24 | endif () 25 | -------------------------------------------------------------------------------- /perf/LegacyBuildPerf.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Test tools 21 | add_definitions(-D_GLIBCXX_USE_NANOSLEEP) 22 | 23 | set(PERF_PRODUCER_SOURCES 24 | PerfProducer.cc 25 | ) 26 | 27 | set(PERF_CONSUMER_SOURCES 28 | PerfConsumer.cc 29 | ) 30 | 31 | add_executable(perfProducer ${PERF_PRODUCER_SOURCES}) 32 | add_executable(perfConsumer ${PERF_CONSUMER_SOURCES}) 33 | 34 | set(TOOL_LIBS ${CLIENT_LIBS} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_THREAD_LIBRARY}) 35 | 36 | target_link_libraries(perfProducer pulsarShared ${TOOL_LIBS}) 37 | target_link_libraries(perfConsumer pulsarShared ${TOOL_LIBS}) 38 | -------------------------------------------------------------------------------- /pkg/apk/.gitignore: -------------------------------------------------------------------------------- 1 | pkg 2 | build 3 | .build -------------------------------------------------------------------------------- /pkg/apk/build-apk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | cd /pulsar-client-cpp 24 | export ROOT_DIR=$(pwd) 25 | 26 | rm -f CMakeCache.txt 27 | rm -rf CMakeFiles 28 | 29 | cd $ROOT_DIR/pkg/apk 30 | 31 | 32 | 33 | POM_VERSION=`cat $ROOT_DIR/version.txt | xargs` 34 | # Sanitize the version string 35 | export VERSION=`echo $POM_VERSION | sed -E 's/\-[a-zA-Z]+//'` 36 | 37 | echo "VERSION: $VERSION" 38 | 39 | abuild-keygen -a -i -n 40 | abuild -F -c -r 41 | 42 | cp -r /root/packages/pkg ./build 43 | -------------------------------------------------------------------------------- /pkg/apk/create-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | cd $ROOT_DIR/pkg/apk 25 | 26 | $ROOT_DIR/build-support/copy-deps-versionfile.sh 27 | 28 | # ARM 29 | IMAGE=apachepulsar/pulsar-build:alpine-3.16-arm64 30 | docker build --platform arm64 -t $IMAGE . --build-arg PLATFORM=aarch64 31 | 32 | # X86_64 33 | IMAGE=apachepulsar/pulsar-build:alpine-3.16-x86_64 34 | docker build --platform x86_64 -t $IMAGE . --build-arg PLATFORM=x86_64 35 | -------------------------------------------------------------------------------- /pkg/apk/docker-build-apk-arm64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:alpine-3.16-arm64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=arm64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/apk/build-apk.sh 31 | 32 | -------------------------------------------------------------------------------- /pkg/apk/docker-build-apk-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:alpine-3.16-x86_64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=x86_64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/apk/build-apk.sh 31 | 32 | -------------------------------------------------------------------------------- /pkg/deb/.gitignore: -------------------------------------------------------------------------------- 1 | BUILD 2 | .build -------------------------------------------------------------------------------- /pkg/deb/create-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | cd $ROOT_DIR/pkg/deb 25 | 26 | $ROOT_DIR/build-support/copy-deps-versionfile.sh 27 | 28 | # ARM 29 | IMAGE=apachepulsar/pulsar-build:debian-9-2.11-arm64 30 | docker build --platform arm64 -t $IMAGE . --build-arg PLATFORM=aarch64 31 | 32 | # X86_64 33 | IMAGE=apachepulsar/pulsar-build:debian-9-2.11-x86_64 34 | docker build --platform x86_64 -t $IMAGE . --build-arg PLATFORM=x86_64 35 | -------------------------------------------------------------------------------- /pkg/deb/docker-build-deb-arm64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -ex 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:debian-9-2.11-arm64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=arm64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/deb/build-deb.sh 31 | -------------------------------------------------------------------------------- /pkg/deb/docker-build-deb-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -ex 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:debian-9-2.11-x86_64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=amd64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/deb/build-deb.sh 31 | -------------------------------------------------------------------------------- /pkg/licenses/LICENSE-boost.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /pkg/licenses/LICENSE-libcurl.txt: -------------------------------------------------------------------------------- 1 | COPYRIGHT AND PERMISSION NOTICE 2 | 3 | Copyright (c) 1996 - 2018, Daniel Stenberg, , and many 4 | contributors, see the THANKS file. 5 | 6 | All rights reserved. 7 | 8 | Permission to use, copy, modify, and distribute this software for any purpose 9 | with or without fee is hereby granted, provided that the above copyright 10 | notice and this permission notice appear in all copies. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN 15 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 18 | OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | Except as contained in this notice, the name of a copyright holder shall not 21 | be used in advertising or otherwise to promote the sale, use or other dealings 22 | in this Software without prior written authorization of the copyright holder. 23 | -------------------------------------------------------------------------------- /pkg/licenses/LICENSE-zlib.txt: -------------------------------------------------------------------------------- 1 | zlib.h -- interface of the 'zlib' general purpose compression library 2 | version 1.2.12, March 27th, 2022 3 | 4 | Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this software must not be misrepresented; you must not 15 | claim that you wrote the original software. If you use this software 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 2. Altered source versions must be plainly marked as such, and must not be 19 | misrepresented as being the original software. 20 | 3. This notice may not be removed or altered from any source distribution. 21 | 22 | Jean-loup Gailly Mark Adler 23 | jloup@gzip.org madler@alumni.caltech.edu 24 | -------------------------------------------------------------------------------- /pkg/mac/vcpkg-curl-patch.diff: -------------------------------------------------------------------------------- 1 | diff --git a/ports/curl/portfile.cmake b/ports/curl/portfile.cmake 2 | index 427bccb217..ddfd75d30f 100644 3 | --- a/ports/curl/portfile.cmake 4 | +++ b/ports/curl/portfile.cmake 5 | @@ -62,6 +62,10 @@ if(VCPKG_TARGET_IS_WINDOWS) 6 | list(APPEND OPTIONS -DENABLE_UNICODE=ON) 7 | endif() 8 | 9 | +if(VCPKG_TARGET_IS_OSX) 10 | + list(APPEND OPTIONS -DENABLE_IPV6=OFF) 11 | +endif() 12 | + 13 | vcpkg_find_acquire_program(PKGCONFIG) 14 | 15 | vcpkg_cmake_configure( 16 | diff --git a/ports/curl/vcpkg.json b/ports/curl/vcpkg.json 17 | index 31955859d0..50e619b846 100644 18 | --- a/ports/curl/vcpkg.json 19 | +++ b/ports/curl/vcpkg.json 20 | @@ -1,7 +1,7 @@ 21 | { 22 | "name": "curl", 23 | "version": "8.13.0", 24 | - "port-version": 1, 25 | + "port-version": 2, 26 | "description": "A library for transferring data with URLs", 27 | "homepage": "https://curl.se/", 28 | "license": "curl AND ISC AND BSD-3-Clause", 29 | -------------------------------------------------------------------------------- /pkg/rpm/.gitignore: -------------------------------------------------------------------------------- 1 | BUILD 2 | BUILDROOT 3 | SOURCES 4 | RPMS 5 | SRPMS 6 | .build -------------------------------------------------------------------------------- /pkg/rpm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Build pulsar client library in Centos with tools to build static RPM 21 | 22 | FROM rockylinux:8 23 | 24 | ARG PLATFORM 25 | 26 | RUN yum update -y && \ 27 | yum install -y \ 28 | gcc-c++ \ 29 | make \ 30 | rpm-build \ 31 | which \ 32 | createrepo \ 33 | git \ 34 | python3 \ 35 | python3-pip 36 | RUN dnf --enablerepo=powertools install -y libstdc++-static 37 | 38 | RUN pip3 install pyyaml 39 | 40 | ADD .build/dependencies.yaml / 41 | ADD .build/dep-version.py /usr/local/bin 42 | 43 | # Vcpkg does not provide pre-built binaries for Arm architectures so we need to build vcpkg from source 44 | RUN yum install -y cmake 45 | RUN dnf --enablerepo=devel install -y ninja-build 46 | 47 | # Dependencies when building OpenSSL 48 | RUN yum install -y perl-IPC-Cmd 49 | -------------------------------------------------------------------------------- /pkg/rpm/build-rpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | 23 | cd /pulsar-client-cpp 24 | ROOT_DIR=$(pwd) 25 | cd $ROOT_DIR/pkg/rpm 26 | 27 | if [[ $PLATFORM == "aarch64" ]]; then 28 | export VCPKG_FORCE_SYSTEM_BINARIES=arm 29 | fi 30 | 31 | POM_VERSION=`cat $ROOT_DIR/version.txt | xargs` 32 | 33 | # Sanitize VERSION by removing `-incubating` since it's not legal in RPM 34 | VERSION=`echo $POM_VERSION | awk -F- '{print $1}'` 35 | 36 | mkdir -p BUILD RPMS SOURCES SPECS SRPMS 37 | 38 | cp $ROOT_DIR/apache-pulsar-client-cpp-$POM_VERSION.tar.gz SOURCES 39 | 40 | rpmbuild -v -bb --clean \ 41 | --define "version $VERSION" \ 42 | --define "pom_version $POM_VERSION" \ 43 | --define "_topdir $PWD" \ 44 | SPECS/pulsar-client.spec 45 | 46 | cd RPMS/${PLATFORM} 47 | createrepo . 48 | -------------------------------------------------------------------------------- /pkg/rpm/create-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e -x 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | cd $ROOT_DIR/pkg/rpm 25 | 26 | $ROOT_DIR/build-support/copy-deps-versionfile.sh 27 | 28 | # ARM 29 | IMAGE=apachepulsar/pulsar-build:centos-7-2.11-arm64 30 | docker build --platform arm64 -t $IMAGE . --build-arg PLATFORM=aarch64 31 | 32 | # X86_64 33 | IMAGE=apachepulsar/pulsar-build:centos-7-2.11-x86_64 34 | docker build --platform x86_64 -t $IMAGE . --build-arg PLATFORM=x86_64 35 | -------------------------------------------------------------------------------- /pkg/rpm/docker-build-rpm-arm64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -ex 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:centos-7-2.11-arm64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=aarch64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/rpm/build-rpm.sh 31 | -------------------------------------------------------------------------------- /pkg/rpm/docker-build-rpm-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -ex 22 | 23 | ROOT_DIR=$(git rev-parse --show-toplevel) 24 | 25 | IMAGE_NAME=${1:-apachepulsar/pulsar-build:centos-7-2.11-x86_64} 26 | 27 | docker run -v $ROOT_DIR:/pulsar-client-cpp \ 28 | --env PLATFORM=x86_64 \ 29 | $IMAGE_NAME \ 30 | /pulsar-client-cpp/pkg/rpm/build-rpm.sh 31 | -------------------------------------------------------------------------------- /pulsar-test-service-start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | 23 | cd `dirname $0` 24 | SRC_DIR=$PWD 25 | 26 | ./pulsar-test-service-stop.sh 27 | 28 | CONTAINER_ID=$(docker run -i --user $(id -u) -p 8080:8080 -p 6650:6650 -p 8443:8443 -p 6651:6651 --rm --detach apachepulsar/pulsar:latest sleep 3600) 29 | build-support/setup-test-service-container.sh $CONTAINER_ID start-test-service-inside-container.sh 30 | 31 | docker cp $CONTAINER_ID:/pulsar/data/tokens/token.txt .test-token.txt 32 | 33 | CONTAINER_ID=$(docker run -i --user $(id -u) -p 8081:8081 -p 6652:6652 -p 8444:8444 -p 6653:6653 --rm --detach apachepulsar/pulsar:latest sleep 3600) 34 | build-support/setup-test-service-container.sh $CONTAINER_ID start-mim-test-service-inside-container.sh 35 | 36 | echo "-- Ready to start tests" 37 | -------------------------------------------------------------------------------- /pulsar-test-service-stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | 21 | set -e 22 | 23 | cd `dirname $0` 24 | SRC_DIR=$PWD 25 | 26 | CONTAINER_ID_PATH=".tests-container-id.txt" 27 | 28 | if [ -f ${CONTAINER_ID_PATH} ]; then 29 | CONTAINER_ID=$(cat $CONTAINER_ID_PATH) 30 | docker kill $CONTAINER_ID || true 31 | rm .tests-container-id.txt 32 | fi 33 | -------------------------------------------------------------------------------- /templates/Version.h.in: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * @PVM_COMMENT@ 22 | */ 23 | #pragma once 24 | 25 | #define PULSAR_VERSION @PULSAR_CLIENT_VERSION_MACRO@ 26 | 27 | #define PULSAR_VERSION_STR "@PULSAR_CLIENT_VERSION@" 28 | -------------------------------------------------------------------------------- /test-conf/.htpasswd: -------------------------------------------------------------------------------- 1 | admin:$apr1$FG4AO6aX$KGYPuMoLUou3i6vUkPUUf. 2 | -------------------------------------------------------------------------------- /test-conf/broker-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpQIBAAKCAQEAmypvJAIj9//mdWHKB6jAq+mN61EuZPeem9S0vjr69G7Gko84 3 | TQjNiRU+LMSZbctYgPzgTdZ99oKrDZTy4kXJ0xWVVwpshtx4ZDs0SwF8Xd5P1CEa 4 | XSegpXB6LgJQ4Rm0uQXfmQ2LzGLcEHP6cos4f9NWVGFQu5L/CXEJx70EQzyMnIsy 5 | 0QUEisaJ2HhWTdov9Ow0Nya1h+Q/JslBYLoxEBm++AykCoUZWeIAXbfAvdEu/KY0 6 | i4UqzAX2++QA5nSV/wJvQ385p8KDjls4QMlCyLwmcjY1ZMJUIhGH6GWPPelBp20Z 7 | iJogm5pS59LLs+Auj8FWVLxtFDBzxdeO0FpezQIDAQABAoIBAG9pk63mP49l1kM4 8 | eQjw2Y9WvslVXBuxVNiNbU4eKW1zUO+RGJrvlC027JLWg1g7pwvPBvu85GspPcsd 9 | xRxFgfonyDhcSrq2+Vb2z8B/i54W73jgX/69YnMIBSKeFRbcD1C+7+MEv/l8jojd 10 | zdmLL4FQ7O7fhUl57dgIqz4Y8UOYyyBsPpz3pzJLFEb5rE/ajqmFzyl+dO+8140B 11 | niQ0+7+tAK0njX8OC0WN844GkO24WPCfWhUFrYGkfLq498eRUCWM2YP2tAJ+Uxnh 12 | v3K9icDwOX6PJXYlbvNEUCE+t60NoDYHcMpfzUdFEhBYpKadfKE/RFFcu0vAZ+aR 13 | y24oAuECgYEAyPLYXWIs88pPHQhSf2DAMRref5eeV+XA6Dy/P+z8z0bA7I6X9dl6 14 | AK6rRKGJl9HI7c/Gky6P10fymopYopNkClXm7SBTLKx0vfjil0U6Mx5ZsfDspE3q 15 | 0o9MJKVgobCxVZlLErU55XzktKwjlv2UvDX7VuxRndqN9qdf+YSMb9kCgYEAxayx 16 | sOrJcPZVfy3Ohy5CeStF+E2dtfcKB7M7xZxZqykVy+6J1XjXHmp1L7Wpi0ju57Hi 17 | l2ZqKasHDwtlLOnfSTbvC47hsa1ydnoFTjJBObR1wS43oVkyV0AHid4w81ddOWPC 18 | H0ZmhvNe7pUxm5crpxsY6hAAraJ4Hej23MOxghUCgYEAip26UvCeQa2U1VogTm3X 19 | Jgh641kbiVabs5fz9Yzs966+9m+Gs7jJSB81Vap415mHGUTyniTIZKDk4WX9rmgt 20 | 4lNPcNOTjIWKImHFLMQ8WXbeOLkRBGYbThQ7WiwadG8GZR3Rg54vyfZVbawxAL78 21 | ErjKIDP0OQfCVhsvQVgF6EECgYEAlQ2P+xA/Dv+gHkLjDUmTdBxuKToVZqU9merL 22 | cklfz9EuD1Tx99ajltq9PFll25IGGw0mB/WAraS5sN1tz/0VkfZrL7LwefKIcc+2 23 | em0og6OQezcnWXGRpPqx9IJnNMY2lFSlhsGmA7I1bf9vpZvKnbmwAqZIbKUqn5sP 24 | sg2ZprUCgYEApAVD+9wXfZE/YDHVZX1k6p38ORqjq/04AJkL/LmUW5DL5to1+1KQ 25 | Q438HzMtYIq7aZyzWmlF6DmyN5mxKKK3yY79p0rvdV74AoT+ucDzM3ge0Md7liCs 26 | 0GwNnDSiPzdau738UoIKc1VbF7dMDL3LzqnfrBUCr7nXRbR3BHHuqws= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test-conf/cakey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA1XI4pVzLpyv3p+00WWmfnfZcopHBTEEVPxNtSjtaJRxexYzZ 3 | fkQZvkn0O/v7hQ0EKRwxZU/6LKyPkOLE0Z0dvWAk07RQzGxC4Jyj7+5EuFG4ZKJ3 4 | Axb9txft1ihfwHE6w4dVpSwHFvHIeQc/ad7Nsx01Lwvp446bqEfu/rSbEngBy0WQ 5 | UhgM7D7b/R44O/TgAfaN5/68tIn0zGRuZWbDK288BLQ+Uhi4J/iHbYdB1ahhINJQ 6 | de6vbwgtntXQV5IK0Qaa9sDCyDjDCpPqvn0lMnXr3dIwpwfxt4i3YBwyo0Xnczio 7 | NbPTzQ68vfdXA6rX4dwqCkFp6zXfjMDs6C2adwIDAQABAoIBAQCZe9cL4dx3y3/8 8 | eu+H1BH5LqySIilTQgGbJ8cQ9/jscqgbehrzVtkEIn3DnIDSvfdd8G38ojQNZ9Cc 9 | qNRKvqYiBT62FRV8yeSVS03/O+CigfEMPF9EE4ZB4K0fsEyaP1G4RFrruOsoLpiv 10 | nuyUnqhfwgL6X6DCB0wbCA7tjMVt0xlkZrm+eVu3spihjXCf49R4nRU5IEIzrZP/ 11 | efjcxmylbr9xOqSYAb5Dj3qk4DEEROmgQMVpMuoPNJ9wZOzoUPyHrLuMUb5pBStB 12 | 25tsGea2/4haTxgKIc9nksanVS6OauYA07UkE/5iDp11cT2h1t/HvdA95d205Y72 13 | g0FgpguhAoGBAPIIV7p6mqFTs97JTG8qniUcdJ5elfn5OAOMkrDfhwWb3tPTCkSo 14 | rpJ+cEb/8s+VNSsaLAUDHOqPCUHeKF9vuAOvPlz5VjAoeibO+kDNnBSxgqofMkBh 15 | sdm6LrWiDgLlKoPqmNuaFvd2G2kFWORnlIBafVqvo1/7rTMOyZs2/am/AoGBAOHD 16 | jvzOYSZckbkoRSeMiiZVQxtzLCP1WTktZ3ZHyYwmXdP7EcaKcvIlh7JL/kGTisQN 17 | Fw8hB54TxbGyubuJuOiF6dFRS0SoAP2mLRwYgXEP+trIX4r2sy7lNa+CK9YXS+sP 18 | ECCc/0pdM/kv4rFNhfzLzBA6OAX825TchMDvJo1JAoGBAL09fKqXtlOxiJAHQLYi 19 | 0mgd6ajyN72t+Pf9b6zP+ViPWRiyh/LLGUP9jHhXI1jfRyUeX5DDsFZN5GUV+Oc2 20 | COEIonA7nAIng+rYJp+IpCMh8BJoNfhU6qRciK0HuoDVAfsG8OGzh4WRWTkyLyDX 21 | RCtflWfUsJ8Zv4CObV/pDUktAoGADNXfdUQOhe3RYyOE+wCkghVq4U6k/c5fKj8I 22 | mNLwBIXR49Fsa0tHybiUhHCJnhTTWN4dp4CLPFOHc9jjcmQcHSwv5PSoQNkEZWdj 23 | PSuvgEwWSQYHWJE6Erp5WOcfsuZULKMImbITWZj+8XXlf4sWyQ6VJX8J3F1J5qa6 24 | 7XUrTfECgYBDB2qSarK3gsmYEZLSBExEV+jo4XXR4uwkOztRbjE2WNePNu59d8fE 25 | urOifLXJFGikzz5PD078wOQBitmkuRi3wx8YNjj/sUAUR5qdvJ/tlsoFGmsq79BL 26 | GMPCuslHXqXGSiixPdtFbO3GxOt6j7fu+oSyIacXLUJI+lsiSQnpwg== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test-conf/chained-client-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEAuf8QfiKGVXg7xrHJxDVU6VJ/1akbeIJZ+y8NSUGi4JwLA9l8 3 | iYWtgux/z7BhMeLOH62N0q9DBnZcU26KPieLDFxKNaAzvND5DcFKcskO1dWyjvER 4 | 0ZxvkwSdJdZ+RdRyrLnQBmA+PyMRdWMZGMGo+Nz54clUvMwPJAOKE+S2pDoUqUYI 5 | XZdErPY/dNNXfHjU1fmqgSQnFvlk3CP8MKODgPQIuB+Qnar1wOn8qYob35ssFCfv 6 | cFP5FhmuTP7Z7esa/pJZXKf2HZmwKvbkI8oM+RuMK977ouD3rLvT2VDK5k4OtP6z 7 | XOVvlYxVFQNXFj6lHlhXCauOdMHHd1fb8SYicQIDAQABAoIBAG+OuMmu03u4HcJT 8 | KH1yr3cycFIql7t0E5xA4Gsr3xFxBnpMnBGwCB4a054yYFmXe6IsaoAPdtgNbdrs 9 | 1iXpedD0Gd6IM//wJzFE2e53AVroTazGkrVyasl3Xvou6JXhktZerJLmbu9XjUUn 10 | JwpePYbmo0n1g8mpavti1BKSf6mH1nlbrGpyKi4UwJVtLmz3z03nba1EmMJOwEJH 11 | F+CL29AB5D7UpcKEnE+qoR5T3SzvMCq8X3bQAsyCfxZu8gGviyj5EHs6Ymm/L/yJ 12 | f5l469JVTli1Qu2jkiAzNBFf6GeSV6gOpD0YEC6UPG7WvKYiwwHEqNdEFkEawqy3 13 | 4fsRHUECgYEA5brvQY7El4YSp6cHIOfZ9enlPgecpse39U65cL5BEBEkYPmZwibK 14 | 5yj/Q4or6EAW3EpdbTGDXIEHtD6eQCkZwzDPDJRqrsueOS4zwJpDYQPpf+pp3xNS 15 | hnpsI21K0Q5njPUSA0eogX7w8PusRBM8EJ7d5Xr4QKBRo7SScpXI1K0CgYEAz0Pg 16 | Gq1iFM5S3Tb6lZlzkqJ4BKiCidNB8Kch5sG8lXxh7ZuBN72WXgUnfodAbdCsDs4p 17 | /wiOBAAGnw4ahX9N8Be4JAl6R1HDcc4YiDQnlAxSN03piM75ObXHx/EkeD6gW33f 18 | AmD3IcgdE+UdKrz9XMxUeINwwrzNsGltPQ0xOVUCgYBAEFVQTuP77WOeZTHTt1RN 19 | A6DuH2lMCT3/pqiIDEZQmLcwY+rA/dhvhjtJNmrwJY86d3J+VORxE3p2hU/UTKHm 20 | kOHsfCcT/6xr/bpo55wKnfCrv08u6lCFN/aYGo5WplGyOVWAnKcdFa1TRpvPkB2b 21 | 9PGkYRqByzN5F44Pbj3HMQKBgEzt749XTXFVh3IuRuIh+8CwZwWrmhAYBoCROEcT 22 | H7EIYryznEmZJ+er2BXhk6tu6X3xTasofLXFYK/Gp1dnggEcfK97iRRRp85k5bwg 23 | R5Ru4lE+rPCnid++tfFjctriu9hZpt2WKgQy54AL6UCEtzGrcartdnwBYgMZjn87 24 | l0qlAoGAFfUzYYCJ2BixDbmeR1ZutPYlrxOTofQG8gIb3ihUx3YBXg5ZKMJySAXL 25 | DH55/VZmppXMX5LLL/p3aiZU30L6j4G7X5OFLH7S/UDTUgc2qtmk1Hwz+oGW5HhU 26 | 5SD52RzjzisfLye6VeOEQw6Oj5DrYkRAXg9dAMbib5Y34sJGYQk= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test-conf/client-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEoQIBAAKCAQEAq2H1ErHhrhkBPllKxsoADJbodjqDINmvOuERIBLg5NBwj0t7 3 | r+GJ75vFqcLtriSNu0Ju7FkRP/VjWWEYn3C2dojiynkVzPucXly7odfw2BHUFzQe 4 | gX4LDgW+XfrWRq/hldigXcUv2amPaWRJlfdCFmqEKy6vkXM9ttREVpphQ0kVIq6Q 5 | XQQpkE6yQTRzPqJIBRy8jhsLwdXfVjJA6ZGie94xK2fxjtbFwIdXcCn5r9tXoC6M 6 | MAqnRzkzTNctMqpIKb3ESMVYUgfEmbHMZtqsKE3BvB9EP6NjYb3/SGF2BLJ9HG6c 7 | 7oK792AceqCYvi1wQy9kv9IPICX3x31wBbguvwIDAQABAoIBAQCcwbSPrPRncaeZ 8 | h8LFoO36le16dnqKCZIloMcxNxNNNvo9lyVC8mBgMXLSm+Eab4TTyyf6Nl14ytJc 9 | ZltHOqkqMnp+B9LQ8zNLfDaDCijY+TWtI5bjio5B/S7qdwyXCzii/slv+3SQ+m6a 10 | T4ifCtH//t11QfaEa4v/NphrPjnIeAgB681bk8nKdRop84ar+51lgbHoAza+wv+8 11 | e+aK3Od8r4yD19ZoPiMg0o4t2cEi8kupVgjsuZVtcvF9Q6QLYV17BFYEHqYjcr18 12 | N1EJ96f2FLO6cwEM+cG4n8gHjfDGRcDlhT9Cum1kDpg4J88auVUXnrDyi5Dcv1Pz 13 | 6EC+ZmXBAoGBAOHUSUDMkbEePKDaM3Z+4jLqZWc3UZhxQLnqg5l7phdQ6iSogQX9 14 | 1LpZCJ+lOMTHBCnaTCoQpuSHgYgraVkD4KG6nzC423oDesd/xNvlfW3TRsmwZWbL 15 | khdcdBSoVy3Kbv1v8kxw0NlcR68qo1XYfmFCAITcFHdxDz/jGStydlR9AoGBAMJH 16 | gyPenL595X8t47R93rkGOIx5cVf5YrDIZCByp4K44Tf9OqZHbky7jSPSSbur10mI 17 | pypRq5EcZ/cudU4w4gGaMauczt5Dgvlqd3T+GTZY3jO8bxi66gvzYTbigAxaJWcY 18 | Uafiv5W9ldRKsY3pyCL8ubg38Ed2cSaS2wGd/SDrAn8NO2MPaO0gc6UZx688QjL+ 19 | yL0oTxV42Snxusv7MkOJGjSd8UGeGEFeqdjXgdbRsNeNnDzaOh+NRGNSlziU/qUq 20 | 1MR/FlXF0G5hQhtGxyuSQ87iAnPukf79X21tyG9TP4lBUE3iLLoQAlgw606muQiu 21 | qi9dmYeZeAZst+HBqfNFAoGADg6qmH/VC5uEbY1eeoLZCL5AfTmUT+9FitEVHZvu 22 | LvE9qpVyFvH4Mykm7z6aAzBN5Y4zukYqiddqVmJQLpYu5DrJ+UbhWQe9hFqFxjtU 23 | i7Amc8vgpgNwR+kWUahV547mQe1qiyFHB4iuPKwi6MfPqWhr775sbl9NlKLvodBS 24 | rn0CgYBDrLH6ehNV/RnJIVZYQD6YcocYdYFy4u76mCYKmEP57XmstZHZXQgiRwbK 25 | Oy2Yg/qieKtSMjstgHFK6ZNYIR37l9J9Lh9aeal61+wW2dsGEy29Rhg01FpvKReq 26 | wCHz3tneUyaOhq9m0gKMOpWYcO+FBX1/2K5Gwj8FgEpu9r2b3w== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test-conf/client-ssl-mim.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Pulsar Client configuration 21 | webServiceUrl=https://localhost:8444/ 22 | brokerServiceUrl=pulsar+ssl://localhost:6653/ 23 | tlsAllowInsecureConnection=false 24 | tlsTrustCertsFilePath=test-conf/hn-verification/cacert.pem 25 | authPlugin=org.apache.pulsar.client.impl.auth.AuthenticationTls 26 | authParams=tlsCertFile:test-conf/client-cert.pem,tlsKeyFile:test-conf/client-key.pem 27 | -------------------------------------------------------------------------------- /test-conf/client-ssl.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Pulsar Client configuration 21 | webServiceUrl=https://localhost:8443/ 22 | brokerServiceUrl=pulsar+ssl://localhost:6651/ 23 | tlsAllowInsecureConnection=false 24 | tlsTrustCertsFilePath=test-conf/cacert.pem 25 | authPlugin=org.apache.pulsar.client.impl.auth.AuthenticationTls 26 | authParams=tlsCertFile:test-conf/client-cert.pem,tlsKeyFile:test-conf/client-key.pem 27 | -------------------------------------------------------------------------------- /test-conf/client.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # Pulsar Client configuration 21 | webServiceUrl=http://localhost:8765/ 22 | brokerServiceUrl=pulsar://localhost:8885/ 23 | #authPlugin= 24 | #authParams= 25 | #useTls= 26 | #tlsAllowInsecureConnection 27 | #tlsTrustCertsFilePath 28 | -------------------------------------------------------------------------------- /test-conf/cpp_credentials_file.json: -------------------------------------------------------------------------------- 1 | { 2 | "issuer_url": "https://dev-kt-aa9ne.us.auth0.com", 3 | "audience": "https://dev-kt-aa9ne.us.auth0.com/api/v2/", 4 | "client_id":"Xd23RHsUnvUlP7wchjNYOaIfazgeHd9x", 5 | "client_secret":"rT7ps7WY8uhdVuBTKWZkttwLdQotmdEliaM5rLfmgNibvqziZ-g07ZH52N_poGAb" 6 | } 7 | -------------------------------------------------------------------------------- /test-conf/hn-verification/broker-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEkDCCAnigAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwETEPMA0GA1UEAwwGZm9v 3 | YmFyMCAXDTE4MDYyMjA4NTUzMloYDzIyOTIwNDA2MDg1NTMyWjAjMSEwHwYDVQQD 4 | DBhicm9rZXIucHVsc2FyLmFwYWNoZS5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB 5 | DwAwggEKAoIBAQDQouKhZah4hMCqmg4aS5RhQG/Y1gA+yP9DGF9mlw35tfhfWs63 6 | EvNjEK4L/ZWSEV45L/wc6YV14RmM6bJ0V/0vXo4xmISbqptND/2kRIspkLZQ5F0O 7 | OQXVicqZLOc6igZQhRg8ANDYdTJUTF65DqauX4OJt3YMhF2FSt7jQtlj06IQBa01 8 | +ARO9OotMJtBY+vIU5bV6JydfgkhQH9rIDI7AMeY5j02gGkJJrelfm+WoOsUez+X 9 | aqTN3/tF8+MBcFB3G04s1qc2CJPJM3YGxvxEtHqTGI14t9J8p5O7X9JHpcY8X00s 10 | bxa4FGbKgfDobbkJ+GgblWCkAcLN95sKTqtHAgMBAAGjgd0wgdowCQYDVR0TBAIw 11 | ADARBglghkgBhvhCAQEEBAMCBkAwMwYJYIZIAYb4QgENBCYWJE9wZW5TU0wgR2Vu 12 | ZXJhdGVkIFNlcnZlciBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUaxFvJrkEGqk8azTA 13 | DyVyTyTbJAIwQQYDVR0jBDowOIAUVwvpyyPov0c+UHo/RX6hGEOdFSehFaQTMBEx 14 | DzANBgNVBAMMBmZvb2JhcoIJANfih0+geeIMMA4GA1UdDwEB/wQEAwIFoDATBgNV 15 | HSUEDDAKBggrBgEFBQcDATANBgkqhkiG9w0BAQsFAAOCAgEA35QDGclHzQtHs3yQ 16 | ZzNOSKisg5srTiIoQgRzfHrXfkthNFCnBzhKjBxqk3EIasVtvyGuk0ThneC1ai3y 17 | ZK3BivnMZfm1SfyvieFoqWetsxohWfcpOSVkpvO37P6v/NmmaTIGkBN3gxKCx0QN 18 | zqApLQyNTM++X3wxetYH/afAGUrRmBGWZuJheQpB9yZ+FB6BRp8YuYIYBzANJyW9 19 | spvXW03TpqX2AIoRBoGMLzK72vbhAbLWiCIfEYREhbZVRkP+yvD338cWrILlOEur 20 | x/n8L/FTmbf7mXzHg4xaQ3zg/5+0OCPMDPUBE4xWDBAbZ82hgOcTqfVjwoPgo2V0 21 | fbbx6redq44J3Vn5d9Xhi59fkpqEjHpX4xebr5iMikZsNTJMeLh0h3uf7DstuO9d 22 | mfnF5j+yDXCKb9XzCsTSvGCN+spmUh6RfSrbkw8/LrRvBUpKVEM0GfKSnaFpOaSS 23 | efM4UEi72FRjszzHEkdvpiLhYvihINLJmDXszhc3fCi42be/DGmUhuhTZWynOPmp 24 | 0N0V/8/sGT5gh4fGEtGzS/8xEvZwO9uDlccJiG8Pi+aO0/K9urB9nppd/xKWXv3C 25 | cib/QrW0Qow4TADWC1fnGYCpFzzaZ2esPL2MvzOYXnW4/AbEqmb6Weatluai64ZK 26 | 3N2cGJWRyvpvvmbP2hKCa4eLgEc= 27 | -----END CERTIFICATE----- 28 | -------------------------------------------------------------------------------- /test-conf/private-key.client-ecdsa.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | MIGXAgEBMBwGByqGSM49AQECEQD////9////////////////MDsEEP////3///// 3 | //////////wEEOh1ecEQefQ92CSZPCzuXtMDFQAADg1NaW5naHVhUXUMwDpEc9A2 4 | eQQhBBYf91KLiZstDChgfKUsW4bPWsg5W6/rE8AtopLd7XqDAhEA/////gAAAAB1 5 | ow0bkDihFQIBAQ== 6 | -----END EC PARAMETERS----- 7 | -----BEGIN EC PRIVATE KEY----- 8 | MIHYAgEBBBDeu9hc8kOvL3pl+LYSjLq9oIGaMIGXAgEBMBwGByqGSM49AQECEQD/ 9 | ///9////////////////MDsEEP////3///////////////wEEOh1ecEQefQ92CSZ 10 | PCzuXtMDFQAADg1NaW5naHVhUXUMwDpEc9A2eQQhBBYf91KLiZstDChgfKUsW4bP 11 | Wsg5W6/rE8AtopLd7XqDAhEA/////gAAAAB1ow0bkDihFQIBAaEkAyIABOsqPpE8 12 | cY80pxkog5xw3i2AQ0yfV3MqMusxlOQnigBp 13 | -----END EC PRIVATE KEY----- 14 | -------------------------------------------------------------------------------- /test-conf/public-key.client-ecdsa.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIHKMIGjBgcqhkjOPQIBMIGXAgEBMBwGByqGSM49AQECEQD////9//////////// 3 | ////MDsEEP////3///////////////wEEOh1ecEQefQ92CSZPCzuXtMDFQAADg1N 4 | aW5naHVhUXUMwDpEc9A2eQQhBBYf91KLiZstDChgfKUsW4bPWsg5W6/rE8AtopLd 5 | 7XqDAhEA/////gAAAAB1ow0bkDihFQIBAQMiAATrKj6RPHGPNKcZKIOccN4tgENM 6 | n1dzKjLrMZTkJ4oAaQ== 7 | -----END PUBLIC KEY----- 8 | -------------------------------------------------------------------------------- /test-conf/public-key.client-mismatch-rsa.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtKWwgqdnTYrOCv+j1MkT 3 | WfSH0wCsHZZca9wAW3qP4uuhlBvnb10JcFf5ZjzP9BSXK+tHmI8uoN368vEv6yhU 4 | RHM4yuXqzCxzuAwkQSo39rzX8PGC7qdjCN7LDJ3MnqiBIrUsSaEP1wrNsB1kI+o9 5 | ER1e5O/uEPAotP933hHQ0J2hMEekHqL7sBlJ98h6NmsicEaUkardk0TOXrlkjC+c 6 | Md8ZbGScPqI9M38bmn3OLxFTn1vthpvnXLvCmG4M+6xtYtD+npcVPZw1i1R90fMs 7 | 7ppZnRbv8Hc/DFdOKVQIgam6CDdnNKgW7c7IBMrP0AEm37HTu0LSOjP2OHXlvvlQ 8 | GQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /test-conf/public-key.client-rsa.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtKWwgqdnTYrOCv+j1MkT 3 | WfSH0wCsHZZca9wAW3qP4uuhlBvnb10JcFf5ZjzP9BSXK+tHmI8uoN368vEv6yhU 4 | RHM4yuXqzCxzuAwkQSo39rzX8PGC7qdjCN7LDJ3MnqiBIrUsSaEP1wrNsB1kI+o9 5 | ER1e5O/uEPAotP933hHQ0J2hMEekHqL7sBlJ98h6NmsicEaUkardk0TOXrlkjC+c 6 | Md8ZbGScPqI9M38bmn3OLxFTn1vthpvnXLvCmG4M+6xtYtD+npcVPZw1i1R90fMs 7 | 7ppZnRbv8Hc/DFdOKVQIgam6CDdnNKgW7c7IBMrP0AEm37HTu0LSOjP2OHXlvvlQ 8 | GQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /tests/Base64Test.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include 22 | 23 | #include "lib/Base64Utils.h" 24 | 25 | using namespace pulsar; 26 | 27 | TEST(Base64Test, testJsonEncodeDecode) { 28 | const std::string s1 = R"("{"key":"value"}")"; 29 | const auto s2 = base64::decode(base64::encode(s1)); 30 | ASSERT_EQ(s1, s2); 31 | } 32 | 33 | TEST(Base64Test, testPaddings) { 34 | auto encode = [](const char* s) { return base64::encode(s, strlen(s)); }; 35 | ASSERT_EQ(encode("x"), "eA=="); // 2 paddings 36 | ASSERT_EQ(encode("xy"), "eHk="); // 1 padding 37 | ASSERT_EQ(encode("xyz"), "eHl6"); // 0 padding 38 | } 39 | -------------------------------------------------------------------------------- /tests/BatchReceivePolicyTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | #include 21 | 22 | using namespace pulsar; 23 | 24 | TEST(BatchReceivePolicyTest, testBatchReceivePolicy) { 25 | ASSERT_THROW(BatchReceivePolicy(-1, -1, -1), std::invalid_argument); 26 | 27 | { 28 | BatchReceivePolicy batchReceivePolicy; 29 | ASSERT_EQ(batchReceivePolicy.getMaxNumMessages(), -1); 30 | ASSERT_EQ(batchReceivePolicy.getMaxNumBytes(), 10 * 1024 * 1024); 31 | ASSERT_EQ(batchReceivePolicy.getTimeoutMs(), 100); 32 | } 33 | 34 | { 35 | BatchReceivePolicy batchReceivePolicy(-1, -1, 123); 36 | ASSERT_EQ(batchReceivePolicy.getMaxNumMessages(), -1); 37 | ASSERT_EQ(batchReceivePolicy.getMaxNumBytes(), 10 * 1024 * 1024); 38 | ASSERT_EQ(batchReceivePolicy.getTimeoutMs(), 123); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | if (INTEGRATE_VCPKG) 21 | include(BuildTests.cmake) 22 | else () 23 | include(LegacyBuildTests.cmake) 24 | endif () 25 | -------------------------------------------------------------------------------- /tests/CompressionCodecSnappyTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "lib/CompressionCodecSnappy.h" 22 | 23 | using namespace pulsar; 24 | 25 | TEST(CompressionCodecSnappyTest, testEncodeAndDecode) { 26 | CompressionCodecSnappy compressionCodecSnappy; 27 | char data[] = "snappy compression compresses snappy"; 28 | size_t sz = sizeof(data); 29 | SharedBuffer source = SharedBuffer::wrap(data, sz); 30 | SharedBuffer compressed = compressionCodecSnappy.encode(source); 31 | ASSERT_GT(compressed.readableBytes(), 0); 32 | 33 | SharedBuffer uncompressed; 34 | bool res = compressionCodecSnappy.decode(compressed, static_cast(sz), uncompressed); 35 | ASSERT_TRUE(res); 36 | ASSERT_EQ(uncompressed.readableBytes(), sz); 37 | ASSERT_STREQ(data, uncompressed.data()); 38 | } 39 | -------------------------------------------------------------------------------- /tests/ConsumerWrapper.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include "ConsumerWrapper.h" 20 | 21 | #include "PulsarFriend.h" 22 | 23 | unsigned long ConsumerWrapper::getNumAcked(CommandAck_AckType ackType) const { 24 | try { 25 | return PulsarFriend::getConsumerStatsPtr(consumer_)->getAckedMsgMap().at( 26 | std::make_pair(ResultOk, ackType)); 27 | } catch (const std::out_of_range&) { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/HttpHelper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #ifndef HTTP_HELPER 20 | #define HTTP_HELPER 21 | 22 | #include 23 | 24 | int makePutRequest(const std::string& url, const std::string& body); 25 | int makePostRequest(const std::string& url, const std::string& body); 26 | int makeDeleteRequest(const std::string& url); 27 | int makeGetRequest(const std::string& url, const std::string& responseData); 28 | 29 | #endif /* end of include guard: HTTP_HELPER */ 30 | -------------------------------------------------------------------------------- /tests/Int64SerDesTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "lib/Int64SerDes.h" 22 | 23 | using namespace pulsar; 24 | 25 | TEST(Int64SerDes, testNormal) { 26 | int64_t x = 0x0102030405060708L; 27 | const auto bytes = toBigEndianBytes(x); 28 | ASSERT_EQ(bytes.size(), 8); 29 | for (int i = 0; i < 8; i++) { 30 | ASSERT_EQ(bytes[i], i + 1); 31 | } 32 | int64_t y = fromBigEndianBytes(bytes.data()); 33 | ASSERT_EQ(x, y); 34 | } 35 | 36 | TEST(Int64SerDes, testOverflow) { 37 | int64_t x = 0x8000000000000000L; 38 | const auto bytes = toBigEndianBytes(x); 39 | ASSERT_EQ(bytes.size(), 8); 40 | ASSERT_EQ(static_cast(bytes[0]), 0x80); 41 | for (int i = 1; i < 8; i++) { 42 | ASSERT_EQ(bytes[i], 0x00); 43 | } 44 | int64_t y = fromBigEndianBytes(bytes); 45 | ASSERT_EQ(x, y); 46 | } 47 | -------------------------------------------------------------------------------- /tests/LogHelper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | template 26 | inline std::ostream& operator<<(std::ostream& os, const std::map& m) { 27 | os << "{"; 28 | bool first = true; 29 | for (const auto& kv : m) { 30 | if (!first) { 31 | os << ", "; 32 | } else { 33 | first = false; 34 | } 35 | os << kv.first << " => " << kv.second; 36 | } 37 | os << "}"; 38 | return os; 39 | } 40 | -------------------------------------------------------------------------------- /tests/LoggerTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "lib/LogUtils.h" 22 | 23 | DECLARE_LOG_OBJECT() 24 | 25 | TEST(LoggerTest, testLogger) { 26 | LOG_DEBUG("Testing logger..."); 27 | int a = 5; 28 | LOG_INFO("Testing logger with arguments " << a); 29 | } 30 | -------------------------------------------------------------------------------- /tests/NoOpsCryptoKeyReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | namespace pulsar { 22 | 23 | class NoOpsCryptoKeyReader : public CryptoKeyReader { 24 | public: 25 | Result getPublicKey(const std::string& keyName, std::map& metadata, 26 | EncryptionKeyInfo& encKeyInfo) const override { 27 | return ResultOk; 28 | } 29 | 30 | Result getPrivateKey(const std::string& keyName, std::map& metadata, 31 | EncryptionKeyInfo& encKeyInfo) const override { 32 | return ResultOk; 33 | } 34 | }; 35 | 36 | } // namespace pulsar 37 | -------------------------------------------------------------------------------- /tests/PaddingDemo.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | syntax = "proto3"; 20 | 21 | package padding.demo; 22 | 23 | message Person { 24 | string name = 1; 25 | int32 id = 2; 26 | } 27 | -------------------------------------------------------------------------------- /tests/PulsarAdminHelper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #include "HttpHelper.h" 25 | 26 | namespace pulsar { 27 | 28 | inline std::string getTopicStats(const std::string& topic, boost::property_tree::ptree& root) { 29 | const auto url = "http://localhost:8080/admin/v2/persistent/public/default/" + topic + "/stats"; 30 | std::string responseData; 31 | int code = makeGetRequest(url, responseData); 32 | if (code != 200) { 33 | return url + " failed: " + std::to_string(code); 34 | } 35 | 36 | std::stringstream stream; 37 | stream << responseData; 38 | boost::property_tree::read_json(stream, root); 39 | return ""; 40 | } 41 | 42 | } // namespace pulsar 43 | -------------------------------------------------------------------------------- /tests/PulsarWrapper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include "lib/ClientConfigurationImpl.h" 22 | #include "pulsar/ClientConfiguration.h" 23 | 24 | namespace pulsar { 25 | 26 | class PulsarWrapper { 27 | public: 28 | static ClientConfigurationImpl& deref(ClientConfiguration conf) { return *conf.impl_; } 29 | }; 30 | 31 | } // namespace pulsar 32 | -------------------------------------------------------------------------------- /tests/SynchronizedQueue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | template 25 | class SynchronizedQueue { 26 | public: 27 | void push(const T& value) { 28 | std::lock_guard lock{mutex_}; 29 | queue_.push(value); 30 | } 31 | 32 | T pop() { 33 | std::lock_guard lock{mutex_}; 34 | auto value = queue_.front(); 35 | queue_.pop(); 36 | return value; 37 | } 38 | 39 | size_t size() const { 40 | std::lock_guard lock{mutex_}; 41 | return queue_.size(); 42 | } 43 | 44 | private: 45 | mutable std::mutex mutex_; 46 | std::queue queue_; 47 | }; 48 | -------------------------------------------------------------------------------- /tests/TopicMetadataImplTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | #include 21 | 22 | #include "lib/TopicMetadataImpl.h" 23 | 24 | using namespace pulsar; 25 | 26 | TEST(TopicMetadataImplTest, numPartitions) { 27 | TopicMetadataImpl topicMetadata(1234); 28 | ASSERT_EQ(1234, topicMetadata.getNumPartitions()); 29 | } 30 | -------------------------------------------------------------------------------- /tests/VersionTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | #include 21 | 22 | TEST(VersionTest, testMacro) { 23 | #ifdef PULSAR_VERSION 24 | ASSERT_GE(PULSAR_VERSION, 2000000); 25 | ASSERT_LE(PULSAR_VERSION, 999999999); 26 | #else 27 | FAIL(); 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /tests/c/c_MessageTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | #include 21 | #include 22 | 23 | TEST(c_MessageTest, MessageCopy) { 24 | pulsar_message_t *from = pulsar_message_create(); 25 | pulsar_message_set_content(from, "hello", 5); 26 | from->message = from->builder.build(); 27 | pulsar_message_t *to = pulsar_message_create(); 28 | 29 | pulsar_message_copy(from, to); 30 | ASSERT_STREQ((const char *)pulsar_message_get_data(to), (const char *)pulsar_message_get_data(from)); 31 | 32 | pulsar_message_free(from); 33 | pulsar_message_free(to); 34 | } 35 | -------------------------------------------------------------------------------- /tests/c/c_ProducerConfigurationTest.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | #include 21 | 22 | TEST(C_ProducerConfigurationTest, testCApiConfig) { 23 | pulsar_producer_configuration_t *producer_conf = pulsar_producer_configuration_create(); 24 | 25 | ASSERT_EQ(pulsar_producer_configuration_is_chunking_enabled(producer_conf), 0); 26 | pulsar_producer_configuration_set_chunking_enabled(producer_conf, 1); 27 | ASSERT_EQ(pulsar_producer_configuration_is_chunking_enabled(producer_conf), 1); 28 | 29 | pulsar_producer_configuration_set_access_mode(producer_conf, pulsar_ProducerAccessModeExclusive); 30 | ASSERT_EQ(pulsar_producer_configuration_get_access_mode(producer_conf), 31 | pulsar_ProducerAccessModeExclusive); 32 | } 33 | -------------------------------------------------------------------------------- /tests/main.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | int main(int argc, char **argv) { 22 | ::testing::InitGoogleMock(&argc, argv); 23 | return RUN_ALL_TESTS(); 24 | } 25 | -------------------------------------------------------------------------------- /tests/mocks/GMockMessage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef MOCK_MESSAGE_HPP_ 21 | #define MOCK_MESSAGE_HPP_ 22 | 23 | #include 24 | #include 25 | 26 | namespace pulsar { 27 | // TODO: For the mock tests, we need to make all methods and destructor virtual in Message class 28 | class GMockMessage : public Message { 29 | public: 30 | MOCK_CONST_METHOD0(hasPartitionKey, bool()); 31 | 32 | MOCK_CONST_METHOD0(getPartitionKey, const std::string&()); 33 | }; 34 | } // namespace pulsar 35 | 36 | #endif // MOCK_MESSAGE_HPP_ 37 | -------------------------------------------------------------------------------- /tests/proto/ExternalTest.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | syntax = "proto3"; 20 | package proto.external; 21 | 22 | option java_package = "org.apache.pulsar.client.schema.proto"; 23 | option java_outer_classname = "ExternalTest"; 24 | 25 | message ExternalMessage { 26 | string stringField = 1; 27 | double doubleField = 2; 28 | } -------------------------------------------------------------------------------- /tests/proto/Test.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | syntax = "proto3"; 20 | package proto; 21 | 22 | import "ExternalTest.proto"; 23 | 24 | option java_package = "org.apache.pulsar.client.schema.proto"; 25 | option java_outer_classname = "Test"; 26 | 27 | enum TestEnum { 28 | SHARED = 0; 29 | FAILOVER = 1; 30 | } 31 | 32 | message SubMessage { 33 | string foo = 1; 34 | double bar = 2; 35 | message NestedMessage { 36 | string url = 1; 37 | string title = 2; 38 | repeated string snippets = 3; 39 | } 40 | } 41 | 42 | message TestMessage { 43 | string stringField = 1; 44 | double doubleField = 2; 45 | int32 intField = 6; 46 | TestEnum testEnum = 4; 47 | SubMessage nestedField = 5; 48 | repeated string repeatedField = 10; 49 | proto.external.ExternalMessage externalMessage = 11; 50 | } -------------------------------------------------------------------------------- /vcpkg-example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | if (NOT CMAKE_TOOLCHAIN_FILE) 4 | set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../vcpkg/scripts/buildsystems/vcpkg.cmake") 5 | endif () 6 | if (VCPKG_TARGET_TRIPLET MATCHES ".*windows-static") 7 | cmake_policy(SET CMP0091 NEW) 8 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 9 | endif () 10 | project(PulsarDemo CXX) 11 | 12 | if (NOT CMAKE_CXX_STANDARD) 13 | set(CMAKE_CXX_STANDARD 11) 14 | endif () 15 | 16 | find_package(unofficial-pulsar CONFIG) 17 | add_executable(main main.cc) 18 | target_link_libraries(main PRIVATE unofficial::pulsar::pulsar) 19 | -------------------------------------------------------------------------------- /vcpkg-example/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace pulsar; 3 | 4 | int main(int argc, char *argv[]) { 5 | Client client{"pulsar://localhost:6650"}; 6 | client.close(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /vcpkg-example/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vcpkg-pulsar-demo", 3 | "version-string": "0.1.0", 4 | "builtin-baseline": "38d1652f152d36481f2f4e8a85c0f1e14f3769f7", 5 | "dependencies": [ 6 | { 7 | "name": "pulsar-client-cpp", 8 | "version>=": "3.4.2#1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /vcpkg-triplets/arm64-osx.cmake: -------------------------------------------------------------------------------- 1 | set(VCPKG_TARGET_ARCHITECTURE arm64) 2 | set(VCPKG_CRT_LINKAGE dynamic) 3 | set(VCPKG_LIBRARY_LINKAGE static) 4 | 5 | set(VCPKG_CMAKE_SYSTEM_NAME Darwin) 6 | set(VCPKG_OSX_ARCHITECTURES arm64) 7 | set(VCPKG_OSX_DEPLOYMENT_TARGET 13.0) 8 | 9 | set(VCPKG_BUILD_TYPE release) 10 | -------------------------------------------------------------------------------- /vcpkg-triplets/x64-osx.cmake: -------------------------------------------------------------------------------- 1 | set(VCPKG_TARGET_ARCHITECTURE x64) 2 | set(VCPKG_CRT_LINKAGE dynamic) 3 | set(VCPKG_LIBRARY_LINKAGE static) 4 | 5 | set(VCPKG_CMAKE_SYSTEM_NAME Darwin) 6 | set(VCPKG_OSX_ARCHITECTURES x86_64) 7 | set(VCPKG_OSX_DEPLOYMENT_TARGET 13.0) 8 | 9 | set(VCPKG_BUILD_TYPE release) 10 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 3.8.0-pre 2 | -------------------------------------------------------------------------------- /win-examples/example.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | using namespace pulsar; 21 | 22 | int main() { 23 | Client client("pulsar://localhost:6650"); 24 | client.close(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /wireshark/pulsar-dissector-example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/pulsar-client-cpp/b0c44122b389ddf8e2ff9f3bd3d8a4e5d00dcc37/wireshark/pulsar-dissector-example.jpg -------------------------------------------------------------------------------- /wireshark/wireshark-plugins.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/pulsar-client-cpp/b0c44122b389ddf8e2ff9f3bd3d8a4e5d00dcc37/wireshark/wireshark-plugins.jpg --------------------------------------------------------------------------------