1#![warn(unreachable_pub)]
45#![forbid(unsafe_code)]
46
47#[cfg(feature = "admin")]
48pub use magnetar_admin as admin;
49pub use magnetar_proto as proto;
50pub use magnetar_proto::conn::{ConnectionConfig, OpOutcome};
51pub use magnetar_proto::{
54 AuthProvider, Backoff, ConnectionEvent, ConsumerHandle, MessageId, OperationRetryConfig,
55 ProducerHandle, ProtocolError, RequestId, SequenceId, SupervisorConfig,
56};
57#[cfg(feature = "moonpool")]
58pub use magnetar_runtime_moonpool as runtime_moonpool;
59#[cfg(feature = "tokio")]
60pub use magnetar_runtime_tokio as runtime_tokio;
61
62mod engine;
63#[cfg(feature = "moonpool")]
64pub use engine::MoonpoolEngine;
65#[cfg(feature = "tokio")]
66pub use engine::TokioEngine;
67#[cfg(feature = "tokio")]
68pub use engine::{
69 BrokerMetadataApi, ConsumerApi, CreateProducerApi, OpenProducerFut, OperationDeadline,
70 ProducerApi, ReceiveBatchFut, ReceiveOptFut, SubscribeApi, SubscribeFut, TopicListChange,
71 WatchTopicListFut,
72};
73pub use engine::{Engine, MessageDecryptorApi, MessageEncryptorApi, NoEncryption, TransactionApi};
74
75#[cfg(feature = "tokio")]
76mod auto_update_task;
77#[cfg(feature = "tokio")]
78mod builders;
79#[cfg(feature = "tokio")]
80mod client;
81#[cfg(feature = "tokio")]
82mod client_builder;
83#[cfg(feature = "tokio")]
84mod consumer_listener;
85#[cfg(feature = "tokio")]
86mod consumer_template;
87#[cfg(feature = "moonpool")]
88mod moonpool_client;
89#[cfg(feature = "tokio")]
90mod multi_topics;
91#[cfg(feature = "tokio")]
92mod partitioned_consumer;
93#[cfg(feature = "tokio")]
94mod partitioned_producer;
95#[cfg(feature = "tokio")]
96mod pattern_consumer;
97#[cfg(feature = "tokio")]
98mod table_view;
99#[cfg(feature = "tokio")]
100mod transaction;
101#[cfg(feature = "tokio")]
102mod typed;
103#[cfg(feature = "tokio")]
104pub use builders::{ConsumerBuilder, ProducerBuilder, ReaderBuilder};
105#[cfg(feature = "tokio")]
106pub use client::{
107 ConsumerInterceptor, IncomingMessage, MemoryLimit, MemoryLimitPolicy, MessageBuilder,
108 OutgoingMessage, ProducerExt, ProducerInterceptor, PulsarClient, PulsarError, Reader,
109 SeekTarget, ack_cumulative_with_interceptors, ack_with_interceptors, receive_with_interceptors,
110 send_with_interceptors,
111};
112#[cfg(feature = "tokio")]
113pub use client_builder::ClientBuilder;
114#[cfg(feature = "tokio")]
115pub use consumer_listener::{
116 ConsumerEvent, ConsumerEventListener, ConsumerEventListenerHandle, MessageListener,
117 MessageListenerHandle, WrapperMessageListener, WrapperReceiver, spawn_consumer_event_listener,
118 spawn_message_listener, spawn_wrapper_message_listener,
119};
120#[cfg(feature = "tokio")]
121pub use multi_topics::{MultiTopicsConsumer, MultiTopicsConsumerBuilder, MultiTopicsMessage};
122#[cfg(feature = "tokio")]
123pub use partitioned_consumer::{PartitionedConsumer, PartitionedConsumerBuilder};
124#[cfg(feature = "tokio")]
125pub use partitioned_producer::{
126 JavaStringHashHasher, MessageRouter, MessageRoutingMode, Murmur3HashHasher,
127 PartitionedMessageBuilder, PartitionedProducer, PartitionedProducerBuilder, java_string_hash,
128 murmur3_32_hash,
129};
130#[cfg(feature = "tokio")]
131pub use pattern_consumer::{
132 PatternConsumer, PatternConsumerBuilder, PatternMessage, ReconcileReport,
133};
134#[cfg(feature = "tokio")]
135pub use table_view::{
136 TableView, TableViewBuilder, TableViewListener, TypedTableView, TypedTableViewBuilder,
137};
138#[cfg(feature = "tokio")]
139pub use transaction::{Transaction, TxnState};
140#[cfg(feature = "tokio")]
141pub use typed::{
142 TypedConsumer, TypedConsumerBuilder, TypedMessage, TypedMessageBuilder, TypedMessageListener,
143 TypedProducer, TypedProducerBuilder,
144};
145
146#[cfg(all(feature = "tokio", feature = "encryption"))]
150mod crypto_bridge;
151#[cfg(all(feature = "tokio", feature = "encryption"))]
152pub use crypto_bridge::MessageCryptoBridge;
153
154#[cfg(feature = "opentelemetry")]
161pub mod otel;
162
163#[cfg(all(feature = "tokio", feature = "opentelemetry"))]
173#[inline]
174pub(crate) fn inject_otel_context(properties: &mut Vec<(String, String)>) {
175 otel::inject_context(properties);
176}
177
178#[cfg(all(feature = "tokio", not(feature = "opentelemetry")))]
180#[inline]
181#[allow(clippy::ptr_arg)]
182pub(crate) fn inject_otel_context(properties: &mut Vec<(String, String)>) {
183 let _ = properties;
184}
185
186#[cfg(feature = "experimental-v5-client")]
191pub mod v5;
192
193#[cfg(all(feature = "tokio", feature = "scalable-topics"))]
199pub mod scalable;
200#[cfg(all(feature = "tokio", feature = "scalable-topics"))]
201pub use engine::{ScalableEvent, ScalableLookup, ScalableTopicsApi};
202
203#[cfg(test)]
204mod tests {
205 #[test]
206 fn proto_reexport_compiles() {
207 let _conn = crate::proto::Connection::new(
208 crate::proto::ConnectionConfig::default(),
209 std::sync::Arc::new(std::time::SystemTime::now),
210 );
211 }
212
213 #[cfg(feature = "tokio")]
214 #[test]
215 fn builder_compiles() {
216 let _ = crate::PulsarClient::builder().service_url("pulsar://localhost:6650");
217 }
218
219 fn assert_transaction_api_bound<T: crate::TransactionApi>() {}
227
228 #[cfg(feature = "tokio")]
229 #[test]
230 fn transaction_api_is_implemented_by_tokio_client() {
231 assert_transaction_api_bound::<magnetar_runtime_tokio::Client>();
234 }
235
236 #[cfg(feature = "moonpool")]
237 #[test]
238 fn transaction_api_is_implemented_by_moonpool_client() {
239 assert_transaction_api_bound::<
244 magnetar_runtime_moonpool::Client<moonpool_core::TokioProviders>,
245 >();
246 }
247
248 #[cfg(feature = "tokio")]
253 fn assert_producer_api_bound<T: crate::ProducerApi>() {}
254
255 #[cfg(feature = "tokio")]
256 fn assert_consumer_api_bound<T: crate::ConsumerApi>() {}
257
258 #[cfg(feature = "tokio")]
259 #[test]
260 fn producer_api_is_implemented_by_tokio_producer() {
261 assert_producer_api_bound::<magnetar_runtime_tokio::Producer>();
262 }
263
264 #[cfg(feature = "tokio")]
265 #[test]
266 fn consumer_api_is_implemented_by_tokio_consumer() {
267 assert_consumer_api_bound::<magnetar_runtime_tokio::Consumer>();
268 }
269
270 #[cfg(all(feature = "tokio", feature = "moonpool"))]
271 #[test]
272 fn producer_api_is_implemented_by_moonpool_producer() {
273 assert_producer_api_bound::<
275 magnetar_runtime_moonpool::Producer<moonpool_core::TokioProviders>,
276 >();
277 }
278
279 #[cfg(all(feature = "tokio", feature = "moonpool"))]
280 #[test]
281 fn consumer_api_is_implemented_by_moonpool_consumer() {
282 assert_consumer_api_bound::<
283 magnetar_runtime_moonpool::Consumer<moonpool_core::TokioProviders>,
284 >();
285 }
286
287 #[cfg(feature = "tokio")]
293 fn assert_subscribe_api_bound<T: crate::SubscribeApi>() {}
294
295 #[cfg(feature = "tokio")]
296 fn assert_create_producer_api_bound<T: crate::CreateProducerApi>() {}
297
298 #[cfg(feature = "tokio")]
299 #[test]
300 fn subscribe_api_is_implemented_by_tokio_client() {
301 assert_subscribe_api_bound::<magnetar_runtime_tokio::Client>();
302 }
303
304 #[cfg(feature = "tokio")]
305 #[test]
306 fn create_producer_api_is_implemented_by_tokio_client() {
307 assert_create_producer_api_bound::<magnetar_runtime_tokio::Client>();
308 }
309
310 #[cfg(all(feature = "tokio", feature = "moonpool"))]
311 #[test]
312 fn subscribe_api_is_implemented_by_moonpool_client() {
313 assert_subscribe_api_bound::<
314 magnetar_runtime_moonpool::Client<moonpool_core::TokioProviders>,
315 >();
316 }
317
318 #[cfg(all(feature = "tokio", feature = "moonpool"))]
319 #[test]
320 fn create_producer_api_is_implemented_by_moonpool_client() {
321 assert_create_producer_api_bound::<
322 magnetar_runtime_moonpool::Client<moonpool_core::TokioProviders>,
323 >();
324 }
325}