pulsar-client-cpp
Loading...
Searching...
No Matches
producer_configuration.h
1
20#pragma once
21
22#include <pulsar/c/message_router.h>
23#include <pulsar/defines.h>
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30typedef enum
31{
32 pulsar_UseSinglePartition,
33 pulsar_RoundRobinDistribution,
34 pulsar_CustomPartition
35} pulsar_partitions_routing_mode;
36
37typedef enum
38{
39 pulsar_Murmur3_32Hash,
40 pulsar_BoostHash,
41 pulsar_JavaStringHash
42} pulsar_hashing_scheme;
43
44typedef enum
45{
46 pulsar_CompressionNone = 0,
47 pulsar_CompressionLZ4 = 1,
48 pulsar_CompressionZLib = 2,
49 pulsar_CompressionZSTD = 3,
50 pulsar_CompressionSNAPPY = 4
51} pulsar_compression_type;
52
53typedef enum
54{
55 pulsar_None = 0,
56 pulsar_String = 1,
57 pulsar_Json = 2,
58 pulsar_Protobuf = 3,
59 pulsar_Avro = 4,
60 pulsar_Boolean = 5,
61 pulsar_Int8 = 6,
62 pulsar_Int16 = 7,
63 pulsar_Int32 = 8,
64 pulsar_Int64 = 9,
65 pulsar_Float32 = 10,
66 pulsar_Float64 = 11,
67 pulsar_KeyValue = 15,
68 pulsar_Bytes = -1,
69 pulsar_AutoConsume = -3,
70 pulsar_AutoPublish = -4,
71} pulsar_schema_type;
72
73typedef enum
74{
75 // This is the default option to fail send if crypto operation fails
76 pulsar_ProducerFail,
77 // Ignore crypto failure and proceed with sending unencrypted messages
78 pulsar_ProducerSend
79} pulsar_producer_crypto_failure_action;
80
81typedef enum
82{
83 // By default multiple producers can publish on a topic.
84 pulsar_ProducerAccessModeShared = 0,
85 // Require exclusive access for producer.
86 // Fail immediately if there's already a producer connected.
87 pulsar_ProducerAccessModeExclusive = 1,
88 // Producer creation is pending until it can acquire exclusive access.
89 pulsar_ProducerAccessModeWaitForExclusive = 2,
90 // Acquire exclusive access for the producer.
91 // Any existing producer will be removed and invalidated immediately.
92 pulsar_ProducerAccessModeExclusiveWithFencing = 3
93
94} pulsar_producer_access_mode;
95
96typedef struct _pulsar_producer_configuration pulsar_producer_configuration_t;
97
98typedef struct _pulsar_crypto_key_reader pulsar_crypto_key_reader;
99
100PULSAR_PUBLIC pulsar_producer_configuration_t *pulsar_producer_configuration_create();
101
102PULSAR_PUBLIC void pulsar_producer_configuration_free(pulsar_producer_configuration_t *conf);
103
104PULSAR_PUBLIC void pulsar_producer_configuration_set_producer_name(pulsar_producer_configuration_t *conf,
105 const char *producerName);
106
107PULSAR_PUBLIC const char *pulsar_producer_configuration_get_producer_name(
108 pulsar_producer_configuration_t *conf);
109
110PULSAR_PUBLIC void pulsar_producer_configuration_set_send_timeout(pulsar_producer_configuration_t *conf,
111 int sendTimeoutMs);
112
113PULSAR_PUBLIC int pulsar_producer_configuration_get_send_timeout(pulsar_producer_configuration_t *conf);
114
115PULSAR_PUBLIC void pulsar_producer_configuration_set_initial_sequence_id(
116 pulsar_producer_configuration_t *conf, int64_t initialSequenceId);
117
118PULSAR_PUBLIC int64_t
119pulsar_producer_configuration_get_initial_sequence_id(pulsar_producer_configuration_t *conf);
120
121PULSAR_PUBLIC void pulsar_producer_configuration_set_compression_type(
122 pulsar_producer_configuration_t *conf, pulsar_compression_type compressionType);
123
124PULSAR_PUBLIC pulsar_compression_type
125pulsar_producer_configuration_get_compression_type(pulsar_producer_configuration_t *conf);
126
127PULSAR_PUBLIC void pulsar_producer_configuration_set_schema_info(pulsar_producer_configuration_t *conf,
128 pulsar_schema_type schemaType,
129 const char *name, const char *schema,
130 pulsar_string_map_t *properties);
131
132PULSAR_PUBLIC void pulsar_producer_configuration_set_max_pending_messages(
133 pulsar_producer_configuration_t *conf, int maxPendingMessages);
134PULSAR_PUBLIC int pulsar_producer_configuration_get_max_pending_messages(
135 pulsar_producer_configuration_t *conf);
136
145PULSAR_PUBLIC void pulsar_producer_configuration_set_max_pending_messages_across_partitions(
146 pulsar_producer_configuration_t *conf, int maxPendingMessagesAcrossPartitions);
147
152PULSAR_PUBLIC int pulsar_producer_configuration_get_max_pending_messages_across_partitions(
153 pulsar_producer_configuration_t *conf);
154
155PULSAR_PUBLIC void pulsar_producer_configuration_set_partitions_routing_mode(
156 pulsar_producer_configuration_t *conf, pulsar_partitions_routing_mode mode);
157
158PULSAR_PUBLIC pulsar_partitions_routing_mode
159pulsar_producer_configuration_get_partitions_routing_mode(pulsar_producer_configuration_t *conf);
160
161PULSAR_PUBLIC void pulsar_producer_configuration_set_message_router(pulsar_producer_configuration_t *conf,
162 pulsar_message_router router, void *ctx);
163
164PULSAR_PUBLIC void pulsar_producer_configuration_set_hashing_scheme(pulsar_producer_configuration_t *conf,
165 pulsar_hashing_scheme scheme);
166
167PULSAR_PUBLIC pulsar_hashing_scheme
168pulsar_producer_configuration_get_hashing_scheme(pulsar_producer_configuration_t *conf);
169
170PULSAR_PUBLIC void pulsar_producer_configuration_set_lazy_start_partitioned_producers(
171 pulsar_producer_configuration_t *conf, int useLazyStartPartitionedProducers);
172
173PULSAR_PUBLIC int pulsar_producer_configuration_get_lazy_start_partitioned_producers(
174 pulsar_producer_configuration_t *conf);
175
176PULSAR_PUBLIC void pulsar_producer_configuration_set_block_if_queue_full(
177 pulsar_producer_configuration_t *conf, int blockIfQueueFull);
178
179PULSAR_PUBLIC int pulsar_producer_configuration_get_block_if_queue_full(
180 pulsar_producer_configuration_t *conf);
181
182// Zero queue size feature will not be supported on consumer end if batching is enabled
183PULSAR_PUBLIC void pulsar_producer_configuration_set_batching_enabled(pulsar_producer_configuration_t *conf,
184 int batchingEnabled);
185
186PULSAR_PUBLIC int pulsar_producer_configuration_get_batching_enabled(pulsar_producer_configuration_t *conf);
187
188PULSAR_PUBLIC void pulsar_producer_configuration_set_batching_max_messages(
189 pulsar_producer_configuration_t *conf, unsigned int batchingMaxMessages);
190
191PULSAR_PUBLIC unsigned int pulsar_producer_configuration_get_batching_max_messages(
192 pulsar_producer_configuration_t *conf);
193
194PULSAR_PUBLIC void pulsar_producer_configuration_set_batching_max_allowed_size_in_bytes(
195 pulsar_producer_configuration_t *conf, unsigned long batchingMaxAllowedSizeInBytes);
196
197PULSAR_PUBLIC unsigned long pulsar_producer_configuration_get_batching_max_allowed_size_in_bytes(
198 pulsar_producer_configuration_t *conf);
199
200PULSAR_PUBLIC void pulsar_producer_configuration_set_batching_max_publish_delay_ms(
201 pulsar_producer_configuration_t *conf, unsigned long batchingMaxPublishDelayMs);
202
203PULSAR_PUBLIC unsigned long pulsar_producer_configuration_get_batching_max_publish_delay_ms(
204 pulsar_producer_configuration_t *conf);
205
206PULSAR_PUBLIC void pulsar_producer_configuration_set_property(pulsar_producer_configuration_t *conf,
207 const char *name, const char *value);
208
209PULSAR_PUBLIC int pulsar_producer_is_encryption_enabled(pulsar_producer_configuration_t *conf);
210
211PULSAR_PUBLIC void pulsar_producer_configuration_set_default_crypto_key_reader(
212 pulsar_producer_configuration_t *conf, const char *public_key_path, const char *private_key_path);
213
214PULSAR_PUBLIC pulsar_producer_crypto_failure_action
215pulsar_producer_configuration_get_crypto_failure_action(pulsar_producer_configuration_t *conf);
216
217PULSAR_PUBLIC void pulsar_producer_configuration_set_crypto_failure_action(
218 pulsar_producer_configuration_t *conf, pulsar_producer_crypto_failure_action cryptoFailureAction);
219
220PULSAR_PUBLIC void pulsar_producer_configuration_set_encryption_key(pulsar_producer_configuration_t *conf,
221 const char *key);
222
223PULSAR_PUBLIC void pulsar_producer_configuration_set_chunking_enabled(pulsar_producer_configuration_t *conf,
224 int chunkingEnabled);
225
226PULSAR_PUBLIC int pulsar_producer_configuration_is_chunking_enabled(pulsar_producer_configuration_t *conf);
227
228PULSAR_PUBLIC pulsar_producer_access_mode
229pulsar_producer_configuration_get_access_mode(pulsar_producer_configuration_t *conf);
230
231PULSAR_PUBLIC void pulsar_producer_configuration_set_access_mode(pulsar_producer_configuration_t *conf,
232 pulsar_producer_access_mode accessMode);
233
234// const CryptoKeyReaderPtr getCryptoKeyReader() const;
235// ProducerConfiguration &setCryptoKeyReader(CryptoKeyReaderPtr cryptoKeyReader);
236//
237// ProducerCryptoFailureAction getCryptoFailureAction() const;
238// ProducerConfiguration &setCryptoFailureAction(ProducerCryptoFailureAction action);
239//
240// std::set <std::string> &getEncryptionKeys();
241// int isEncryptionEnabled() const;
242// ProducerConfiguration &addEncryptionKey(std::string key);
243
244#ifdef __cplusplus
245}
246#endif