NATS C Client with JetStream and Streaming support  3.2.0
The nats.io C Client, Supported by Synadia Communications Inc.
nats.h
Go to the documentation of this file.
1// Copyright 2015-2021 The NATS Authors
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef NATS_H_
15#define NATS_H_
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <stdlib.h>
22#include <stdint.h>
23#include <stdbool.h>
24#include <inttypes.h>
25#include <stdio.h>
26
27#include "status.h"
28#include "version.h"
29
37#if defined(_WIN32)
38 #include <winsock2.h>
39 #if defined(nats_EXPORTS)
40 #define NATS_EXTERN __declspec(dllexport)
41 #elif defined(nats_IMPORTS)
42 #define NATS_EXTERN __declspec(dllimport)
43 #else
44 #define NATS_EXTERN
45 #endif
46
47 typedef SOCKET natsSock;
48#else
49 #define NATS_EXTERN
50 typedef int natsSock;
51#endif
52
86#define NATS_DEFAULT_URL "nats://localhost:4222"
87
97 #define JSMsgSize "Nats-Msg-Size"
98
111 #define JSMsgRollup "Nats-Rollup"
112
120 #define JSMsgRollupSubject "sub"
121
129 #define JSMsgRollupAll "all"
130
131//
132// Types.
133//
145typedef struct __natsConnection natsConnection;
146
152typedef struct __natsStatistics natsStatistics;
153
158typedef struct __natsSubscription natsSubscription;
159
165typedef struct __natsMsg natsMsg;
166
171typedef struct __natsOptions natsOptions;
172
180typedef char natsInbox;
181
205typedef struct natsMsgList
206{
208 const int Count;
209
211
220typedef struct __jsCtx jsCtx;
221
237typedef struct jsPubOptions
238{
239 int64_t MaxWait;
240 const char *MsgId;
241 const char *ExpectStream;
242 const char *ExpectLastMsgId;
243 uint64_t ExpectLastSeq;
246
248
252typedef enum
253{
257
259
263typedef enum
264{
267
269
273typedef enum
274{
277
279
283typedef enum
284{
291
293
297typedef enum
298{
302
303
305
309typedef enum
310{
313
315
316
328typedef struct jsPlacement
329{
330 const char *Cluster;
331 const char **Tags;
333
335
345typedef struct jsExternalStream
346{
347 const char *APIPrefix;
348 const char *DeliverPrefix;
349
351
364typedef struct jsStreamSource
365{
366 const char *Name;
367 uint64_t OptStartSeq;
368 int64_t OptStartTime;
369 const char *FilterSubject;
371
373
443typedef struct jsStreamConfig {
444 const char *Name;
445 const char *Description;
446 const char **Subjects;
450 int64_t MaxMsgs;
451 int64_t MaxBytes;
452 int64_t MaxAge;
454 int32_t MaxMsgSize;
457 int64_t Replicas;
458 bool NoAck;
459 const char *Template;
460 int64_t Duplicates;
465 bool Sealed;
473
475
479typedef struct jsLostStreamData
480{
481 uint64_t *Msgs;
483 uint64_t Bytes;
484
486
493typedef struct jsStreamState
494{
495 uint64_t Msgs;
496 uint64_t Bytes;
497 uint64_t FirstSeq;
498 int64_t FirstTime;
499 uint64_t LastSeq;
500 int64_t LastTime;
501 uint64_t NumDeleted;
502 uint64_t *Deleted;
505 int64_t Consumers;
506
508
513typedef struct jsPeerInfo
514{
515 char *Name;
518 int64_t Active;
519 uint64_t Lag;
520
522
527typedef struct jsClusterInfo
528{
529 char *Name;
530 char *Leader;
533
535
539typedef struct jsStreamSourceInfo
540{
541 char *Name;
543 uint64_t Lag;
544 int64_t Active;
545
547
554typedef struct jsStreamInfo
555{
557 int64_t Created;
563
565
602typedef struct jsConsumerConfig
603{
604 const char *Durable;
605 const char *Description;
606 const char *DeliverSubject;
607 const char *DeliverGroup;
609 uint64_t OptStartSeq;
610 int64_t OptStartTime;
612 int64_t AckWait;
613 int64_t MaxDeliver;
614 const char *FilterSubject;
616 uint64_t RateLimit;
617 const char *SampleFrequency;
618 int64_t MaxWaiting;
621 int64_t Heartbeat;
623
625
644{
645 uint64_t Stream;
646 uint64_t ConsumerClient;
647 uint64_t ConsumerServer;
648
650
666typedef struct jsSubOptions
667{
674 const char *Stream;
684 const char *Consumer;
699 const char *Queue;
724 bool Ordered;
725
727
731typedef struct jsSequencePair
732{
733 uint64_t Consumer;
734 uint64_t Stream;
735
737
741typedef struct jsSequenceInfo
742{
743 uint64_t Consumer;
744 uint64_t Stream;
745 int64_t Last;
746
748
755typedef struct jsConsumerInfo
756{
757 char *Stream;
758 char *Name;
759 int64_t Created;
765 int64_t NumWaiting;
766 uint64_t NumPending;
769
771
775typedef struct jsAPIStats
776{
777 uint64_t Total;
778 uint64_t Errors;
779
781
785typedef struct jsAccountLimits
786{
787 int64_t MaxMemory;
788 int64_t MaxStore;
789 int64_t MaxStreams;
791
793
797typedef struct jsAccountInfo
798{
799 uint64_t Memory;
800 uint64_t Store;
801 int64_t Streams;
802 int64_t Consumers;
803 char *Domain;
806
808
816typedef struct jsMsgMetaData
817{
819 uint64_t NumDelivered;
820 uint64_t NumPending;
821 int64_t Timestamp;
822 char *Stream;
823 char *Consumer;
824 char *Domain;
825
827
831typedef struct jsPubAck
832{
833 char *Stream;
834 uint64_t Sequence;
835 char *Domain;
837
839
844typedef struct jsPubAckErr
845{
849 const char *ErrText;
850
852
853#ifndef BUILD_IN_DOXYGEN
854// Forward declaration
855typedef void (*jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure);
856#endif
857
863typedef struct jsOptions
864{
865 const char *Prefix;
866 const char *Domain;
867 int64_t Wait;
868
873 {
874 int64_t MaxPending;
877 int64_t StallWait;
878
880
888 {
899 {
900 const char *Subject;
901 uint64_t Sequence;
902 uint64_t Keep;
903
905
910 {
912
914
916
918
922typedef struct __kvStore kvStore;
923
927typedef struct __kvEntry kvEntry;
928
932typedef struct __kvStatus kvStatus;
933
937typedef struct __kvWatcher kvWatcher;
938
942typedef enum
943{
948
950
956typedef struct kvConfig
957{
958 const char *Bucket;
959 const char *Description;
961 uint8_t History;
962 int64_t TTL;
963 int64_t MaxBytes;
966
968
974typedef struct kvWatchOptions
975{
979 int64_t Timeout;
980
982
1000typedef struct kvEntryList
1001{
1003 const int Count;
1004
1006
1024typedef struct kvKeysList
1025{
1026 char **Keys;
1027 const int Count;
1028
1030
1031#if defined(NATS_HAS_STREAMING)
1036typedef struct __stanConnection stanConnection;
1037
1042typedef struct __stanSubscription stanSubscription;
1043
1048typedef struct __stanMsg stanMsg;
1049
1054typedef struct __stanConnOptions stanConnOptions;
1055
1060typedef struct __stanSubOptions stanSubOptions;
1061#endif
1062 // end of typesGroup
1064
1065//
1066// Callbacks.
1067//
1068
1091typedef void (*natsMsgHandler)(
1092 natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure);
1093
1108 natsConnection *nc, void *closure);
1109
1116typedef void (*natsErrHandler)(
1117 natsConnection *nc, natsSubscription *subscription, natsStatus err,
1118 void *closure);
1119
1134 void **userData,
1135 void *loop,
1136 natsConnection *nc,
1137 natsSock socket);
1138
1149 void *userData,
1150 bool add);
1151
1162 void *userData,
1163 bool add);
1164
1173 void *userData);
1174
1197 char **userJWT,
1198 char **customErrTxt,
1199 void *closure);
1200
1201
1228 char **customErrTxt,
1229 unsigned char **signature,
1230 int *signatureLength,
1231 const char *nonce,
1232 void *closure);
1233
1242typedef const char* (*natsTokenHandler)(void *closure);
1243
1244
1252typedef void (*natsOnCompleteCB)(void *closure);
1253
1274typedef int64_t (*natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure);
1275
1276#ifdef BUILD_IN_DOXYGEN
1310typedef void (*jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure);
1311#endif
1312
1313#if defined(NATS_HAS_STREAMING)
1322typedef void (*stanPubAckHandler)(const char *guid, const char *error, void *closure);
1323
1333typedef void (*stanMsgHandler)(
1334 stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure);
1335
1343 stanConnection *sc, const char* errorTxt, void *closure);
1344#endif
1345 // end of callbacksGroup
1347
1348//
1349// Functions.
1350//
1377nats_Open(int64_t lockSpinCount);
1378
1379
1384NATS_EXTERN const char*
1386
1394NATS_EXTERN uint32_t
1396
1397#ifdef BUILD_IN_DOXYGEN
1413#else
1414
1415#define nats_CheckCompatibility() nats_CheckCompatibilityImpl(NATS_VERSION_REQUIRED_NUMBER, \
1416 NATS_VERSION_NUMBER, \
1417 NATS_VERSION_STRING)
1418
1419NATS_EXTERN bool
1420nats_CheckCompatibilityImpl(uint32_t reqVerNumber, uint32_t verNumber, const char *verString);
1421
1422#endif
1423
1428NATS_EXTERN int64_t
1430
1436NATS_EXTERN int64_t
1438
1446NATS_EXTERN void
1447nats_Sleep(int64_t sleepTime);
1448
1461NATS_EXTERN const char*
1463
1473nats_GetLastErrorStack(char *buffer, size_t bufLen);
1474
1495NATS_EXTERN void
1497
1529
1540NATS_EXTERN void
1542
1568nats_Sign(const char *encodedSeed,
1569 const char *input,
1570 unsigned char **signature,
1571 int *signatureLength);
1572
1593NATS_EXTERN void
1595
1642nats_CloseAndWait(int64_t timeout);
1643 // end of libraryGroup
1645
1661NATS_EXTERN const char*
1663 // end of statusGroup
1665
1685
1704 uint64_t *inMsgs, uint64_t *inBytes,
1705 uint64_t *outMsgs, uint64_t *outBytes,
1706 uint64_t *reconnects);
1707
1714NATS_EXTERN void
1716 // end of statsGroup
1718
1745
1766/*
1767 * The above is for doxygen. The proper syntax for username/password
1768 * is without the '\' character:
1769 *
1770 * nats://localhost:4222
1771 * nats://user@localhost:4222
1772 * nats://user:password@localhost:4222
1773 */
1775natsOptions_SetURL(natsOptions *opts, const char *url);
1776
1792natsOptions_SetServers(natsOptions *opts, const char** servers, int serversCount);
1793
1820natsOptions_SetUserInfo(natsOptions *opts, const char *user, const char *password);
1821
1847natsOptions_SetToken(natsOptions *opts, const char *token);
1848
1866 void *closure);
1867
1879
1893natsOptions_SetTimeout(natsOptions *opts, int64_t timeout);
1894
1903natsOptions_SetName(natsOptions *opts, const char *name);
1904
1916
1932
1959natsOptions_SetCATrustedCertificates(natsOptions *opts, const char *certificates);
1960
1977 const char *certsFileName,
1978 const char *keyFileName);
1979
1993 const char *cert,
1994 const char *key);
1995
2012natsOptions_SetCiphers(natsOptions *opts, const char *ciphers);
2013
2028natsOptions_SetCipherSuites(natsOptions *opts, const char *ciphers);
2029
2041
2054
2067
2080
2092
2106
2120
2134
2144
2159natsOptions_SetReconnectWait(natsOptions *opts, int64_t reconnectWait);
2160
2185natsOptions_SetReconnectJitter(natsOptions *opts, int64_t jitter, int64_t jitterTLS);
2186
2208 void *closure);
2209
2224
2240
2257 void *closure);
2258
2273 void *closure);
2274
2293 natsConnectionHandler disconnectedCb,
2294 void *closure);
2295
2313 natsConnectionHandler reconnectedCb,
2314 void *closure);
2315
2332 natsConnectionHandler discoveredServersCb,
2333 void *closure);
2334
2353 natsConnectionHandler lameDuckCb,
2354 void *closure);
2355
2375 void *loop,
2376 natsEvLoop_Attach attachCb,
2379 natsEvLoop_Detach detachCb);
2380
2405
2430
2460
2472
2489
2510
2566 natsConnectionHandler connectedCb, void* closure);
2567
2598 natsUserJWTHandler ujwtCB,
2599 void *ujwtClosure,
2601 void *sigClosure);
2602
2643 const char *userOrChainedFile,
2644 const char *seedFile);
2645
2671 const char *pubKey,
2673 void *sigClosure);
2674
2701 const char *pubKey,
2702 const char *seedFile);
2703
2719
2756
2764NATS_EXTERN void
2766 // end of optsGroup
2768
2769#if defined(NATS_HAS_STREAMING)
2805
2829
2848
2860
2872
2882
2883
2899stanConnOptions_SetMaxPubAcksInflight(stanConnOptions *opts, int maxPubAcksInflight, float percentage);
2900
2917stanConnOptions_SetPings(stanConnOptions *opts, int interval, int maxOut);
2918
2931
2939NATS_EXTERN void
2941 // end of stanConnOptsGroup
2943
2976
2996stanSubOptions_SetDurableName(stanSubOptions *opts, const char *durableName);
2997
3013
3027
3045
3062
3076
3087
3097
3114
3122NATS_EXTERN void
3124 // end of stanSubOptsGroup
3126#endif
3127
3149
3156NATS_EXTERN void
3158 // end of inboxGroup
3160
3179NATS_EXTERN void
3181
3200natsMsg_Create(natsMsg **newMsg, const char *subj, const char *reply,
3201 const char *data, int dataLen);
3202
3211NATS_EXTERN const char*
3213
3223NATS_EXTERN const char*
3225
3241NATS_EXTERN const char*
3243
3250NATS_EXTERN int
3252
3269natsMsgHeader_Set(natsMsg *msg, const char *key, const char *value);
3270
3287natsMsgHeader_Add(natsMsg *msg, const char *key, const char *value);
3288
3308natsMsgHeader_Get(natsMsg *msg, const char *key, const char **value);
3309
3344natsMsgHeader_Values(natsMsg *msg, const char *key, const char* **values, int *count);
3345
3376natsMsgHeader_Keys(natsMsg *msg, const char* **keys, int *count);
3377
3392natsMsgHeader_Delete(natsMsg *msg, const char *key);
3393
3419NATS_EXTERN bool
3421
3428NATS_EXTERN void
3430 // end of msgGroup
3432
3433#if defined(NATS_HAS_STREAMING)
3446NATS_EXTERN uint64_t
3448
3455NATS_EXTERN int64_t
3457
3466NATS_EXTERN bool
3468
3484NATS_EXTERN const char*
3486
3493NATS_EXTERN int
3495
3502NATS_EXTERN void
3504 // end of stanMsgGroup
3506#endif
3507
3540
3551NATS_EXTERN void
3553
3564NATS_EXTERN void
3566
3587
3594NATS_EXTERN bool
3596
3603NATS_EXTERN bool
3605
3612bool
3614
3625
3637NATS_EXTERN int
3639
3657
3672
3682NATS_EXTERN int64_t
3684
3696
3707natsConnection_GetConnectedUrl(natsConnection *nc, char *buffer, size_t bufferSize);
3708
3719natsConnection_GetConnectedServerId(natsConnection *nc, char *buffer, size_t bufferSize);
3720
3742natsConnection_GetServers(natsConnection *nc, char ***servers, int *count);
3743
3765natsConnection_GetDiscoveredServers(natsConnection *nc, char ***servers, int *count);
3766
3780natsConnection_GetLastError(natsConnection *nc, const char **lastError);
3781
3797
3818
3838
3853 const unsigned char *message, int messageLen,
3854 unsigned char sig[64]);
3855
3876
3889
3899
3921
3931NATS_EXTERN void
3933
3941NATS_EXTERN void
3943 // end of connMgtGroup
3945
3964 const void *data, int dataLen);
3965
3982 const char *str);
3983
3996
4011 const char *reply, const void *data, int dataLen);
4012
4031 const char *reply, const char *str);
4032
4051natsConnection_Request(natsMsg **replyMsg, natsConnection *nc, const char *subj,
4052 const void *data, int dataLen, int64_t timeout);
4053
4077 const char *subj, const char *str,
4078 int64_t timeout);
4079
4096 natsMsg *requestMsg, int64_t timeout);
4097 // end of connPubGroup
4099
4122 const char *subject, natsMsgHandler cb,
4123 void *cbClosure);
4124
4157 const char *subject, int64_t timeout,
4158 natsMsgHandler cb, void *cbClosure);
4159
4172 const char *subject);
4173
4193 const char *subject, const char *queueGroup,
4194 natsMsgHandler cb, void *cbClosure);
4195
4230 const char *subject, const char *queueGroup,
4231 int64_t timeout, natsMsgHandler cb, void *cbClosure);
4232
4246 const char *subject, const char *queueGroup);
4247 // end of connSubGroup
4249 // end of connGroup
4251
4272
4297 int64_t timeout);
4298
4309
4323
4335
4357natsSubscription_SetPendingLimits(natsSubscription *sub, int msgLimit, int bytesLimit);
4358
4379natsSubscription_GetPendingLimits(natsSubscription *sub, int *msgLimit, int *bytesLimit);
4380
4397
4408
4426
4441
4450
4479 int *pendingMsgs,
4480 int *pendingBytes,
4481 int *maxPendingMsgs,
4482 int *maxPendingBytes,
4483 int64_t *deliveredMsgs,
4484 int64_t *droppedMsgs);
4485
4494NATS_EXTERN bool
4496
4516
4569
4594
4622
4653
4661NATS_EXTERN void
4663 // end of subGroup
4665
4666#if defined(NATS_HAS_STREAMING)
4708stanConnection_Connect(stanConnection **sc, const char *clusterID, const char *clientID,
4709 stanConnOptions *options);
4710
4735
4760NATS_EXTERN void
4762
4775
4785 // end of stanConnMgtGroup
4787
4806 const void *data, int dataLen);
4807
4833 const void *data, int dataLen,
4834 stanPubAckHandler ah, void *ahClosure);
4835 // end of stanConnPubGroup
4837
4862 const char *channel, stanMsgHandler cb,
4863 void *cbClosure, stanSubOptions *options);
4864
4886 const char *channel, const char *queueGroup,
4887 stanMsgHandler cb, void *cbClosure, stanSubOptions *options);
4888 // end of stanConnSubGroup
4890 // end of stanConnGroup
4892
4923
4935
4957
4970
4978NATS_EXTERN void
4980 // end of stanSubGroup
4982#endif
4983
4999
5016
5023NATS_EXTERN void
5025
5041
5050
5059
5068
5090
5112
5136js_PurgeStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
5137
5149js_DeleteStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
5150
5169js_GetMsg(natsMsg **msg, jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
5170
5189js_GetLastMsg(natsMsg **msg, jsCtx *js, const char *stream, const char *subject, jsOptions *opts, jsErrCode *errCode);
5190
5208js_DeleteMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
5209
5225js_EraseMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
5226
5254js_GetStreamInfo(jsStreamInfo **si, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
5255
5262NATS_EXTERN void
5264
5275
5297 const char *stream, jsConsumerConfig *cfg,
5298 jsOptions *opts, jsErrCode *errCode);
5299
5315 const char *stream, const char *consumer,
5316 jsOptions *opts, jsErrCode *errCode);
5317
5330js_DeleteConsumer(jsCtx *js, const char *stream, const char *consumer,
5331 jsOptions *opts, jsErrCode *errCode);
5332
5339NATS_EXTERN void
5341
5358
5365NATS_EXTERN void
5367 // end of jsAssetsGroup
5369
5385
5402js_Publish(jsPubAck **pubAck, jsCtx *js, const char *subj, const void *data, int dataLen,
5403 jsPubOptions *opts, jsErrCode *errCode);
5404
5426 jsPubOptions *opts, jsErrCode *errCode);
5427
5434NATS_EXTERN void
5436
5448js_PublishAsync(jsCtx *js, const char *subj, const void *data, int dataLen,
5449 jsPubOptions *opts);
5450
5476
5490
5541 // end of jsPubGroup
5543
5559
5575js_Subscribe(natsSubscription **sub, jsCtx *js, const char *subject,
5576 natsMsgHandler cb, void* cbClosure,
5577 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
5578
5592js_SubscribeSync(natsSubscription **sub, jsCtx *js, const char *subject,
5593 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
5594
5614js_PullSubscribe(natsSubscription **sub, jsCtx *js, const char *subject, const char *durable,
5615 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
5616
5636natsSubscription_Fetch(natsMsgList *list, natsSubscription *sub, int batch, int64_t timeout,
5637 jsErrCode *errCode);
5638
5639
5669 // end of jsSubGroup
5671
5694
5701NATS_EXTERN void
5703
5714
5728
5741
5752
5763
5773NATS_EXTERN uint64_t
5775
5785NATS_EXTERN int64_t
5787 // end of jsMsg
5789 // end of jsGroup
5791
5822
5839
5856js_KeyValue(kvStore **new_kv, jsCtx *js, const char *bucket);
5857
5868js_DeleteKeyValue(jsCtx *js, const char *bucket);
5869
5877NATS_EXTERN void
5879 // end of kvGroupMgt
5881
5898NATS_EXTERN const char*
5900
5907NATS_EXTERN const char*
5909
5916NATS_EXTERN const void*
5918
5925NATS_EXTERN int
5927
5935NATS_EXTERN const char*
5937
5944NATS_EXTERN uint64_t
5946
5953NATS_EXTERN int64_t
5955
5965NATS_EXTERN uint64_t
5967
5978
5985NATS_EXTERN void
5987 // end of kvEntry
5989
6001kvStore_Get(kvEntry **new_entry, kvStore *kv, const char *key);
6002
6014kvStore_Put(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len);
6015
6030kvStore_PutString(uint64_t *rev, kvStore *kv, const char *key, const char *data);
6031
6043kvStore_Create(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len);
6044
6059kvStore_CreateString(uint64_t *rev, kvStore *kv, const char *key, const char *data);
6060
6073kvStore_Update(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len, uint64_t last);
6074
6090kvStore_UpdateString(uint64_t *rev, kvStore *kv, const char *key, const char *data, uint64_t last);
6091
6100kvStore_Delete(kvStore *kv, const char *key);
6101
6110kvStore_Purge(kvStore *kv, const char *key);
6111
6121
6140
6158kvStore_Watch(kvWatcher **new_watcher, kvStore *kv, const char *keys, kvWatchOptions *opts);
6159
6176
6197
6209NATS_EXTERN void
6211
6235kvStore_History(kvEntryList *list, kvStore *kv, const char *key, kvWatchOptions *opts);
6236
6248NATS_EXTERN void
6250
6260NATS_EXTERN const char*
6262
6263// PurgeDeletes
6264
6276
6303kvWatcher_Next(kvEntry **new_entry, kvWatcher *w, int64_t timeout);
6304
6316
6323NATS_EXTERN void
6325 // end of kvWatcher
6327
6344NATS_EXTERN const char*
6346
6353NATS_EXTERN uint64_t
6355
6362NATS_EXTERN int64_t
6364
6371NATS_EXTERN int64_t
6373
6380NATS_EXTERN int64_t
6382
6389NATS_EXTERN void
6391 // end of kvStatus
6393 // end of kvGroup
6395 // end of funcGroup
6397
6434#ifdef __cplusplus
6435}
6436#endif
6437
6438#endif /* NATS_H_ */
void(* natsOnCompleteCB)(void *closure)
Callback used to notify that an object lifecycle is complete.
Definition: nats.h:1252
natsStatus(* natsEvLoop_Attach)(void **userData, void *loop, natsConnection *nc, natsSock socket)
Attach this connection to the external event loop.
Definition: nats.h:1133
natsStatus(* natsUserJWTHandler)(char **userJWT, char **customErrTxt, void *closure)
Callback used to fetch and return account signed user JWT.
Definition: nats.h:1196
natsStatus(* natsEvLoop_WriteAddRemove)(void *userData, bool add)
Write event needs to be added or removed.
Definition: nats.h:1161
int64_t(* natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure)
Callback used to specify how long to wait between reconnects.
Definition: nats.h:1274
const char *(* natsTokenHandler)(void *closure)
Callback used to build a token on connections and reconnections.
Definition: nats.h:1242
void(* jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure)
Callback used to process asynchronous publish errors from JetStream.
Definition: nats.h:1310
void(* natsErrHandler)(natsConnection *nc, natsSubscription *subscription, natsStatus err, void *closure)
Callback used to notify the user of errors encountered while processing inbound messages.
Definition: nats.h:1116
natsStatus(* natsEvLoop_Detach)(void *userData)
Detach from the event loop.
Definition: nats.h:1172
natsStatus(* natsSignatureHandler)(char **customErrTxt, unsigned char **signature, int *signatureLength, const char *nonce, void *closure)
Callback used to sign a nonce sent by the server.
Definition: nats.h:1227
void(* stanConnectionLostHandler)(stanConnection *sc, const char *errorTxt, void *closure)
Callback used to notify the user of the permanent loss of the connection.
Definition: nats.h:1342
void(* natsConnectionHandler)(natsConnection *nc, void *closure)
Callback used to notify the user of asynchronous connection events.
Definition: nats.h:1107
void(* natsMsgHandler)(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition: nats.h:1091
void(* stanPubAckHandler)(const char *guid, const char *error, void *closure)
Callback used to notify of an asynchronous publish result.
Definition: nats.h:1322
natsStatus(* natsEvLoop_ReadAddRemove)(void *userData, bool add)
Read event needs to be added or removed.
Definition: nats.h:1148
void(* stanMsgHandler)(stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition: nats.h:1333
NATS_EXTERN int natsConnection_Buffered(natsConnection *nc)
Returns the number of bytes to be sent to the server.
bool natsConnection_IsDraining(natsConnection *nc)
Test if connection is draining.
NATS_EXTERN void natsConnection_Close(natsConnection *nc)
Closes the connection.
NATS_EXTERN natsStatus natsConnection_Flush(natsConnection *nc)
Flushes the connection.
NATS_EXTERN natsConnStatus natsConnection_Status(natsConnection *nc)
Returns the current state of the connection.
NATS_EXTERN natsStatus natsConnection_GetConnectedServerId(natsConnection *nc, char *buffer, size_t bufferSize)
Gets the server Id.
NATS_EXTERN bool natsConnection_IsClosed(natsConnection *nc)
Test if connection has been closed.
NATS_EXTERN natsStatus natsConnection_Drain(natsConnection *nc)
Drains the connection with default timeout.
NATS_EXTERN bool natsConnection_IsReconnecting(natsConnection *nc)
Test if connection is reconnecting.
NATS_EXTERN natsStatus natsConnection_GetStats(natsConnection *nc, natsStatistics *stats)
Gets the connection statistics.
NATS_EXTERN int64_t natsConnection_GetMaxPayload(natsConnection *nc)
Returns the maximum message payload.
NATS_EXTERN natsStatus natsConnection_Sign(natsConnection *nc, const unsigned char *message, int messageLen, unsigned char sig[64])
Signs any 'message' using the connection's user credentials.
NATS_EXTERN natsStatus natsConnection_Connect(natsConnection **nc, natsOptions *options)
Connects to a NATS Server using the provided options.
NATS_EXTERN natsStatus natsConnection_GetClientID(natsConnection *nc, uint64_t *cid)
Gets the current client ID assigned by the server.
natsStatus natsConnection_GetLocalIPAndPort(natsConnection *nc, char **ip, int *port)
Returns the connection local IP and port.
NATS_EXTERN natsStatus natsConnection_FlushTimeout(natsConnection *nc, int64_t timeout)
Flushes the connection with a given timeout.
NATS_EXTERN natsStatus natsConnection_GetRTT(natsConnection *nc, int64_t *rtt)
Returns the round trip time between this client and the server.
NATS_EXTERN void natsConnection_ProcessReadEvent(natsConnection *nc)
Process a read event when using external event loop.
NATS_EXTERN natsStatus natsConnection_GetLastError(natsConnection *nc, const char **lastError)
Gets the last connection error.
NATS_EXTERN natsStatus natsConnection_GetDiscoveredServers(natsConnection *nc, char ***servers, int *count)
Returns the list of discovered server URLs.
NATS_EXTERN natsStatus natsConnection_HasHeaderSupport(natsConnection *nc)
Returns if the connection to current server supports headers.
NATS_EXTERN void natsConnection_ProcessWriteEvent(natsConnection *nc)
Process a write event when using external event loop.
NATS_EXTERN natsStatus natsConnection_GetClientIP(natsConnection *nc, char **ip)
Returns the client's IP address as reported by the server.
NATS_EXTERN natsStatus natsConnection_DrainTimeout(natsConnection *nc, int64_t timeout)
Drains the connection with given timeout.
NATS_EXTERN natsStatus natsConnection_GetServers(natsConnection *nc, char ***servers, int *count)
Returns the list of server URLs known to this connection.
NATS_EXTERN natsStatus natsConnection_GetConnectedUrl(natsConnection *nc, char *buffer, size_t bufferSize)
Gets the URL of the currently connected server.
NATS_EXTERN natsStatus natsConnection_ConnectTo(natsConnection **nc, const char *urls)
Connects to a NATS Server using any of the URL from the given list.
NATS_EXTERN void natsConnection_Destroy(natsConnection *nc)
Destroys the connection object.
NATS_EXTERN natsStatus natsConnection_RequestMsg(natsMsg **replyMsg, natsConnection *nc, natsMsg *requestMsg, int64_t timeout)
Sends a request based on the given requestMsg and waits for a reply.
NATS_EXTERN natsStatus natsConnection_RequestString(natsMsg **replyMsg, natsConnection *nc, const char *subj, const char *str, int64_t timeout)
Sends a request (as a string) and waits for a reply.
NATS_EXTERN natsStatus natsConnection_PublishMsg(natsConnection *nc, natsMsg *msg)
Publishes a message on a subject.
NATS_EXTERN natsStatus natsConnection_PublishRequest(natsConnection *nc, const char *subj, const char *reply, const void *data, int dataLen)
Publishes data on a subject expecting replies on the given reply.
NATS_EXTERN natsStatus natsConnection_PublishRequestString(natsConnection *nc, const char *subj, const char *reply, const char *str)
Publishes a string on a subject expecting replies on the given reply.
NATS_EXTERN natsStatus natsConnection_Publish(natsConnection *nc, const char *subj, const void *data, int dataLen)
Publishes data on a subject.
NATS_EXTERN natsStatus natsConnection_PublishString(natsConnection *nc, const char *subj, const char *str)
Publishes a string on a subject.
NATS_EXTERN natsStatus natsConnection_Request(natsMsg **replyMsg, natsConnection *nc, const char *subj, const void *data, int dataLen, int64_t timeout)
Sends a request and waits for a reply.
NATS_EXTERN natsStatus natsConnection_SubscribeSync(natsSubscription **sub, natsConnection *nc, const char *subject)
Creates a synchronous subcription.
NATS_EXTERN natsStatus natsConnection_QueueSubscribe(natsSubscription **sub, natsConnection *nc, const char *subject, const char *queueGroup, natsMsgHandler cb, void *cbClosure)
Creates an asynchronous queue subscriber.
NATS_EXTERN natsStatus natsConnection_QueueSubscribeSync(natsSubscription **sub, natsConnection *nc, const char *subject, const char *queueGroup)
Creates a synchronous queue subscriber.
NATS_EXTERN natsStatus natsConnection_QueueSubscribeTimeout(natsSubscription **sub, natsConnection *nc, const char *subject, const char *queueGroup, int64_t timeout, natsMsgHandler cb, void *cbClosure)
Creates an asynchronous queue subscriber with a timeout.
NATS_EXTERN natsStatus natsConnection_SubscribeTimeout(natsSubscription **sub, natsConnection *nc, const char *subject, int64_t timeout, natsMsgHandler cb, void *cbClosure)
Creates an asynchronous subscription with a timeout.
NATS_EXTERN natsStatus natsConnection_Subscribe(natsSubscription **sub, natsConnection *nc, const char *subject, natsMsgHandler cb, void *cbClosure)
Creates an asynchronous subscription.
NATS_EXTERN natsStatus natsInbox_Create(natsInbox **newInbox)
Creates an inbox.
NATS_EXTERN void natsInbox_Destroy(natsInbox *inbox)
Destroys the inbox.
NATS_EXTERN natsStatus jsPlacement_Init(jsPlacement *placement)
Initializes a placement configuration structure.
NATS_EXTERN natsStatus js_GetConsumerInfo(jsConsumerInfo **ci, jsCtx *js, const char *stream, const char *consumer, jsOptions *opts, jsErrCode *errCode)
Retrieves information about a consumer.
NATS_EXTERN natsStatus jsConsumerConfig_Init(jsConsumerConfig *cc)
Initializes a consumer configuration structure.
NATS_EXTERN natsStatus js_DeleteStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Deletes a stream.
NATS_EXTERN natsStatus js_DeleteConsumer(jsCtx *js, const char *stream, const char *consumer, jsOptions *opts, jsErrCode *errCode)
Deletes a consumer.
NATS_EXTERN natsStatus js_PurgeStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Purges a stream.
NATS_EXTERN natsStatus js_AddStream(jsStreamInfo **si, jsCtx *js, jsStreamConfig *cfg, jsOptions *opts, jsErrCode *errCode)
Creates a stream.
NATS_EXTERN natsStatus js_GetLastMsg(natsMsg **msg, jsCtx *js, const char *stream, const char *subject, jsOptions *opts, jsErrCode *errCode)
Retrieves the last JetStream message from the stream for a given subject.
NATS_EXTERN natsStatus js_EraseMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode)
Erases a message from the stream.
NATS_EXTERN natsStatus js_UpdateStream(jsStreamInfo **si, jsCtx *js, jsStreamConfig *cfg, jsOptions *opts, jsErrCode *errCode)
Updates a stream.
NATS_EXTERN void jsAccountInfo_Destroy(jsAccountInfo *ai)
Destroys the account information object.
NATS_EXTERN natsStatus jsStreamSource_Init(jsStreamSource *source)
Initializes a stream source configuration structure.
NATS_EXTERN natsStatus jsExternalStream_Init(jsExternalStream *external)
Initializes an external stream configuration structure.
NATS_EXTERN void jsStreamInfo_Destroy(jsStreamInfo *si)
Destroys the stream information object.
NATS_EXTERN natsStatus js_GetStreamInfo(jsStreamInfo **si, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Retreives information from a stream.
NATS_EXTERN void jsConsumerInfo_Destroy(jsConsumerInfo *ci)
Destroys the consumer information object.
NATS_EXTERN natsStatus js_GetMsg(natsMsg **msg, jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode)
Retrieves a JetStream message from the stream by sequence.
NATS_EXTERN natsStatus jsStreamConfig_Init(jsStreamConfig *cfg)
Initializes a streaming configuration structure.
NATS_EXTERN natsStatus js_GetAccountInfo(jsAccountInfo **ai, jsCtx *js, jsOptions *opts, jsErrCode *errCode)
Retrieves information about the JetStream usage from an account.
NATS_EXTERN natsStatus js_DeleteMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode)
Deletes a message from the stream.
NATS_EXTERN natsStatus js_AddConsumer(jsConsumerInfo **ci, jsCtx *js, const char *stream, jsConsumerConfig *cfg, jsOptions *opts, jsErrCode *errCode)
Adds a JetStream consumer.
NATS_EXTERN natsStatus jsOptions_Init(jsOptions *opts)
Initializes a streaming context options structure.
NATS_EXTERN natsStatus natsConnection_JetStream(jsCtx **js, natsConnection *nc, jsOptions *opts)
Returns a new JetStream context.
NATS_EXTERN void jsCtx_Destroy(jsCtx *js)
Destroys the JetStream context.
NATS_EXTERN uint64_t natsMsg_GetSequence(natsMsg *msg)
Returns the sequence number of this JetStream message.
NATS_EXTERN int64_t natsMsg_GetTime(natsMsg *msg)
Returns the timestamp (in UTC) of this JetStream message.
NATS_EXTERN natsStatus natsMsg_Nak(natsMsg *msg, jsOptions *opts)
Negatively acknowledges a message.
NATS_EXTERN natsStatus natsMsg_GetMetaData(jsMsgMetaData **new_meta, natsMsg *msg)
Returns metadata from this JetStream message.
NATS_EXTERN natsStatus natsMsg_InProgress(natsMsg *msg, jsOptions *opts)
Resets redelivery timer on the server.
NATS_EXTERN natsStatus natsMsg_Ack(natsMsg *msg, jsOptions *opts)
Acknowledges a message.
NATS_EXTERN natsStatus natsMsg_Term(natsMsg *msg, jsOptions *opts)
Abandon this message.
NATS_EXTERN void jsMsgMetaData_Destroy(jsMsgMetaData *meta)
Destroys the message metadata object.
NATS_EXTERN natsStatus natsMsg_AckSync(natsMsg *msg, jsOptions *opts, jsErrCode *errCode)
Acknowledges a message and wait for a confirmation.
NATS_EXTERN natsStatus js_PublishAsync(jsCtx *js, const char *subj, const void *data, int dataLen, jsPubOptions *opts)
Publishes data to JetStream but does not wait for a jsPubAck.
NATS_EXTERN natsStatus js_PublishAsyncComplete(jsCtx *js, jsPubOptions *opts)
Wait for all outstanding messages to be acknowledged.
NATS_EXTERN natsStatus js_PublishAsyncGetPendingList(natsMsgList *pending, jsCtx *js)
Returns the list of pending messages published asynchronously.
NATS_EXTERN natsStatus js_PublishMsg(jsPubAck **pubAck, jsCtx *js, natsMsg *msg, jsPubOptions *opts, jsErrCode *errCode)
Publishes a message to JetStream.
NATS_EXTERN void jsPubAck_Destroy(jsPubAck *pubAck)
Destroys the publish acknowledgment object.
NATS_EXTERN natsStatus js_PublishMsgAsync(jsCtx *js, natsMsg **msg, jsPubOptions *opts)
Publishes a message to JetStream but does not wait for a jsPubAck.
NATS_EXTERN natsStatus js_Publish(jsPubAck **pubAck, jsCtx *js, const char *subj, const void *data, int dataLen, jsPubOptions *opts, jsErrCode *errCode)
Publishes data on a subject to JetStream.
NATS_EXTERN natsStatus jsPubOptions_Init(jsPubOptions *opts)
Initializes a publish options structure.
NATS_EXTERN natsStatus natsSubscription_GetSequenceMismatch(jsConsumerSequenceMismatch *csm, natsSubscription *sub)
Returns the consumer sequence mismatch information.
NATS_EXTERN natsStatus jsSubOptions_Init(jsSubOptions *opts)
Initializes a subscribe options structure.
NATS_EXTERN natsStatus js_Subscribe(natsSubscription **sub, jsCtx *js, const char *subject, natsMsgHandler cb, void *cbClosure, jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode)
Create an asynchronous subscription.
NATS_EXTERN natsStatus js_PullSubscribe(natsSubscription **sub, jsCtx *js, const char *subject, const char *durable, jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode)
Create a pull subscriber.
NATS_EXTERN natsStatus js_SubscribeSync(natsSubscription **sub, jsCtx *js, const char *subject, jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode)
Create a synchronous subscription.
NATS_EXTERN natsStatus natsSubscription_Fetch(natsMsgList *list, natsSubscription *sub, int batch, int64_t timeout, jsErrCode *errCode)
Fetches messages for a pull subscription.
NATS_EXTERN kvOperation kvEntry_Operation(kvEntry *e)
Returns the type of operation of this value.
NATS_EXTERN uint64_t kvEntry_Delta(kvEntry *e)
Returns the distance from the latest value.
NATS_EXTERN const void * kvEntry_Value(kvEntry *e)
Returns the value for this key.
NATS_EXTERN uint64_t kvEntry_Revision(kvEntry *e)
Returns the unique sequence for this value.
NATS_EXTERN int64_t kvEntry_Created(kvEntry *e)
Returns the time (in UTC) the data was put in the bucket.
NATS_EXTERN const char * kvEntry_ValueString(kvEntry *e)
Returns the value, as a string, for this key.
NATS_EXTERN void kvEntry_Destroy(kvEntry *e)
Destroys the KeyValue entry object.
NATS_EXTERN const char * kvEntry_Key(kvEntry *e)
Returns the name of the key that was retrieved.
NATS_EXTERN const char * kvEntry_Bucket(kvEntry *e)
Returns the name of the bucket the data was loaded from.
NATS_EXTERN int kvEntry_ValueLen(kvEntry *e)
Returns the value length for this key.
NATS_EXTERN void kvKeysList_Destroy(kvKeysList *list)
Destroys this list of KeyValue store key strings.
NATS_EXTERN natsStatus kvStore_UpdateString(uint64_t *rev, kvStore *kv, const char *key, const char *data, uint64_t last)
Updates the value (as a string) for the key into the store if and only if the latest revision matches...
NATS_EXTERN natsStatus kvStore_Put(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len)
Places the new value for the key into the store.
NATS_EXTERN natsStatus kvStore_Get(kvEntry **new_entry, kvStore *kv, const char *key)
Returns the latest entry for the key.
NATS_EXTERN natsStatus kvStore_Watch(kvWatcher **new_watcher, kvStore *kv, const char *keys, kvWatchOptions *opts)
Returns a watcher for any updates to keys that match the keys argument.
NATS_EXTERN natsStatus kvStore_Create(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len)
Places the value for the key into the store if and only if the key does not exist.
NATS_EXTERN natsStatus kvStore_CreateString(uint64_t *rev, kvStore *kv, const char *key, const char *data)
Places the value (as a string) for the key into the store if and only if the key does not exist.
NATS_EXTERN natsStatus kvStore_History(kvEntryList *list, kvStore *kv, const char *key, kvWatchOptions *opts)
Returns all historical entries for the key.
NATS_EXTERN natsStatus kvStore_Keys(kvKeysList *list, kvStore *kv, kvWatchOptions *opts)
Returns all keys in the bucket.
NATS_EXTERN natsStatus kvStore_Purge(kvStore *kv, const char *key)
Deletes a key by placing a purge marker and removing all revisions.
NATS_EXTERN natsStatus kvStore_Delete(kvStore *kv, const char *key)
Deletes a key by placing a delete marker and leaving all revisions.
NATS_EXTERN natsStatus kvWatchOptions_Init(kvWatchOptions *opts)
Initializes a KeyValue watcher options structure.
NATS_EXTERN natsStatus kvStore_PutString(uint64_t *rev, kvStore *kv, const char *key, const char *data)
Places the new value (as a string) for the key into the store.
NATS_EXTERN natsStatus kvStore_PurgeDeletes(kvStore *kv, kvWatchOptions *opts)
Removes all current delete markers.
NATS_EXTERN const char * kvStore_Bucket(kvStore *kv)
Returns the bucket name of this KeyValue store object.
NATS_EXTERN natsStatus kvStore_Status(kvStatus **new_status, kvStore *kv)
Returns the status and configuration of a bucket.
NATS_EXTERN natsStatus kvStore_Update(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len, uint64_t last)
Updates the value for the key into the store if and only if the latest revision matches.
NATS_EXTERN void kvEntryList_Destroy(kvEntryList *list)
Destroys this list of KeyValue store entries.
NATS_EXTERN natsStatus kvStore_WatchAll(kvWatcher **new_watcher, kvStore *kv, kvWatchOptions *opts)
Returns a watcher for any updates to any keys of the KeyValue store bucket.
NATS_EXTERN natsStatus kvConfig_Init(kvConfig *cfg)
Initializes a KeyValue configuration structure.
NATS_EXTERN natsStatus js_KeyValue(kvStore **new_kv, jsCtx *js, const char *bucket)
Looks-up and binds to an existing KeyValue store.
NATS_EXTERN natsStatus js_DeleteKeyValue(jsCtx *js, const char *bucket)
Deletes a KeyValue store.
NATS_EXTERN void kvStore_Destroy(kvStore *kv)
Destroys a KeyValue store object.
NATS_EXTERN natsStatus js_CreateKeyValue(kvStore **new_kv, jsCtx *js, kvConfig *cfg)
Creates a KeyValue store with a given configuration.
NATS_EXTERN const char * kvStatus_Bucket(kvStatus *sts)
Returns the bucket name.
NATS_EXTERN uint64_t kvStatus_Values(kvStatus *sts)
Returns how many messages are in the bucket, including historical values.
NATS_EXTERN void kvStatus_Destroy(kvStatus *sts)
Destroys the KeyValue status object.
NATS_EXTERN int64_t kvStatus_Replicas(kvStatus *sts)
Returns the number of replicas to keep for a bucket.
NATS_EXTERN int64_t kvStatus_TTL(kvStatus *sts)
Returns how long the bucket keeps values for.
NATS_EXTERN int64_t kvStatus_History(kvStatus *sts)
Returns the configured history kept per key.
NATS_EXTERN void kvWatcher_Destroy(kvWatcher *w)
Destroys the KeyValue watcher object.
NATS_EXTERN natsStatus kvWatcher_Next(kvEntry **new_entry, kvWatcher *w, int64_t timeout)
Returns the next entry for this watcher.
NATS_EXTERN natsStatus kvWatcher_Stop(kvWatcher *w)
Stops the watcher.
NATS_EXTERN const char * nats_GetVersion(void)
Returns the Library's version.
NATS_EXTERN natsStatus nats_Open(int64_t lockSpinCount)
Initializes the library.
NATS_EXTERN void nats_PrintLastErrorStack(FILE *file)
Prints the calling thread's last known error stack into the file.
NATS_EXTERN uint32_t nats_GetVersionNumber(void)
Returns the Library's version as a number.
NATS_EXTERN bool nats_CheckCompatibility(void)
Check that the header is compatible with the library.
NATS_EXTERN int64_t nats_Now(void)
Gives the current time in milliseconds.
NATS_EXTERN natsStatus nats_SetMessageDeliveryPoolSize(int max)
Sets the maximum size of the global message delivery thread pool.
NATS_EXTERN natsStatus nats_GetLastErrorStack(char *buffer, size_t bufLen)
Returns the calling thread's last known error stack.
NATS_EXTERN int64_t nats_NowInNanoSeconds(void)
Gives the current time in nanoseconds.
NATS_EXTERN void nats_Sleep(int64_t sleepTime)
Sleeps for a given number of milliseconds.
NATS_EXTERN const char * nats_GetLastError(natsStatus *status)
Returns the calling thread's last known error.
NATS_EXTERN void nats_Close(void)
Tear down the library.
NATS_EXTERN natsStatus nats_CloseAndWait(int64_t timeout)
Tear down the library and wait for all resources to be released.
NATS_EXTERN natsStatus nats_Sign(const char *encodedSeed, const char *input, unsigned char **signature, int *signatureLength)
Signs a given text using the provided private key.
NATS_EXTERN void nats_ReleaseThreadMemory(void)
Release thread-local memory possibly allocated by the library.
NATS_EXTERN natsStatus natsMsg_Create(natsMsg **newMsg, const char *subj, const char *reply, const char *data, int dataLen)
Creates a natsMsg object.
NATS_EXTERN void natsMsgList_Destroy(natsMsgList *list)
Destroys this list of messages.
NATS_EXTERN int natsMsg_GetDataLength(const natsMsg *msg)
Returns the message length.
NATS_EXTERN natsStatus natsMsgHeader_Add(natsMsg *msg, const char *key, const char *value)
Add value to the header associated with key.
NATS_EXTERN bool natsMsg_IsNoResponders(natsMsg *msg)
Indicates if this message is a "no responders" message from the server.
NATS_EXTERN const char * natsMsg_GetData(const natsMsg *msg)
Returns the message payload.
NATS_EXTERN natsStatus natsMsgHeader_Keys(natsMsg *msg, const char ***keys, int *count)
Get all header keys.
NATS_EXTERN const char * natsMsg_GetReply(const natsMsg *msg)
Returns the reply set in this message.
NATS_EXTERN void natsMsg_Destroy(natsMsg *msg)
Destroys the message object.
NATS_EXTERN natsStatus natsMsgHeader_Get(natsMsg *msg, const char *key, const char **value)
Get the header entry associated with key.
NATS_EXTERN natsStatus natsMsgHeader_Delete(natsMsg *msg, const char *key)
Delete the value(s) associated with key.
NATS_EXTERN const char * natsMsg_GetSubject(const natsMsg *msg)
Returns the subject set in this message.
NATS_EXTERN natsStatus natsMsgHeader_Values(natsMsg *msg, const char *key, const char ***values, int *count)
Get all header values associated with key.
NATS_EXTERN natsStatus natsMsgHeader_Set(natsMsg *msg, const char *key, const char *value)
Set the header entries associated with key to the single element value.
NATS_EXTERN natsStatus natsOptions_SetNKey(natsOptions *opts, const char *pubKey, natsSignatureHandler sigCB, void *sigClosure)
Sets the NKey public key and signature callback.
NATS_EXTERN natsStatus natsOptions_SetExpectedHostname(natsOptions *opts, const char *hostname)
Sets the server certificate's expected hostname.
NATS_EXTERN natsStatus natsOptions_SetErrorHandler(natsOptions *opts, natsErrHandler errHandler, void *closure)
Sets the error handler for asynchronous events.
NATS_EXTERN natsStatus natsOptions_SetTimeout(natsOptions *opts, int64_t timeout)
Sets the (re)connect process timeout.
NATS_EXTERN natsStatus natsOptions_DisableNoResponders(natsOptions *opts, bool disabled)
Enable/Disable the "no responders" feature.
NATS_EXTERN natsStatus natsOptions_SetIOBufSize(natsOptions *opts, int ioBufSize)
Sets the size of the internal read/write buffers.
NATS_EXTERN natsStatus natsOptions_SetName(natsOptions *opts, const char *name)
Sets the name.
NATS_EXTERN natsStatus natsOptions_SetRetryOnFailedConnect(natsOptions *opts, bool retry, natsConnectionHandler connectedCb, void *closure)
Indicates if initial connect failure should be retried or not.
NATS_EXTERN natsStatus natsOptions_SetTokenHandler(natsOptions *opts, natsTokenHandler tokenCb, void *closure)
Sets the tokenCb to use whenever a token is needed.
NATS_EXTERN natsStatus natsOptions_SetReconnectedCB(natsOptions *opts, natsConnectionHandler reconnectedCb, void *closure)
Sets the callback to be invoked when the connection has reconnected.
NATS_EXTERN natsStatus natsOptions_SetPedantic(natsOptions *opts, bool pedantic)
Sets the pedantic mode.
NATS_EXTERN natsStatus natsOptions_SetReconnectWait(natsOptions *opts, int64_t reconnectWait)
Sets the time between reconnect attempts.
NATS_EXTERN natsStatus natsOptions_SetCipherSuites(natsOptions *opts, const char *ciphers)
Sets the list of available ciphers for TLSv1.3.
NATS_EXTERN natsStatus natsOptions_LoadCATrustedCertificates(natsOptions *opts, const char *fileName)
Loads the trusted CA certificates from a file.
NATS_EXTERN natsStatus natsOptions_SetCustomReconnectDelay(natsOptions *opts, natsCustomReconnectDelayHandler cb, void *closure)
Sets the handler to invoke when the library needs to wait before the next reconnect attempts.
NATS_EXTERN natsStatus natsOptions_LoadCertificatesChain(natsOptions *opts, const char *certsFileName, const char *keyFileName)
Loads the certificate chain from a file, using the given key.
NATS_EXTERN natsStatus natsOptions_SetAllowReconnect(natsOptions *opts, bool allow)
Indicates if the connection will be allowed to reconnect.
NATS_EXTERN natsStatus natsOptions_SetURL(natsOptions *opts, const char *url)
Sets the URL to connect to.
NATS_EXTERN natsStatus natsOptions_SetClosedCB(natsOptions *opts, natsConnectionHandler closedCb, void *closure)
Sets the callback to be invoked when a connection to a server is permanently lost.
NATS_EXTERN natsStatus natsOptions_SetNoEcho(natsOptions *opts, bool noEcho)
Sets if connection receives its own messages.
NATS_EXTERN natsStatus natsOptions_SetLameDuckModeCB(natsOptions *opts, natsConnectionHandler lameDuckCb, void *closure)
Sets the callback to be invoked when server enters lame duck mode.
NATS_EXTERN natsStatus natsOptions_SetCiphers(natsOptions *opts, const char *ciphers)
Sets the list of available ciphers.
NATS_EXTERN natsStatus natsOptions_SetUserCredentialsFromFiles(natsOptions *opts, const char *userOrChainedFile, const char *seedFile)
Sets the file(s) to use to fetch user JWT and seed required to sign nonce.
NATS_EXTERN natsStatus natsOptions_SetUserInfo(natsOptions *opts, const char *user, const char *password)
Sets the user name/password to use when not specified in the URL.
NATS_EXTERN natsStatus natsOptions_SetUserCredentialsCallbacks(natsOptions *opts, natsUserJWTHandler ujwtCB, void *ujwtClosure, natsSignatureHandler sigCB, void *sigClosure)
Sets the callbacks to fetch user JWT and sign server's nonce.
NATS_EXTERN natsStatus natsOptions_Create(natsOptions **newOpts)
Creates a natsOptions object.
NATS_EXTERN natsStatus natsOptions_SetNKeyFromSeed(natsOptions *opts, const char *pubKey, const char *seedFile)
Sets the NKey public key and its seed file.
NATS_EXTERN natsStatus natsOptions_SkipServerVerification(natsOptions *opts, bool skip)
Switch server certificate verification.
NATS_EXTERN natsStatus natsOptions_UseOldRequestStyle(natsOptions *opts, bool useOldStyle)
Switches the use of old style requests.
NATS_EXTERN natsStatus natsOptions_IPResolutionOrder(natsOptions *opts, int order)
Dictates the order in which host name are resolved during connect.
NATS_EXTERN natsStatus natsOptions_SetSendAsap(natsOptions *opts, bool sendAsap)
Sets if Publish calls should send data right away.
NATS_EXTERN natsStatus natsOptions_SetReconnectJitter(natsOptions *opts, int64_t jitter, int64_t jitterTLS)
Set the upper bound of a random delay added to reconnect wait.
NATS_EXTERN void natsOptions_Destroy(natsOptions *opts)
Destroys a natsOptions object.
NATS_EXTERN natsStatus natsOptions_SetMaxPendingMsgs(natsOptions *opts, int maxPending)
Sets the maximum number of pending messages per subscription.
NATS_EXTERN natsStatus natsOptions_SetReconnectBufSize(natsOptions *opts, int reconnectBufSize)
Sets the size of the backing buffer used during reconnect.
NATS_EXTERN natsStatus natsOptions_SetVerbose(natsOptions *opts, bool verbose)
Sets the verbose mode.
NATS_EXTERN natsStatus natsOptions_SetSecure(natsOptions *opts, bool secure)
Sets the secure mode.
NATS_EXTERN natsStatus natsOptions_SetNoRandomize(natsOptions *opts, bool noRandomize)
Indicate if the servers list should be randomized.
NATS_EXTERN natsStatus natsOptions_SetWriteDeadline(natsOptions *opts, int64_t deadline)
Sets the write deadline.
NATS_EXTERN natsStatus natsOptions_SetMaxPingsOut(natsOptions *opts, int maxPingsOut)
Sets the limit of outstanding PINGs without corresponding PONGs.
NATS_EXTERN natsStatus natsOptions_SetEventLoop(natsOptions *opts, void *loop, natsEvLoop_Attach attachCb, natsEvLoop_ReadAddRemove readCb, natsEvLoop_WriteAddRemove writeCb, natsEvLoop_Detach detachCb)
Sets the external event loop and associated callbacks.
NATS_EXTERN natsStatus natsOptions_SetMaxReconnect(natsOptions *opts, int maxReconnect)
Sets the maximum number of reconnect attempts.
NATS_EXTERN natsStatus natsOptions_SetDiscoveredServersCB(natsOptions *opts, natsConnectionHandler discoveredServersCb, void *closure)
Sets the callback to be invoked when new servers are discovered.
NATS_EXTERN natsStatus natsOptions_UseGlobalMessageDelivery(natsOptions *opts, bool global)
Switch on/off the use of a central message delivery thread pool.
NATS_EXTERN natsStatus natsOptions_SetServers(natsOptions *opts, const char **servers, int serversCount)
Set the list of servers to try to (re)connect to.
NATS_EXTERN natsStatus natsOptions_SetToken(natsOptions *opts, const char *token)
Sets the token to use when not specified in the URL.
NATS_EXTERN natsStatus natsOptions_SetDisconnectedCB(natsOptions *opts, natsConnectionHandler disconnectedCb, void *closure)
Sets the callback to be invoked when the connection to a server is lost.
NATS_EXTERN natsStatus natsOptions_SetFailRequestsOnDisconnect(natsOptions *opts, bool failRequests)
Fails pending requests on disconnect event.
NATS_EXTERN natsStatus natsOptions_SetPingInterval(natsOptions *opts, int64_t interval)
Sets the ping interval.
NATS_EXTERN natsStatus natsOptions_SetCertificatesChain(natsOptions *opts, const char *cert, const char *key)
Sets the client certificate and key.
NATS_EXTERN natsStatus natsOptions_SetCATrustedCertificates(natsOptions *opts, const char *certificates)
Sets the trusted CA certificates from memory.
NATS_EXTERN natsStatus stanConnection_GetNATSConnection(stanConnection *sc, natsConnection **nc)
Returns the underlying NATS Connection.
NATS_EXTERN void stanConnection_ReleaseNATSConnection(stanConnection *sc)
Releases the NATS Connection.
NATS_EXTERN natsStatus stanConnection_Connect(stanConnection **sc, const char *clusterID, const char *clientID, stanConnOptions *options)
Connects to a NATS Streaming Server using the provided options.
NATS_EXTERN natsStatus stanConnection_Close(stanConnection *sc)
Closes the connection.
NATS_EXTERN natsStatus stanConnection_Destroy(stanConnection *sc)
Destroys the connection object.
NATS_EXTERN natsStatus stanConnOptions_SetDiscoveryPrefix(stanConnOptions *opts, const char *prefix)
Sets the subject prefix the library sends the connect request to.
NATS_EXTERN natsStatus stanConnOptions_SetConnectionLostHandler(stanConnOptions *opts, stanConnectionLostHandler handler, void *closure)
Sets the connection lost handler.
NATS_EXTERN natsStatus stanConnOptions_SetMaxPubAcksInflight(stanConnOptions *opts, int maxPubAcksInflight, float percentage)
Sets the maximum number of published messages without outstanding ACKs from the server.
NATS_EXTERN natsStatus stanConnOptions_SetPubAckWait(stanConnOptions *opts, int64_t wait)
Sets the timeout for waiting for an ACK for a published message.
NATS_EXTERN natsStatus stanConnOptions_SetURL(stanConnOptions *opts, const char *url)
Sets the URL to connect to.
NATS_EXTERN natsStatus stanConnOptions_SetConnectionWait(stanConnOptions *opts, int64_t wait)
Sets the timeout for establishing a connection.
NATS_EXTERN void stanConnOptions_Destroy(stanConnOptions *opts)
Destroys a stanConnOptions object.
NATS_EXTERN natsStatus stanConnOptions_SetPings(stanConnOptions *opts, int interval, int maxOut)
Sets the ping interval and max out values.
NATS_EXTERN natsStatus stanConnOptions_SetNATSOptions(stanConnOptions *opts, natsOptions *nOpts)
Sets the NATS Options to use to create the connection.
NATS_EXTERN natsStatus stanConnOptions_Create(stanConnOptions **newOpts)
Creates a stanConnOptions object.
NATS_EXTERN natsStatus stanConnection_PublishAsync(stanConnection *sc, const char *channel, const void *data, int dataLen, stanPubAckHandler ah, void *ahClosure)
Asynchronously publishes data on a channel.
NATS_EXTERN natsStatus stanConnection_Publish(stanConnection *sc, const char *channel, const void *data, int dataLen)
Publishes data on a channel.
NATS_EXTERN natsStatus stanConnection_QueueSubscribe(stanSubscription **sub, stanConnection *sc, const char *channel, const char *queueGroup, stanMsgHandler cb, void *cbClosure, stanSubOptions *options)
Creates a queue subscription.
NATS_EXTERN natsStatus stanConnection_Subscribe(stanSubscription **sub, stanConnection *sc, const char *channel, stanMsgHandler cb, void *cbClosure, stanSubOptions *options)
Creates a subscription.
NATS_EXTERN const char * stanMsg_GetData(const stanMsg *msg)
Returns the message payload.
NATS_EXTERN int64_t stanMsg_GetTimestamp(const stanMsg *msg)
Returns the message's timestamp.
NATS_EXTERN int stanMsg_GetDataLength(const stanMsg *msg)
Returns the message length.
NATS_EXTERN bool stanMsg_IsRedelivered(const stanMsg *msg)
Returns the message's redelivered flag.
NATS_EXTERN uint64_t stanMsg_GetSequence(const stanMsg *msg)
Returns the message's sequence number.
NATS_EXTERN void stanMsg_Destroy(stanMsg *msg)
Destroys the message object.
NATS_EXTERN natsStatus stanSubscription_AckMsg(stanSubscription *sub, stanMsg *msg)
Acknowledge a message.
NATS_EXTERN void stanSubscription_Destroy(stanSubscription *sub)
Destroys the subscription.
NATS_EXTERN natsStatus stanSubscription_SetOnCompleteCB(stanSubscription *sub, natsOnCompleteCB cb, void *closure)
Sets a completion callback.
NATS_EXTERN natsStatus stanSubscription_Close(stanSubscription *sub)
Closes the subscription.
NATS_EXTERN natsStatus stanSubscription_Unsubscribe(stanSubscription *sub)
Permanently remove a subscription.
NATS_EXTERN void stanSubOptions_Destroy(stanSubOptions *opts)
Destroys a stanSubOptions object.
NATS_EXTERN natsStatus stanSubOptions_StartAtTimeDelta(stanSubOptions *opts, int64_t delta)
Sets the desired start position based on the given delta.
NATS_EXTERN natsStatus stanSubOptions_SetMaxInflight(stanSubOptions *opts, int maxInflight)
Sets the the maximum number of messages the cluster will send without an ACK.
NATS_EXTERN natsStatus stanSubOptions_StartAtSequence(stanSubOptions *opts, uint64_t seq)
Sets the desired start position based on the given sequence number.
NATS_EXTERN natsStatus stanSubOptions_SetManualAckMode(stanSubOptions *opts, bool manual)
Sets the subscription's acknowledgment mode.
NATS_EXTERN natsStatus stanSubOptions_StartWithLastReceived(stanSubOptions *opts)
The subscription should start with the last message in the channel.
NATS_EXTERN natsStatus stanSubOptions_SetDurableName(stanSubOptions *opts, const char *durableName)
Sets the Durable Name for this subscription.
NATS_EXTERN natsStatus stanSubOptions_StartAtTime(stanSubOptions *opts, int64_t time)
Sets the desired start position based on the given time.
NATS_EXTERN natsStatus stanSubOptions_DeliverAllAvailable(stanSubOptions *opts)
The subscription should start with the first message in the channel.
NATS_EXTERN natsStatus stanSubOptions_Create(stanSubOptions **newOpts)
Creates a stanSubOptions object.
NATS_EXTERN natsStatus stanSubOptions_SetAckWait(stanSubOptions *opts, int64_t wait)
Sets the timeout for waiting for an ACK from the cluster's point of view for delivered messages.
NATS_EXTERN void natsStatistics_Destroy(natsStatistics *stats)
Destroys the natsStatistics object.
NATS_EXTERN natsStatus natsStatistics_GetCounts(const natsStatistics *stats, uint64_t *inMsgs, uint64_t *inBytes, uint64_t *outMsgs, uint64_t *outBytes, uint64_t *reconnects)
Extracts the various statistics values.
NATS_EXTERN natsStatus natsStatistics_Create(natsStatistics **newStats)
Creates a natsStatistics object.
NATS_EXTERN const char * natsStatus_GetText(natsStatus s)
Get the text corresponding to a natsStatus.
NATS_EXTERN natsStatus natsSubscription_WaitForDrainCompletion(natsSubscription *sub, int64_t timeout)
Blocks until the drain operation completes.
NATS_EXTERN natsStatus natsSubscription_AutoUnsubscribe(natsSubscription *sub, int max)
Auto-Unsubscribes.
NATS_EXTERN natsStatus natsSubscription_GetMaxPending(natsSubscription *sub, int *msgs, int *bytes)
Returns the maximum number of pending messages and bytes.
NATS_EXTERN natsStatus natsSubscription_GetStats(natsSubscription *sub, int *pendingMsgs, int *pendingBytes, int *maxPendingMsgs, int *maxPendingBytes, int64_t *deliveredMsgs, int64_t *droppedMsgs)
Get various statistics from this subscription.
NATS_EXTERN natsStatus natsSubscription_GetDropped(natsSubscription *sub, int64_t *msgs)
Returns the number of dropped messages.
NATS_EXTERN natsStatus natsSubscription_Drain(natsSubscription *sub)
Drains the subscription with a default timeout.
NATS_EXTERN natsStatus natsSubscription_NoDeliveryDelay(natsSubscription *sub)
Enables the No Delivery Delay mode.
NATS_EXTERN natsStatus natsSubscription_GetDelivered(natsSubscription *sub, int64_t *msgs)
Returns the number of delivered messages.
NATS_EXTERN void natsSubscription_Destroy(natsSubscription *sub)
Destroys the subscription.
NATS_EXTERN bool natsSubscription_IsValid(natsSubscription *sub)
Checks the validity of the subscription.
NATS_EXTERN natsStatus natsSubscription_NextMsg(natsMsg **nextMsg, natsSubscription *sub, int64_t timeout)
Returns the next available message.
NATS_EXTERN natsStatus natsSubscription_SetPendingLimits(natsSubscription *sub, int msgLimit, int bytesLimit)
Sets the limit for pending messages and bytes.
NATS_EXTERN natsStatus natsSubscription_GetPendingLimits(natsSubscription *sub, int *msgLimit, int *bytesLimit)
Returns the current limit for pending messages and bytes.
NATS_EXTERN natsStatus natsSubscription_QueuedMsgs(natsSubscription *sub, uint64_t *queuedMsgs)
Gets the number of pending messages.
NATS_EXTERN natsStatus natsSubscription_DrainCompletionStatus(natsSubscription *sub)
Returns the status of the drain after completion.
NATS_EXTERN natsStatus natsSubscription_DrainTimeout(natsSubscription *sub, int64_t timeout)
Drains the subscription with the specified timeout.
NATS_EXTERN natsStatus natsSubscription_GetPending(natsSubscription *sub, int *msgs, int *bytes)
Returns the number of pending messages and bytes.
NATS_EXTERN natsStatus natsSubscription_SetOnCompleteCB(natsSubscription *sub, natsOnCompleteCB cb, void *closure)
Sets a completion callback.
NATS_EXTERN natsStatus natsSubscription_Unsubscribe(natsSubscription *sub)
Unsubscribes.
NATS_EXTERN natsStatus natsSubscription_ClearMaxPending(natsSubscription *sub)
Clears the statistics regarding the maximum pending values.
struct kvEntryList kvEntryList
A list of KeyValue store entries.
struct __stanSubOptions stanSubOptions
Way to configure a stanSubscription.
Definition: nats.h:1060
struct jsConsumerConfig jsConsumerConfig
struct __kvStore kvStore
Definition: nats.h:922
struct jsOptions jsOptions
jsDeliverPolicy
Definition: nats.h:284
struct __stanConnOptions stanConnOptions
Way to configure a stanConnection.
Definition: nats.h:1054
jsStorageType
Definition: nats.h:274
struct jsPeerInfo jsPeerInfo
char natsInbox
Unique subject often used for point-to-point communication.
Definition: nats.h:180
struct jsStreamInfo jsStreamInfo
struct jsStreamConfig jsStreamConfig
struct jsSequenceInfo jsSequenceInfo
struct jsStreamState jsStreamState
struct __stanMsg stanMsg
The Streaming message.
Definition: nats.h:1048
struct jsConsumerInfo jsConsumerInfo
struct jsSequencePair jsSequencePair
jsRetentionPolicy
Definition: nats.h:253
struct jsPlacement jsPlacement
struct __kvWatcher kvWatcher
Definition: nats.h:937
struct __natsStatistics natsStatistics
Statistics of a natsConnection.
Definition: nats.h:152
struct jsAccountInfo jsAccountInfo
struct kvConfig kvConfig
struct jsPubOptions jsPubOptions
jsDiscardPolicy
Definition: nats.h:264
jsReplayPolicy
Definition: nats.h:310
struct __natsSubscription natsSubscription
Interest on a given subject.
Definition: nats.h:158
kvOperation
Definition: nats.h:943
jsAckPolicy
Definition: nats.h:298
struct __stanConnection stanConnection
A connection to a NATS Streaming Server.
Definition: nats.h:1036
struct jsAccountLimits jsAccountLimits
struct __jsCtx jsCtx
Definition: nats.h:220
struct jsClusterInfo jsClusterInfo
struct jsStreamSourceInfo jsStreamSourceInfo
struct kvKeysList kvKeysList
A list of KeyValue store keys.
struct jsStreamSource jsStreamSource
struct __natsOptions natsOptions
Way to configure a natsConnection.
Definition: nats.h:171
struct kvWatchOptions kvWatchOptions
struct jsSubOptions jsSubOptions
struct jsConsumerSequenceMismatch jsConsumerSequenceMismatch
struct jsMsgMetaData jsMsgMetaData
struct jsAPIStats jsAPIStats
struct __kvStatus kvStatus
Definition: nats.h:932
struct __kvEntry kvEntry
Definition: nats.h:927
struct jsPubAckErr jsPubAckErr
struct __natsMsg natsMsg
A structure holding a subject, optional reply and payload.
Definition: nats.h:165
struct __stanSubscription stanSubscription
Interest on a given channel.
Definition: nats.h:1042
struct jsExternalStream jsExternalStream
struct jsPubAck jsPubAck
struct jsLostStreamData jsLostStreamData
struct __natsConnection natsConnection
A connection to a NATS Server.
Definition: nats.h:145
struct natsMsgList natsMsgList
A list of NATS messages.
@ js_DeliverByStartSequence
Starts from a given sequence.
Definition: nats.h:288
@ js_DeliverByStartTime
Starts from a given UTC time (number of nanoseconds since epoch)
Definition: nats.h:289
@ js_DeliverNew
Starts with messages sent after the consumer is created.
Definition: nats.h:287
@ js_DeliverLastPerSubject
Starts with the last message for all subjects received.
Definition: nats.h:290
@ js_DeliverLast
Starts with the last sequence received.
Definition: nats.h:286
@ js_DeliverAll
Starts from the very beginning of a stream. This is the default.
Definition: nats.h:285
@ js_FileStorage
Specifies on disk storage. It's the default.
Definition: nats.h:275
@ js_MemoryStorage
Specifies in memory only.
Definition: nats.h:276
@ js_LimitsPolicy
Specifies that messages are retained until any given limit is reached, which could be one of MaxMsgs,...
Definition: nats.h:254
@ js_InterestPolicy
Specifies that when all known observables have acknowledged a message it can be removed.
Definition: nats.h:255
@ js_WorkQueuePolicy
Specifies that when the first worker or subscriber acknowledges the message it can be removed.
Definition: nats.h:256
@ js_DiscardNew
Will fail to store new messages.
Definition: nats.h:266
@ js_DiscardOld
Will remove older messages to return to the limits. This is the default.
Definition: nats.h:265
@ js_ReplayInstant
Replays messages as fast as possible.
Definition: nats.h:311
@ js_ReplayOriginal
Maintains the same timing as the messages were received.
Definition: nats.h:312
@ kvOp_Unknown
Definition: nats.h:944
@ kvOp_Delete
Definition: nats.h:946
@ kvOp_Put
Definition: nats.h:945
@ kvOp_Purge
Definition: nats.h:947
@ js_AckExplicit
Requires ack or nack for all messages.
Definition: nats.h:299
@ js_AckAll
When acking a sequence number, this implicitly acks all sequences below this one as well.
Definition: nats.h:301
@ js_AckNone
Requires no acks for delivered messages.
Definition: nats.h:300
#define NATS_EXTERN
Needed for shared library.
Definition: nats.h:49
int natsSock
Definition: nats.h:50
jsErrCode
Definition: status.h:135
natsStatus
Status returned by most of the APIs.
Definition: status.h:50
natsConnStatus
The connection state.
Definition: status.h:24
Definition: nats.h:776
uint64_t Total
Definition: nats.h:777
uint64_t Errors
Definition: nats.h:778
Definition: nats.h:798
int64_t Consumers
Definition: nats.h:802
int64_t Streams
Definition: nats.h:801
uint64_t Memory
Definition: nats.h:799
jsAPIStats API
Definition: nats.h:804
jsAccountLimits Limits
Definition: nats.h:805
char * Domain
Definition: nats.h:803
uint64_t Store
Definition: nats.h:800
Definition: nats.h:786
int64_t MaxStreams
Definition: nats.h:789
int64_t MaxConsumers
Definition: nats.h:790
int64_t MaxStore
Definition: nats.h:788
int64_t MaxMemory
Definition: nats.h:787
Definition: nats.h:528
int ReplicasLen
Definition: nats.h:532
char * Name
Definition: nats.h:529
jsPeerInfo ** Replicas
Definition: nats.h:531
char * Leader
Definition: nats.h:530
Definition: nats.h:603
uint64_t OptStartSeq
Definition: nats.h:609
bool HeadersOnly
Definition: nats.h:622
uint64_t RateLimit
Definition: nats.h:616
jsDeliverPolicy DeliverPolicy
Definition: nats.h:608
const char * Description
Definition: nats.h:605
const char * Durable
Definition: nats.h:604
const char * SampleFrequency
Definition: nats.h:617
bool FlowControl
Definition: nats.h:620
int64_t AckWait
Definition: nats.h:612
int64_t OptStartTime
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:610
int64_t MaxWaiting
Definition: nats.h:618
jsAckPolicy AckPolicy
Definition: nats.h:611
const char * DeliverSubject
Definition: nats.h:606
int64_t Heartbeat
Heartbeat interval expressed in number of nanoseconds.
Definition: nats.h:621
int64_t MaxDeliver
Definition: nats.h:613
jsReplayPolicy ReplayPolicy
Definition: nats.h:615
const char * DeliverGroup
Definition: nats.h:607
int64_t MaxAckPending
Definition: nats.h:619
const char * FilterSubject
Definition: nats.h:614
Definition: nats.h:756
jsSequenceInfo Delivered
Definition: nats.h:761
jsConsumerConfig * Config
Definition: nats.h:760
bool PushBound
Definition: nats.h:768
int64_t NumWaiting
Definition: nats.h:765
int64_t Created
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:759
jsClusterInfo * Cluster
Definition: nats.h:767
int64_t NumAckPending
Definition: nats.h:763
char * Stream
Definition: nats.h:757
int64_t NumRedelivered
Definition: nats.h:764
char * Name
Definition: nats.h:758
jsSequenceInfo AckFloor
Definition: nats.h:762
uint64_t NumPending
Definition: nats.h:766
Definition: nats.h:644
uint64_t Stream
This is the stream sequence that the application should resume from.
Definition: nats.h:645
uint64_t ConsumerServer
This is the consumer sequence last sent by the server.
Definition: nats.h:647
uint64_t ConsumerClient
This is the consumer sequence that was last received by the library.
Definition: nats.h:646
Definition: nats.h:346
const char * DeliverPrefix
Definition: nats.h:348
const char * APIPrefix
Definition: nats.h:347
Definition: nats.h:480
uint64_t * Msgs
Definition: nats.h:481
uint64_t Bytes
Definition: nats.h:483
int MsgsLen
Definition: nats.h:482
Definition: nats.h:817
uint64_t NumPending
Definition: nats.h:820
jsSequencePair Sequence
Definition: nats.h:818
char * Stream
Definition: nats.h:822
char * Domain
Definition: nats.h:824
char * Consumer
Definition: nats.h:823
uint64_t NumDelivered
Definition: nats.h:819
int64_t Timestamp
Definition: nats.h:821
Definition: nats.h:873
jsPubAckErrHandler ErrHandler
Callback invoked when error encountered publishing a given message.
Definition: nats.h:875
void * ErrHandlerClosure
Closure (or user data) passed to jsPubAckErrHandler callback.
Definition: nats.h:876
int64_t StallWait
Amount of time (in milliseconds) to wait in a PublishAsync call when there is MaxPending inflight mes...
Definition: nats.h:877
int64_t MaxPending
Maximum outstanding asynchronous publishes that can be inflight at one time.
Definition: nats.h:874
bool DeletedDetails
Get the list of deleted message sequences.
Definition: nats.h:911
uint64_t Sequence
Purge up to but not including sequence.
Definition: nats.h:901
uint64_t Keep
Number of messages to keep.
Definition: nats.h:902
const char * Subject
This is the subject to match against messages for the purge command.
Definition: nats.h:900
Definition: nats.h:888
struct jsOptions::jsOptionsStream::jsOptionsStreamInfo Info
Optional stream information retrieval options.
struct jsOptions::jsOptionsStream::jsOptionsStreamPurge Purge
Optional stream purge options.
Definition: nats.h:864
struct jsOptions::jsOptionsPublishAsync PublishAsync
int64_t Wait
Amount of time (in milliseconds) to wait for various JetStream API requests, default is 5000 ms (5 se...
Definition: nats.h:867
const char * Prefix
JetStream prefix, default is "$JS.API".
Definition: nats.h:865
const char * Domain
Domain changes the domain part of JetSteam API prefix.
Definition: nats.h:866
struct jsOptions::jsOptionsStream Stream
Optional stream options.
Definition: nats.h:514
bool Offline
Definition: nats.h:517
uint64_t Lag
Definition: nats.h:519
int64_t Active
Definition: nats.h:518
char * Name
Definition: nats.h:515
bool Current
Definition: nats.h:516
Definition: nats.h:329
int TagsLen
Definition: nats.h:332
const char * Cluster
Definition: nats.h:330
const char ** Tags
Definition: nats.h:331
Definition: nats.h:845
natsMsg * Msg
Definition: nats.h:846
natsStatus Err
Definition: nats.h:847
jsErrCode ErrCode
Definition: nats.h:848
const char * ErrText
Definition: nats.h:849
Definition: nats.h:832
uint64_t Sequence
Definition: nats.h:834
bool Duplicate
Definition: nats.h:836
char * Domain
Definition: nats.h:835
char * Stream
Definition: nats.h:833
Definition: nats.h:238
const char * ExpectLastMsgId
Expected last message ID in the stream.
Definition: nats.h:242
int64_t MaxWait
Amount of time (in milliseconds) to wait for a publish response, default will the context's Wait valu...
Definition: nats.h:239
uint64_t ExpectLastSeq
Expected last message sequence in the stream.
Definition: nats.h:243
bool ExpectNoMessage
Expected no message (that is, sequence == 0) for the subject in the stream.
Definition: nats.h:245
const char * ExpectStream
Expected stream to respond from the publish call.
Definition: nats.h:241
const char * MsgId
Message ID used for de-duplication.
Definition: nats.h:240
uint64_t ExpectLastSubjectSeq
Expected last message sequence for the subject in the stream.
Definition: nats.h:244
Definition: nats.h:742
int64_t Last
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:745
uint64_t Stream
Definition: nats.h:744
uint64_t Consumer
Definition: nats.h:743
Definition: nats.h:732
uint64_t Consumer
Definition: nats.h:733
uint64_t Stream
Definition: nats.h:734
Definition: nats.h:443
jsDiscardPolicy Discard
Definition: nats.h:455
const char ** Subjects
Definition: nats.h:446
int SourcesLen
Definition: nats.h:464
const char * Description
Definition: nats.h:445
const char * Template
Definition: nats.h:459
bool DenyPurge
Restrict the ability to purge messages.
Definition: nats.h:467
jsStorageType Storage
Definition: nats.h:456
jsRetentionPolicy Retention
Definition: nats.h:448
int64_t MaxMsgs
Definition: nats.h:450
int64_t MaxConsumers
Definition: nats.h:449
const char * Name
Definition: nats.h:444
bool NoAck
Definition: nats.h:458
jsStreamSource ** Sources
Definition: nats.h:463
int32_t MaxMsgSize
Definition: nats.h:454
int64_t Duplicates
Definition: nats.h:460
int64_t MaxMsgsPerSubject
Definition: nats.h:453
int64_t MaxAge
Definition: nats.h:452
int SubjectsLen
Definition: nats.h:447
bool AllowRollup
Definition: nats.h:472
jsStreamSource * Mirror
Definition: nats.h:462
jsPlacement * Placement
Definition: nats.h:461
int64_t MaxBytes
Definition: nats.h:451
int64_t Replicas
Definition: nats.h:457
bool Sealed
Seal a stream so no messages can get our or in.
Definition: nats.h:465
bool DenyDelete
Restrict the ability to delete messages.
Definition: nats.h:466
Definition: nats.h:555
jsStreamSourceInfo ** Sources
Definition: nats.h:561
int64_t Created
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:557
jsStreamState State
Definition: nats.h:558
jsClusterInfo * Cluster
Definition: nats.h:559
jsStreamSourceInfo * Mirror
Definition: nats.h:560
jsStreamConfig * Config
Definition: nats.h:556
int SourcesLen
Definition: nats.h:562
Definition: nats.h:365
jsExternalStream * External
Definition: nats.h:370
int64_t OptStartTime
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:368
const char * Name
Definition: nats.h:366
uint64_t OptStartSeq
Definition: nats.h:367
const char * FilterSubject
Definition: nats.h:369
Definition: nats.h:540
int64_t Active
Definition: nats.h:544
char * Name
Definition: nats.h:541
jsExternalStream * External
Definition: nats.h:542
uint64_t Lag
Definition: nats.h:543
Definition: nats.h:494
jsLostStreamData * Lost
Definition: nats.h:504
uint64_t LastSeq
Definition: nats.h:499
int64_t Consumers
Definition: nats.h:505
int DeletedLen
Definition: nats.h:503
uint64_t Msgs
Definition: nats.h:495
uint64_t FirstSeq
Definition: nats.h:497
int64_t LastTime
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:500
uint64_t * Deleted
Definition: nats.h:502
uint64_t NumDeleted
Definition: nats.h:501
uint64_t Bytes
Definition: nats.h:496
int64_t FirstTime
UTC time expressed as number of nanoseconds since epoch.
Definition: nats.h:498
Definition: nats.h:667
bool ManualAck
If true, the user will have to acknowledge the messages.
Definition: nats.h:712
const char * Consumer
If specified, the subscription will be bound to an existing consumer from the Stream without attempti...
Definition: nats.h:684
const char * Stream
If specified, the consumer will be bound to this stream name.
Definition: nats.h:674
bool Ordered
If true, this will be an ordered consumer.
Definition: nats.h:724
const char * Queue
Queue name for queue subscriptions.
Definition: nats.h:699
jsConsumerConfig Config
Consumer configuration.
Definition: nats.h:717
Definition: nats.h:957
uint8_t History
Definition: nats.h:961
const char * Bucket
Definition: nats.h:958
int64_t MaxBytes
Definition: nats.h:963
int32_t MaxValueSize
Definition: nats.h:960
int Replicas
Definition: nats.h:965
const char * Description
Definition: nats.h:959
int64_t TTL
Definition: nats.h:962
jsStorageType StorageType
Definition: nats.h:964
A list of KeyValue store entries.
Definition: nats.h:1001
const int Count
Definition: nats.h:1003
kvEntry ** Entries
Definition: nats.h:1002
A list of KeyValue store keys.
Definition: nats.h:1025
const int Count
Definition: nats.h:1027
char ** Keys
Definition: nats.h:1026
Definition: nats.h:975
bool IgnoreDeletes
Definition: nats.h:976
bool IncludeHistory
Definition: nats.h:977
int64_t Timeout
How long to wait (in milliseconds) for some operations to complete.
Definition: nats.h:979
bool MetaOnly
Definition: nats.h:978
A list of NATS messages.
Definition: nats.h:206
const int Count
Definition: nats.h:208
natsMsg ** Msgs
Definition: nats.h:207