NATS C Client with JetStream and Streaming support  3.11.0
The nats.io C Client, Supported by Synadia Communications Inc.
Loading...
Searching...
No Matches
nats.h
Go to the documentation of this file.
1// Copyright 2015-2025 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 // Headers for republished messages and direct get.
132 #define JSStream "Nats-Stream"
133 #define JSSequence "Nats-Sequence"
134 #define JSLastSequence "Nats-Last-Sequence"
135 #define JSTimeStamp "Nats-Time-Stamp"
136 #define JSSubject "Nats-Subject"
137
138//
139// Types.
140//
152typedef struct __natsConnection natsConnection;
153
159typedef struct __natsStatistics natsStatistics;
160
165typedef struct __natsSubscription natsSubscription;
166
172typedef struct __natsMsg natsMsg;
173
178typedef struct __natsOptions natsOptions;
179
187typedef char natsInbox;
188
193typedef struct __natsHeader natsHeader;
194
200typedef struct __natsClientConfig
201{
203
205
206 // Subscription message delivery thread control
209
210 // Reply message delivery thread control
215
239typedef struct natsMsgList
240{
242 int Count;
243
245
250typedef struct natsMetadata
251{
255 const char **List;
259 int Count;
260
262
271typedef struct __jsCtx jsCtx;
272
288typedef struct jsPubOptions
289{
290 int64_t MaxWait;
291 const char *MsgId;
292 const char *ExpectStream;
293 const char *ExpectLastMsgId;
294 uint64_t ExpectLastSeq;
297 int64_t MsgTTL;
298
300
311
315typedef enum
316{
319
321
325typedef enum
326{
329
331
340
354
358typedef enum
359{
363
364
366
376
377
389typedef struct jsPlacement
390{
391 const char *Cluster;
392 const char **Tags;
394
396
406typedef struct jsExternalStream
407{
408 const char *APIPrefix;
409 const char *DeliverPrefix;
410
412
425typedef struct jsStreamSource
426{
427 const char *Name;
428 uint64_t OptStartSeq;
429 int64_t OptStartTime;
430 const char *FilterSubject;
432 // Domain and External are mutually exclusive.
433 // If Domain is set, an External value will be created with
434 // the APIPrefix constructed based on the Domain value.
435 const char *Domain;
436
438
442typedef struct jsRePublish
443{
444 const char *Source;
445 const char *Destination;
447
449
459
469
625
629typedef struct jsLostStreamData
630{
631 uint64_t *Msgs;
633 uint64_t Bytes;
634
636
643{
644 const char *Subject;
645 uint64_t Msgs;
646
648
684
691typedef struct jsStreamState
692{
693 uint64_t Msgs;
694 uint64_t Bytes;
695 uint64_t FirstSeq;
696 int64_t FirstTime;
697 uint64_t LastSeq;
698 int64_t LastTime;
699 int64_t NumSubjects;
701 uint64_t NumDeleted;
702 uint64_t *Deleted;
705 int64_t Consumers;
706
708
713typedef struct jsPeerInfo
714{
715 char *Name;
718 int64_t Active;
719 uint64_t Lag;
720
722
735
750
754typedef struct jsStreamAlternate
755{
756 const char *Name;
757 const char *Domain;
758 const char *Cluster;
759
761
781
795
803typedef struct jsStreamNamesList
804{
805 char **List;
806 int Count;
807
809
853typedef struct jsConsumerConfig
854{
855 const char *Name;
856 const char *Durable;
857 const char *Description;
859 uint64_t OptStartSeq;
860 int64_t OptStartTime;
862 int64_t AckWait;
863 int64_t MaxDeliver;
864 int64_t *BackOff;
866 const char *FilterSubject;
868 uint64_t RateLimit;
869 const char *SampleFrequency;
870 int64_t MaxWaiting;
873 int64_t Heartbeat;
875
876 // Pull based options.
880
881 // Push based options.
882 const char *DeliverSubject;
883 const char *DeliverGroup;
884
885 // Ephemeral inactivity threshold.
887
888 // Generally inherited by parent stream and other markers, now can be configured directly.
889 int64_t Replicas;
890 // Force memory storage.
892
893 // Configuration options introduced in 2.10
894
895 const char **FilterSubjects;
898
899 // Configuration options introduced in 2.11
900
904 int64_t PauseUntil;
905
909 const char *PriorityPolicy;
910
915 int64_t PinnedTTL;
916
918 const char **PriorityGroups;
921
946
962typedef struct jsSubOptions
963{
970 const char *Stream;
980 const char *Consumer;
995 const char *Queue;
1020 bool Ordered;
1021
1023
1027typedef struct jsSequencePair
1028{
1029 uint64_t Consumer;
1030 uint64_t Stream;
1031
1033
1037typedef struct jsSequenceInfo
1038{
1039 uint64_t Consumer;
1040 uint64_t Stream;
1041 int64_t Last;
1042
1044
1054
1080
1094
1103{
1104 char **List;
1106
1108
1120
1124typedef struct jsAPIStats
1125{
1126 uint64_t Total;
1127 uint64_t Errors;
1128
1130
1146
1147typedef struct jsTier
1148{
1149 const char *Name;
1150 uint64_t Memory;
1151 uint64_t Store;
1152 int64_t Streams;
1153 int64_t Consumers;
1155
1157
1174
1193
1197typedef struct jsPubAck
1198{
1199 char *Stream;
1200 uint64_t Sequence;
1201 char *Domain;
1203
1205
1218
1219#ifndef BUILD_IN_DOXYGEN
1220// Forward declarations
1221typedef void (*jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure);
1222typedef void (*jsPubAckHandler)(jsCtx *js, natsMsg *msg, jsPubAck *pa, jsPubAckErr *pae, void *closure);
1223#endif
1224
1235{
1236 uint64_t Sequence;
1237 const char *NextBySubject;
1238 const char *LastBySubject;
1239
1241
1247typedef struct jsFetchRequest
1248{
1249 int64_t Expires;
1250 int Batch;
1251 int64_t MaxBytes;
1252 bool NoWait;
1253 int64_t Heartbeat;
1254
1255 // The use of these fields require nats-server v2.11.0 or later
1256 int64_t MinPending;
1258 const char *ID;
1260 const char *Group;
1261
1263
1285typedef void (*jsFetchCompleteHandler)(natsConnection *nc, natsSubscription *sub, natsStatus s, void *closure);
1286
1297typedef bool (*jsFetchNextHandler)(int *messages, int64_t *maxBytes, natsSubscription *sub, void *closure);
1298
1371
1378{
1379 int64_t MaxPending;
1380
1381 // If jsPubAckHandler is specified, the callback will be invoked
1382 // for every asynchronous published message, either as a positive
1383 // result, or with the error encountered when publishing that
1384 // message. If this callback is specified, ErrHandler (see below)
1385 // will be ignored.
1388
1389 // This callback is invoked for messages published asynchronously
1390 // when an error is returned by the server or if the library has
1391 // timed-out waiting for an acknowledgment back from the server
1392 // (if publish uses the jsPubOptions.MaxWait).
1395
1396 int64_t StallWait;
1397
1399
1410{
1411 const char *Subject;
1412 uint64_t Sequence;
1413 uint64_t Keep;
1414
1416
1426
1439
1455
1459typedef struct __kvStore kvStore;
1460
1464typedef struct __kvEntry kvEntry;
1465
1469typedef struct __kvStatus kvStatus;
1470
1474typedef struct __kvWatcher kvWatcher;
1475
1487
1509
1524
1530typedef struct kvPurgeOptions
1531{
1532 // How long to wait (in milliseconds) for some operations to complete.
1533 int64_t Timeout;
1534
1535 // When calling kvStore_PurgeDeletes(), all keys that have a delete or
1536 // purge marker as the last entry are gathered and then those keys
1537 // are purged of their content, including the marker.
1538 // Starting with NATS C client v3.3.0, if this option is not specified,
1539 // only the markers older than 30 minutes will be deleted. Use this
1540 // option to set the limit or a negative value to force removal of
1541 // markers regardless of their age.
1542 // The value is expressed as a time in nanoseconds.
1544
1546
1564typedef struct kvEntryList
1565{
1568
1570
1588typedef struct kvKeysList
1589{
1590 char **Keys;
1592
1594
1598typedef struct __objStore objStore;
1599
1612typedef struct __objStorePut objStorePut;
1613
1619typedef struct __objStoreGet objStoreGet;
1620
1624typedef struct __objStoreWatcher objStoreWatcher;
1625
1653typedef struct objStoreConfig
1654{
1661 const char *Bucket;
1662
1666 const char *Description;
1667
1674 int64_t TTL;
1675
1681 int64_t MaxBytes;
1682
1689
1696
1704
1711
1712 // /**
1713 // * @brief Bucket-specific metadata.
1714 // *
1715 // * \note Metadata requires nats-server v2.10.0+
1716 // */
1718
1720
1728typedef struct objStoreNamesList
1729{
1730 char **List;
1732
1734
1748typedef struct objStoreStatus
1749{
1753 const char *Bucket;
1754
1758 const char *Description;
1759
1763 int64_t TTL;
1764
1769
1774
1779
1783 uint64_t Size;
1784
1790 const char *BackingStore;
1791
1796
1801
1806
1808
1822
1826typedef struct objStoreLink
1827{
1831 const char *Bucket;
1832
1838 const char *Name;
1839
1841
1862
1897
1901typedef struct objStoreInfo
1902{
1907
1911 const char *Bucket;
1912
1916 const char *NUID;
1917
1921 uint64_t Size;
1922
1926 int64_t ModTime;
1927
1933 uint32_t Chunks;
1934
1940 const char *Digest;
1941
1946
1948
1962
1985
2010
2011
2012#if defined(NATS_HAS_STREAMING)
2017typedef struct __stanConnection stanConnection;
2018
2023typedef struct __stanSubscription stanSubscription;
2024
2029typedef struct __stanMsg stanMsg;
2030
2035typedef struct __stanConnOptions stanConnOptions;
2036
2041typedef struct __stanSubOptions stanSubOptions;
2042#endif
2043
// end of typesGroup
2045
2046//
2047// Callbacks.
2048//
2049
2072typedef void (*natsMsgHandler)(
2073 natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure);
2074
2089 natsConnection *nc, void *closure);
2090
2103 natsSock *fd, char *host, int port, void *closure);
2104
2111typedef void (*natsErrHandler)(
2112 natsConnection *nc, natsSubscription *subscription, natsStatus err,
2113 void *closure);
2114
2129 void **userData,
2130 void *loop,
2131 natsConnection *nc,
2132 natsSock socket);
2133
2144 void *userData,
2145 bool add);
2146
2157 void *userData,
2158 bool add);
2159
2168 void *userData);
2169
2192 char **userJWT,
2193 char **customErrTxt,
2194 void *closure);
2195
2196
2223 char **customErrTxt,
2224 unsigned char **signature,
2225 int *signatureLength,
2226 const char *nonce,
2227 void *closure);
2228
2237typedef const char* (*natsTokenHandler)(void *closure);
2238
2239
2247typedef void (*natsOnCompleteCB)(void *closure);
2248
2269typedef int64_t (*natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure);
2270
2294typedef int (*natsSSLVerifyCb)(int preverifyOk, void *ctx);
2295
2296#ifdef BUILD_IN_DOXYGEN
2330typedef void (*jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure);
2331
2373typedef void (*jsPubAckHandler)(jsCtx *js, natsMsg *msg, jsPubAck *pa, jsPubAckErr *pae, void *closure);
2374#endif
2375
2376#if defined(NATS_HAS_STREAMING)
2385typedef void (*stanPubAckHandler)(const char *guid, const char *error, void *closure);
2386
2396typedef void (*stanMsgHandler)(
2397 stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure);
2398
2406 stanConnection *sc, const char* errorTxt, void *closure);
2407#endif
2408
// end of callbacksGroup
2410
2411//
2412// Functions.
2413//
2442
2457nats_Open(int64_t lockSpinCount);
2458
2459
2464NATS_EXTERN const char*
2466
2474NATS_EXTERN uint32_t
2476
2477#ifdef BUILD_IN_DOXYGEN
2492NATS_EXTERN bool
2494#else
2495
2496#define nats_CheckCompatibility() nats_CheckCompatibilityImpl(NATS_VERSION_REQUIRED_NUMBER, \
2497 NATS_VERSION_NUMBER, \
2498 NATS_VERSION_STRING)
2499
2500NATS_EXTERN bool
2501nats_CheckCompatibilityImpl(uint32_t reqVerNumber, uint32_t verNumber, const char *verString);
2502
2503#endif
2504
2509NATS_EXTERN int64_t
2511
2517NATS_EXTERN int64_t
2519
2529NATS_EXTERN int64_t
2531
2539NATS_EXTERN void
2540nats_Sleep(int64_t sleepTime);
2541
2554NATS_EXTERN const char*
2556
2566nats_GetLastErrorStack(char *buffer, size_t bufLen);
2567
2588NATS_EXTERN void
2590
2622
2633NATS_EXTERN void
2635
2661nats_Sign(const char *encodedSeed,
2662 const char *input,
2663 unsigned char **signature,
2664 int *signatureLength);
2665
2686NATS_EXTERN void
2688
2735nats_CloseAndWait(int64_t timeout);
2736
// end of libraryGroup
2738
2754NATS_EXTERN const char*
2756
// end of statusGroup
2758
2778
2797 uint64_t *inMsgs, uint64_t *inBytes,
2798 uint64_t *outMsgs, uint64_t *outBytes,
2799 uint64_t *reconnects);
2800
2807NATS_EXTERN void
2809
// end of statsGroup
2811
2838
2860/*
2861 * The above is for doxygen. The proper syntax for username/password
2862 * is without the '\' character:
2863 *
2864 * nats://localhost:4222
2865 * nats://user@localhost:4222
2866 * nats://user:password@localhost:4222
2867 */
2869natsOptions_SetURL(natsOptions *opts, const char *url);
2870
2886natsOptions_SetServers(natsOptions *opts, const char** servers, int serversCount);
2887
2914natsOptions_SetUserInfo(natsOptions *opts, const char *user, const char *password);
2915
2941natsOptions_SetToken(natsOptions *opts, const char *token);
2942
2960 void *closure);
2961
2973
2987natsOptions_SetTimeout(natsOptions *opts, int64_t timeout);
2988
2997natsOptions_SetName(natsOptions *opts, const char *name);
2998
3017
3039
3080
3098
3116
3145natsOptions_SetCATrustedCertificates(natsOptions *opts, const char *certificates);
3146
3165 const char *certsFileName,
3166 const char *keyFileName);
3167
3185 const char *certsFileName,
3186 const char *keyFileName);
3187
3203 const char *cert,
3204 const char *key);
3205
3224natsOptions_SetCiphers(natsOptions *opts, const char *ciphers);
3225
3242natsOptions_SetCipherSuites(natsOptions *opts, const char *ciphers);
3243
3257
3274
3289
3302
3315
3327
3341
3355
3369
3379
3394natsOptions_SetReconnectWait(natsOptions *opts, int64_t reconnectWait);
3395
3420natsOptions_SetReconnectJitter(natsOptions *opts, int64_t jitter, int64_t jitterTLS);
3421
3443 void *closure);
3444
3459
3475
3491
3505 void *closure);
3506
3523 void *closure);
3524
3539 void *closure);
3540
3559 natsConnectionHandler disconnectedCb,
3560 void *closure);
3561
3579 natsConnectionHandler reconnectedCb,
3580 void *closure);
3581
3598 natsConnectionHandler discoveredServersCb,
3599 void *closure);
3600
3616
3635 natsConnectionHandler lameDuckCb,
3636 void *closure);
3637
3657 void *loop,
3658 natsEvLoop_Attach attachCb,
3661 natsEvLoop_Detach detachCb);
3662
3687
3712
3742
3754
3771
3792
3848 natsConnectionHandler connectedCb, void* closure);
3849
3880 natsUserJWTHandler ujwtCB,
3881 void *ujwtClosure,
3883 void *sigClosure);
3884
3925 const char *userOrChainedFile,
3926 const char *seedFile);
3927
3942 const char *jwtAndSeedContent);
3943
3969 const char *pubKey,
3971 void *sigClosure);
3972
3999 const char *pubKey,
4000 const char *seedFile);
4001
4017
4054
4071natsOptions_SetCustomInboxPrefix(natsOptions *opts, const char *inboxPrefix);
4072
4088
4096NATS_EXTERN void
4098
// end of optsGroup
4100
4101#if defined(NATS_HAS_STREAMING)
4137
4161
4180
4192
4204
4214
4215
4231stanConnOptions_SetMaxPubAcksInflight(stanConnOptions *opts, int maxPubAcksInflight, float percentage);
4232
4249stanConnOptions_SetPings(stanConnOptions *opts, int interval, int maxOut);
4250
4263
4271NATS_EXTERN void
4273
// end of stanConnOptsGroup
4275
4308
4328stanSubOptions_SetDurableName(stanSubOptions *opts, const char *durableName);
4329
4345
4359
4377
4394
4408
4419
4429
4446
4454NATS_EXTERN void
4456
// end of stanSubOptsGroup
4458#endif
4459
4481
4488NATS_EXTERN void
4490
// end of inboxGroup
4492
4513
4526natsHeader_Set(natsHeader *h, const char *key, const char *value);
4527
4540natsHeader_Add(natsHeader *h, const char *key, const char *value);
4541
4558natsHeader_Get(natsHeader *h, const char *key, const char **value);
4559
4590natsHeader_Values(natsHeader *h, const char *key, const char* **values, int *count);
4591
4621natsHeader_Keys(natsHeader *h, const char* **keys, int *count);
4622
4628NATS_EXTERN int
4630
4643natsHeader_Delete(natsHeader *h, const char *key);
4644
4651NATS_EXTERN void
4653
// end of headerGroup
4655
4674NATS_EXTERN void
4676
4695natsMsg_Create(natsMsg **newMsg, const char *subj, const char *reply,
4696 const char *data, int dataLen);
4697
4706NATS_EXTERN const char*
4708
4718NATS_EXTERN const char*
4720
4736NATS_EXTERN const char*
4738
4745NATS_EXTERN int
4747
4764natsMsgHeader_Set(natsMsg *msg, const char *key, const char *value);
4765
4782natsMsgHeader_Add(natsMsg *msg, const char *key, const char *value);
4783
4803natsMsgHeader_Get(natsMsg *msg, const char *key, const char **value);
4804
4839natsMsgHeader_Values(natsMsg *msg, const char *key, const char* **values, int *count);
4840
4871natsMsgHeader_Keys(natsMsg *msg, const char* **keys, int *count);
4872
4887natsMsgHeader_Delete(natsMsg *msg, const char *key);
4888
4914NATS_EXTERN bool
4916
4923NATS_EXTERN void
4925
// end of msgGroup
4927
4928#if defined(NATS_HAS_STREAMING)
4941NATS_EXTERN uint64_t
4943
4950NATS_EXTERN int64_t
4952
4961NATS_EXTERN bool
4963
4979NATS_EXTERN const char*
4981
4988NATS_EXTERN int
4990
4997NATS_EXTERN void
4999
// end of stanMsgGroup
5001#endif
5002
5035
5047
5058NATS_EXTERN void
5060
5072NATS_EXTERN void
5074
5085NATS_EXTERN void
5087
5098NATS_EXTERN void
5100
5121
5128NATS_EXTERN bool
5130
5137NATS_EXTERN bool
5139
5146NATS_EXTERN bool
5148
5159
5171NATS_EXTERN int
5173
5191
5206
5216NATS_EXTERN int64_t
5218
5230
5241natsConnection_GetConnectedUrl(natsConnection *nc, char *buffer, size_t bufferSize);
5242
5253natsConnection_GetConnectedServerId(natsConnection *nc, char *buffer, size_t bufferSize);
5254
5276natsConnection_GetServers(natsConnection *nc, char ***servers, int *count);
5277
5299natsConnection_GetDiscoveredServers(natsConnection *nc, char ***servers, int *count);
5300
5318natsConnection_GetLastError(natsConnection *nc, const char **lastError);
5319
5344
5360
5381
5401
5416 const unsigned char *message, int messageLen,
5417 unsigned char sig[64]);
5418
5439
5452
5462
5484
5494NATS_EXTERN void
5496
5504NATS_EXTERN void
5506
// end of connMgtGroup
5508
5527 const void *data, int dataLen);
5528
5545 const char *str);
5546
5559
5574 const char *reply, const void *data, int dataLen);
5575
5594 const char *reply, const char *str);
5595
5614natsConnection_Request(natsMsg **replyMsg, natsConnection *nc, const char *subj,
5615 const void *data, int dataLen, int64_t timeout);
5616
5640 const char *subj, const char *str,
5641 int64_t timeout);
5642
5659 natsMsg *requestMsg, int64_t timeout);
5660
// end of connPubGroup
5662
5685 const char *subject, natsMsgHandler cb,
5686 void *cbClosure);
5687
5720 const char *subject, int64_t timeout,
5721 natsMsgHandler cb, void *cbClosure);
5722
5735 const char *subject);
5736
5756 const char *subject, const char *queueGroup,
5757 natsMsgHandler cb, void *cbClosure);
5758
5793 const char *subject, const char *queueGroup,
5794 int64_t timeout, natsMsgHandler cb, void *cbClosure);
5795
5809 const char *subject, const char *queueGroup);
5810
// end of connSubGroup
5812
// end of connGroup
5814
5835
5860 int64_t timeout);
5861
5872
5886
5898
5907NATS_EXTERN int64_t
5909
5920NATS_EXTERN const char*
5922
5944natsSubscription_SetPendingLimits(natsSubscription *sub, int msgLimit, int bytesLimit);
5945
5966natsSubscription_GetPendingLimits(natsSubscription *sub, int *msgLimit, int *bytesLimit);
5967
5984
5995
6013
6028
6037
6066 int *pendingMsgs,
6067 int *pendingBytes,
6068 int *maxPendingMsgs,
6069 int *maxPendingBytes,
6070 int64_t *deliveredMsgs,
6071 int64_t *droppedMsgs);
6072
6081NATS_EXTERN bool
6083
6103
6156
6181
6209
6240
6248NATS_EXTERN void
6250
// end of subGroup
6252
6253#if defined(NATS_HAS_STREAMING)
6295stanConnection_Connect(stanConnection **sc, const char *clusterID, const char *clientID,
6296 stanConnOptions *options);
6297
6322
6347NATS_EXTERN void
6349
6362
6372
// end of stanConnMgtGroup
6374
6393 const void *data, int dataLen);
6394
6420 const void *data, int dataLen,
6421 stanPubAckHandler ah, void *ahClosure);
6422
// end of stanConnPubGroup
6424
6449 const char *channel, stanMsgHandler cb,
6450 void *cbClosure, stanSubOptions *options);
6451
6473 const char *channel, const char *queueGroup,
6474 stanMsgHandler cb, void *cbClosure, stanSubOptions *options);
6475
// end of stanConnSubGroup
6477
// end of stanConnGroup
6479
6510
6522
6544
6557
6565NATS_EXTERN void
6567
// end of stanSubGroup
6569#endif
6570
6586
6603
6610NATS_EXTERN void
6612
6628
6637
6646
6655
6664
6686
6708
6732js_PurgeStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
6733
6745js_DeleteStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
6746
6765js_GetMsg(natsMsg **msg, jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
6766
6785js_GetLastMsg(natsMsg **msg, jsCtx *js, const char *stream, const char *subject, jsOptions *opts, jsErrCode *errCode);
6786
6796
6820js_DirectGetMsg(natsMsg **msg, jsCtx *js, const char *stream, jsOptions *opts, jsDirectGetMsgOptions *dgOpts);
6821
6839js_DeleteMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
6840
6856js_EraseMsg(jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode);
6857
6885js_GetStreamInfo(jsStreamInfo **si, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
6886
6893NATS_EXTERN void
6895
6912
6922NATS_EXTERN void
6924
6941
6951NATS_EXTERN void
6953
6964
6986 const char *stream, jsConsumerConfig *cfg,
6987 jsOptions *opts, jsErrCode *errCode);
6988
7010 const char *stream, jsConsumerConfig *cfg,
7011 jsOptions *opts, jsErrCode *errCode);
7012
7028 const char *stream, const char *consumer,
7029 jsOptions *opts, jsErrCode *errCode);
7030
7043js_DeleteConsumer(jsCtx *js, const char *stream, const char *consumer,
7044 jsOptions *opts, jsErrCode *errCode);
7045
7062 const char *stream, const char *consumer,
7063 uint64_t pauseUntil, jsOptions *opts, jsErrCode *errCode);
7064
7071NATS_EXTERN void
7073
7080NATS_EXTERN void
7082
7098js_Consumers(jsConsumerInfoList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
7099
7109NATS_EXTERN void
7111
7127js_ConsumerNames(jsConsumerNamesList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode);
7128
7138NATS_EXTERN void
7140
7157
7164NATS_EXTERN void
7166
// end of jsAssetsGroup
7168
7184
7201js_Publish(jsPubAck **pubAck, jsCtx *js, const char *subj, const void *data, int dataLen,
7202 jsPubOptions *opts, jsErrCode *errCode);
7203
7225 jsPubOptions *opts, jsErrCode *errCode);
7226
7233NATS_EXTERN void
7235
7247js_PublishAsync(jsCtx *js, const char *subj, const void *data, int dataLen,
7248 jsPubOptions *opts);
7249
7275
7289
7340
// end of jsPubGroup
7342
7358
7405js_Subscribe(natsSubscription **sub, jsCtx *js, const char *subject,
7406 natsMsgHandler cb, void* cbClosure,
7407 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
7408
7427js_SubscribeMulti(natsSubscription **sub, jsCtx *js, const char **subjects, int numSubjects,
7428 natsMsgHandler cb, void *cbClosure,
7429 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
7430
7445js_SubscribeSync(natsSubscription **sub, jsCtx *js, const char *subject,
7446 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
7447
7464js_SubscribeSyncMulti(natsSubscription **sub, jsCtx *js, const char **subjects, int numSubjects,
7465 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
7466
7489js_PullSubscribe(natsSubscription **sub, jsCtx *js, const char *subject, const char *durable,
7490 jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode);
7491
7511natsSubscription_Fetch(natsMsgList *list, natsSubscription *sub, int batch, int64_t timeout,
7512 jsErrCode *errCode);
7513
7522
7547js_PullSubscribeAsync(natsSubscription **newsub, jsCtx *js, const char *subject, const char *durable,
7548 natsMsgHandler msgCB, void *msgCBClosure,
7549 jsOptions *jsOpts, jsSubOptions *opts, jsErrCode *errCode);
7550
7565
7585js_UnpinConsumer(jsCtx *js, const char *stream, const char *consumer, const char *group,
7586 jsOptions *opts, jsErrCode *errCode);
7587
7600 jsOptions *opts, jsErrCode *errCode);
7601
7631
// end of jsSubGroup
7633
7656
7663NATS_EXTERN void
7665
7676
7690
7703
7717natsMsg_NakWithDelay(natsMsg *msg, int64_t delay, jsOptions *opts);
7718
7729
7740
7750NATS_EXTERN uint64_t
7752
7762NATS_EXTERN int64_t
7764
// end of jsMsg
7766
// end of jsGroup
7768
7793
7810
7827js_KeyValue(kvStore **new_kv, jsCtx *js, const char *bucket);
7828
7839js_DeleteKeyValue(jsCtx *js, const char *bucket);
7840
7848NATS_EXTERN void
7850
// end of kvGroupMgt
7852
7866NATS_EXTERN const char*
7868
7875NATS_EXTERN const char*
7877
7884NATS_EXTERN const void*
7886
7893NATS_EXTERN int
7895
7903NATS_EXTERN const char*
7905
7912NATS_EXTERN uint64_t
7914
7921NATS_EXTERN int64_t
7923
7933NATS_EXTERN uint64_t
7935
7946
7953NATS_EXTERN void
7955
// end of kvEntry
7957
7969kvStore_Get(kvEntry **new_entry, kvStore *kv, const char *key);
7970
7984kvStore_GetRevision(kvEntry **new_entry, kvStore *kv, const char *key, uint64_t revision);
7985
7997kvStore_Put(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len);
7998
8013kvStore_PutString(uint64_t *rev, kvStore *kv, const char *key, const char *data);
8014
8026kvStore_Create(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len);
8027
8042kvStore_CreateString(uint64_t *rev, kvStore *kv, const char *key, const char *data);
8043
8056kvStore_Update(uint64_t *rev, kvStore *kv, const char *key, const void *data, int len, uint64_t last);
8057
8073kvStore_UpdateString(uint64_t *rev, kvStore *kv, const char *key, const char *data, uint64_t last);
8074
8083kvStore_Delete(kvStore *kv, const char *key);
8084
8094kvStore_Purge(kvStore *kv, const char *key, kvPurgeOptions *opts);
8095
8105
8115
8135
8153kvStore_Watch(kvWatcher **new_watcher, kvStore *kv, const char *keys, kvWatchOptions *opts);
8154
8177kvStore_WatchMulti(kvWatcher **new_watcher, kvStore *kv, const char **keys, int numKeys, kvWatchOptions *opts);
8178
8195
8216
8241kvStore_KeysWithFilters(kvKeysList *list, kvStore *kv, const char **filters, int numFilters, kvWatchOptions *opts);
8242
8254NATS_EXTERN void
8256
8280kvStore_History(kvEntryList *list, kvStore *kv, const char *key, kvWatchOptions *opts);
8281
8293NATS_EXTERN void
8295
8305NATS_EXTERN const char*
8307
8308// PurgeDeletes
8309
8321
8345kvWatcher_Next(kvEntry **new_entry, kvWatcher *w, int64_t timeout);
8346
8358
8365NATS_EXTERN void
8367
// end of kvWatcher
8369
8383NATS_EXTERN const char*
8385
8392NATS_EXTERN uint64_t
8394
8401NATS_EXTERN int64_t
8403
8410NATS_EXTERN int64_t
8412
8419NATS_EXTERN int64_t
8421
8428NATS_EXTERN uint64_t
8430
8437NATS_EXTERN void
8439
// end of kvStatus
8441
// end of kvGroup
8443
8485
8502
8521
8538js_ObjectStore(objStore **new_obs, jsCtx *js, const char *bucket);
8539
8554
8563NATS_EXTERN void
8565
8580
8589NATS_EXTERN void
8591
8602js_DeleteObjectStore(jsCtx *js, const char *bucket);
8603
// end of obsGroupMgt
8605
8622
8647objStore_GetInfo(objStoreInfo **new_info, objStore *obs, const char *name, objStoreOptions *opts);
8648
8655NATS_EXTERN void
8657
8674objStore_UpdateMeta(objStore *obs, const char *name, objStoreMeta *meta);
8675
8689objStore_Delete(objStore *obs, const char *name);
8690
8710objStore_AddLink(objStoreInfo **new_info, objStore *obs, const char *name, objStoreInfo *obj);
8711
8732objStore_AddBucketLink(objStoreInfo **new_info, objStore *obs, const char *name, objStore *bucket);
8733
8742
8754
8781
8802objStoreWatcher_Next(objStoreInfo **new_info, objStoreWatcher *watcher, int64_t timeout);
8803
8817
8824NATS_EXTERN void
8826
8848
8857NATS_EXTERN void
8859
8874
8881NATS_EXTERN void
8883
8891NATS_EXTERN void
8893
// end of obsMgt
8895
8916
8977
8998objStorePut_Add(objStorePut *put, const void *data, int dataLen);
8999
9016objStorePut_Complete(objStoreInfo **new_info, objStorePut *put, int64_t timeout);
9017
9027NATS_EXTERN void
9029
9049objStore_PutString(objStoreInfo **new_info, objStore *obs, const char *name, const char *data);
9050
9071objStore_PutBytes(objStoreInfo **new_info, objStore *obs, const char *name, const void *data, int dataLen);
9072
9088objStore_PutFile(objStoreInfo **new_info, objStore *obs, const char *fileName);
9089
9201objStore_Get(objStoreGet **new_get, objStore *obs, const char *name, objStoreOptions *opts);
9202
9216
9239objStoreGet_Read(bool *done, void **new_data, int *dataLen, objStoreGet *get, int64_t timeout);
9240
9261objStoreGet_ReadAll(void **new_data, int *dataLen, objStoreGet *get, int64_t timeout);
9262
9269NATS_EXTERN void
9271
9310objStore_GetString(char **new_str, objStore *obs, const char *name, objStoreOptions *opts);
9311
9331objStore_GetBytes(void **new_data, int *dataLen, objStore *obs, const char *name, objStoreOptions *opts);
9332
9350objStore_GetFile(objStore *obs, const char *name, const char *fileName, objStoreOptions *opts);
9351
// end of obsGroup
9353
// end of funcGroup
9355
9356//
9357// Microservices.
9358//
9359
9402typedef struct micro_client_s microClient;
9403
9407typedef struct __for_forward_compatibility_only microClientConfig;
9408
9418typedef struct micro_endpoint_s microEndpoint;
9419
9428
9439
9449
9462typedef struct micro_error_s microError;
9463
9471typedef struct micro_group_s microGroup;
9472
9480
9486typedef struct micro_request_s microRequest;
9487
9499typedef struct micro_service_s microService;
9500
9511
9522
9530
9531
9534
// end of microTypes
9536
9555typedef microError *(*microRequestHandler)(microRequest *req);
9556
9580
9592typedef void (*microDoneHandler)(microService *m);
9593
// end of microCallbacks
9595
9607{
9613 const char *Name;
9614
9624 const char *Subject;
9625
9630 const char *QueueGroup;
9631
9637
9643
9648
9653 void *State;
9654};
9655
9660{
9664 const char *Name;
9665
9669 const char *Subject;
9670
9675 const char *QueueGroup;
9676
9682};
9683
9688{
9689 const char *Name;
9690 const char *Subject;
9691
9696 const char *QueueGroup;
9697
9702
9707 int64_t NumErrors;
9708
9713
9718
9723
9728};
9729
9734{
9736 const char *Prefix;
9737
9739 const char *QueueGroup;
9740
9743};
9744
9834
9841{
9845 const char *Type;
9846
9850 const char *Name;
9851
9855 const char *Version;
9856
9860 const char *Description;
9861
9865 const char *Id;
9866
9871
9876
9881};
9882
9887{
9891 const char *Type;
9892
9896 const char *Name;
9897
9901 const char *Version;
9902
9906 const char *Id;
9907
9911 int64_t Started;
9912
9917
9922};
9923
// end of microStructs
9925
9937#define MICRO_API_PREFIX "$SRV"
9938
9942#define MICRO_INFO_RESPONSE_TYPE "io.nats.micro.v1.info_response"
9943
9947#define MICRO_INFO_VERB "INFO"
9948
9952#define MICRO_PING_RESPONSE_TYPE "io.nats.micro.v1.ping_response"
9953
9957#define MICRO_PING_VERB "PING"
9958
9962#define MICRO_STATS_RESPONSE_TYPE "io.nats.micro.v1.stats_response"
9963
9967#define MICRO_STATS_VERB "STATS"
9968
9973#define MICRO_STATUS_HDR "Nats-Status"
9974
9979#define MICRO_ERROR_HDR "Nats-Service-Error"
9980
9985#define MICRO_ERROR_CODE_HDR "Nats-Service-Error-Code"
9986
// end of microConstants
9988
10020
10036
10053
10067
10078
10093
10103NATS_EXTERN void *
10105
10120
10129NATS_EXTERN bool
10131
10145
10164
// end of microServiceFunctions
10166
10189
10205
// end of microGroupFunctions
10207
10228microRequest_AddHeader(microRequest *req, const char *key, const char *value);
10229
10241
10252
10266NATS_EXTERN const char *
10268
10277NATS_EXTERN int
10279
10289NATS_EXTERN void *
10291
10309microRequest_GetHeaderKeys(microRequest *req, const char ***keys, int *count);
10310
10323microRequest_GetHeaderValue(microRequest *req, const char *key, const char **value);
10324
10341microRequest_GetHeaderValues(microRequest *req, const char *key, const char ***values, int *count);
10342
10351
10361NATS_EXTERN const char *
10363
10372
10381NATS_EXTERN void *
10383
10391NATS_EXTERN const char *
10393
10404microRequest_Respond(microRequest *req, const char *data, size_t len);
10405
10422
10467microRequest_RespondCustom(microRequest *req, microError *err, const char *data, size_t len);
10468
10483microRequest_SetHeader(microRequest *req, const char *key, const char *value);
10484
// end of microRequestFunctions
10486
10503micro_Errorf(const char *format, ...);
10504
10517micro_ErrorfCode(int code, const char *format, ...);
10518
10527
10534NATS_EXTERN int
10536
10541NATS_EXTERN void
10543
10544#define microError_Ignore(__err) microError_Destroy(__err)
10545
10555
10567NATS_EXTERN const char *
10568microError_String(microError *err, char *buf, size_t len);
10569
10584microError_Wrapf(microError *err, const char *format, ...);
10585
// end of microErrorFunctions
10587
10604
10610NATS_EXTERN void
10612
10626microClient_DoRequest(natsMsg **reply, microClient *client, const char *subject, const char *data, int data_len);
10627
// end of microClientFunctions
10629
10641NATS_EXTERN void
10643
10649NATS_EXTERN void
10651
// end of microCleanupFunctions
10653
// end of microFunctions
10655
// end of microGroup
10657
10694#ifdef __cplusplus
10695}
10696#endif
10697
10698#endif /* NATS_H_ */
void(* natsOnCompleteCB)(void *closure)
Callback used to notify that an object lifecycle is complete.
Definition nats.h:2247
natsStatus(* natsEvLoop_Attach)(void **userData, void *loop, natsConnection *nc, natsSock socket)
Attach this connection to the external event loop.
Definition nats.h:2128
natsStatus(* natsUserJWTHandler)(char **userJWT, char **customErrTxt, void *closure)
Callback used to fetch and return account signed user JWT.
Definition nats.h:2191
natsStatus(* natsEvLoop_WriteAddRemove)(void *userData, bool add)
Write event needs to be added or removed.
Definition nats.h:2156
int64_t(* natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure)
Callback used to specify how long to wait between reconnects.
Definition nats.h:2269
const char *(* natsTokenHandler)(void *closure)
Callback used to build a token on connections and reconnections.
Definition nats.h:2237
void(* jsPubAckHandler)(jsCtx *js, natsMsg *msg, jsPubAck *pa, jsPubAckErr *pae, void *closure)
Callback used to process asynchronous publish responses from JetStream.
Definition nats.h:2373
void(* jsPubAckErrHandler)(jsCtx *js, jsPubAckErr *pae, void *closure)
Callback used to process asynchronous publish errors from JetStream.
Definition nats.h:2330
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:2111
natsStatus(* natsEvLoop_Detach)(void *userData)
Detach from the event loop.
Definition nats.h:2167
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:2222
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:2405
int(* natsSSLVerifyCb)(int preverifyOk, void *ctx)
SSL certificate verification callback.
Definition nats.h:2294
void(* natsConnectionHandler)(natsConnection *nc, void *closure)
Callback used to notify the user of asynchronous connection events.
Definition nats.h:2088
void(* natsMsgHandler)(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition nats.h:2072
void(* stanPubAckHandler)(const char *guid, const char *error, void *closure)
Callback used to notify of an asynchronous publish result.
Definition nats.h:2385
natsStatus(* natsProxyConnHandler)(natsSock *fd, char *host, int port, void *closure)
Callback used to handle connections via proxy.
Definition nats.h:2102
natsStatus(* natsEvLoop_ReadAddRemove)(void *userData, bool add)
Read event needs to be added or removed.
Definition nats.h:2143
void(* stanMsgHandler)(stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition nats.h:2396
NATS_EXTERN int natsConnection_Buffered(natsConnection *nc)
Returns the number of bytes to be sent to the server.
NATS_EXTERN natsStatus natsConnection_ReadLastError(natsConnection *nc, char *buf, size_t n)
Read the last connection error into a user provided buffer.
NATS_EXTERN void natsConnection_Close(natsConnection *nc)
Closes the connection.
NATS_EXTERN natsStatus natsConnection_Flush(natsConnection *nc)
Flushes the connection.
NATS_EXTERN bool natsConnection_IsDraining(natsConnection *nc)
Test if connection is draining.
NATS_EXTERN natsStatus natsConnection_Reconnect(natsConnection *nc)
Drops the current connection, reconnects including re-subscribing.
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.
NATS_EXTERN natsStatus natsConnection_FlushTimeout(natsConnection *nc, int64_t timeout)
Flushes the connection with a given timeout.
NATS_EXTERN void natsConnection_ProcessDetachedEvent(natsConnection *nc)
Process a detach event when using external event loop.
NATS_EXTERN void natsConnection_ProcessCloseEvent(natsSock *socket)
Process a socket close event when using external event loop.
NATS_EXTERN natsStatus natsConnection_GetLocalIPAndPort(natsConnection *nc, char **ip, int *port)
Returns the connection local IP and port.
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 natsHeader_Delete(natsHeader *h, const char *key)
Delete the value(s) associated with key.
NATS_EXTERN natsStatus natsHeader_Keys(natsHeader *h, const char ***keys, int *count)
Get all header keys.
NATS_EXTERN natsStatus natsHeader_New(natsHeader **new_header)
Creates an header object.
NATS_EXTERN void natsHeader_Destroy(natsHeader *h)
Destroys the natsHeader object.
NATS_EXTERN natsStatus natsHeader_Add(natsHeader *h, const char *key, const char *value)
Add value to the header associated with key.
NATS_EXTERN natsStatus natsHeader_Get(natsHeader *h, const char *key, const char **value)
Get the header entry associated with key.
NATS_EXTERN natsStatus natsHeader_Set(natsHeader *h, const char *key, const char *value)
Set the header entries associated with key to the single element value.
NATS_EXTERN natsStatus natsHeader_Values(natsHeader *h, const char *key, const char ***values, int *count)
Get all header values associated with key.
NATS_EXTERN int natsHeader_KeysCount(natsHeader *h)
Returns the number of keys.
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 void jsConsumerNamesList_Destroy(jsConsumerNamesList *list)
Destroys the consumer names list object.
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 jsRePublish_Init(jsRePublish *rp)
Initializes a republish structure.
NATS_EXTERN void jsStreamInfoList_Destroy(jsStreamInfoList *list)
Destroys the stream information list object.
NATS_EXTERN natsStatus js_DeleteStream(jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Deletes a stream.
NATS_EXTERN void jsConsumerInfoList_Destroy(jsConsumerInfoList *list)
Destroys the consumer information list object.
NATS_EXTERN natsStatus js_DeleteConsumer(jsCtx *js, const char *stream, const char *consumer, jsOptions *opts, jsErrCode *errCode)
Deletes a consumer.
NATS_EXTERN natsStatus js_Streams(jsStreamInfoList **list, jsCtx *js, jsOptions *opts, jsErrCode *errCode)
Retrieves the list of all available streams.
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_DirectGetMsg(natsMsg **msg, jsCtx *js, const char *stream, jsOptions *opts, jsDirectGetMsgOptions *dgOpts)
Retrieves directly a JetStream message based on provided options.
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_ConsumerNames(jsConsumerNamesList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Retrieves the list of all available consumer names for a stream.
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 jsConsumerPauseResponse_Destroy(jsConsumerPauseResponse *cpr)
Destroys the PauseConsumer response object.
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 natsStatus jsDirectGetMsgOptions_Init(jsDirectGetMsgOptions *opts)
Initializes a direct get message options 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 js_PauseConsumer(jsConsumerPauseResponse **new_cpr, jsCtx *js, const char *stream, const char *consumer, uint64_t pauseUntil, jsOptions *opts, jsErrCode *errCode)
Pauses a consumer.
NATS_EXTERN natsStatus jsStreamConfig_Init(jsStreamConfig *cfg)
Initializes a streaming configuration structure.
NATS_EXTERN natsStatus js_StreamNames(jsStreamNamesList **list, jsCtx *js, jsOptions *opts, jsErrCode *errCode)
Retrieves the list of all available stream names.
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_UpdateConsumer(jsConsumerInfo **ci, jsCtx *js, const char *stream, jsConsumerConfig *cfg, jsOptions *opts, jsErrCode *errCode)
Updates a JetStream consumer.
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_Consumers(jsConsumerInfoList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode)
Retrieves the list of all available consumers for a 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 void jsStreamNamesList_Destroy(jsStreamNamesList *list)
Destroys the stream names list object.
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_NakWithDelay(natsMsg *msg, int64_t delay, jsOptions *opts)
Negatively acknowledges a 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 jsFetchRequest_Init(jsFetchRequest *request)
Initializes a fetch request options structure.
NATS_EXTERN natsStatus jsSubOptions_Init(jsSubOptions *opts)
Initializes a subscribe options structure.
NATS_EXTERN natsStatus js_UnpinConsumer(jsCtx *js, const char *stream, const char *consumer, const char *group, jsOptions *opts, jsErrCode *errCode)
Un-pins a consumer priority group from a specific subscription.
NATS_EXTERN natsStatus natsSubscription_FetchRequest(natsMsgList *list, natsSubscription *sub, jsFetchRequest *request)
Fetches messages for a pull subscription with a complete request configuration.
NATS_EXTERN natsStatus js_PullSubscribeAsync(natsSubscription **newsub, jsCtx *js, const char *subject, const char *durable, natsMsgHandler msgCB, void *msgCBClosure, jsOptions *jsOpts, jsSubOptions *opts, jsErrCode *errCode)
Starts a Pull based JetStream subscription, and delivers messages to a user callback asynchronously.
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 natsSubscription_GetConsumerInfo(jsConsumerInfo **ci, natsSubscription *sub, jsOptions *opts, jsErrCode *errCode)
Returns the jsConsumerInfo associated with this 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 js_SubscribeSyncMulti(natsSubscription **sub, jsCtx *js, const char **subjects, int numSubjects, jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode)
Create an asynchronous subscription to multiple subjects.
NATS_EXTERN natsStatus js_SubscribeMulti(natsSubscription **sub, jsCtx *js, const char **subjects, int numSubjects, natsMsgHandler cb, void *cbClosure, jsOptions *opts, jsSubOptions *subOpts, jsErrCode *errCode)
Create an asynchronous subscription to multiple subjects.
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 kvPurgeOptions_Init(kvPurgeOptions *opts)
Initializes a KeyValue purge options structure.
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_PurgeDeletes(kvStore *kv, kvPurgeOptions *opts)
Purge and removes delete markers.
NATS_EXTERN natsStatus kvStore_Purge(kvStore *kv, const char *key, kvPurgeOptions *opts)
Deletes a key by placing a purge marker and removing all revisions.
NATS_EXTERN natsStatus kvStore_WatchMulti(kvWatcher **new_watcher, kvStore *kv, const char **keys, int numKeys, kvWatchOptions *opts)
Returns a watcher for any updates to keys that match one of 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_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_GetRevision(kvEntry **new_entry, kvStore *kv, const char *key, uint64_t revision)
Returns the entry at the specific revision for the key.
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 natsStatus kvStore_KeysWithFilters(kvKeysList *list, kvStore *kv, const char **filters, int numFilters, kvWatchOptions *opts)
Returns all keys in the bucket which matches the list of subject like filters.
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 uint64_t kvStatus_Bytes(kvStatus *sts)
Returns the size (in bytes) of this bucket.
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 int64_t nats_NowMonotonicInNanoSeconds(void)
Gives the current time in nanoseconds using monotonic timer.
NATS_EXTERN natsStatus nats_SetMessageDeliveryPoolSize(int max)
Sets the maximum size of the global message delivery thread pool.
NATS_EXTERN natsStatus nats_OpenWithConfig(natsClientConfig *config)
Initializes the library.
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.
void(* microErrorHandler)(microService *m, microEndpoint *ep, natsStatus s)
Callback type for async error notifications.
Definition nats.h:9579
microError *(* microRequestHandler)(microRequest *req)
Callback type for request processing.
Definition nats.h:9555
void(* microDoneHandler)(microService *m)
Callback type for Done (service stopped) notifications.
Definition nats.h:9592
NATS_EXTERN void microServiceInfo_Destroy(microServiceInfo *info)
Destroys a microServiceInfo object.
NATS_EXTERN void microServiceStats_Destroy(microServiceStats *stats)
Destroys a microServiceStats object.
NATS_EXTERN microError * micro_NewClient(microClient **new_client, natsConnection *nc, microClientConfig *cfg)
Creates a new microservice client.
NATS_EXTERN void microClient_Destroy(microClient *client)
Destroys a microservice client.
NATS_EXTERN microError * microClient_DoRequest(natsMsg **reply, microClient *client, const char *subject, const char *data, int data_len)
Sends a request to a microservice and receives the response.
NATS_EXTERN void microError_Destroy(microError *err)
destroys a microError.
NATS_EXTERN natsStatus microError_Status(microError *err)
Returns the NATS status associated with the error.
NATS_EXTERN int microError_Code(microError *err)
returns the int code of the error.
NATS_EXTERN microError * micro_Errorf(const char *format,...)
creates a new microError, with a printf-like formatted message.
NATS_EXTERN microError * micro_ErrorfCode(int code, const char *format,...)
creates a new microError, with a code and a printf-like formatted message.
NATS_EXTERN const char * microError_String(microError *err, char *buf, size_t len)
Returns a printable string with the error message.
NATS_EXTERN microError * micro_ErrorFromStatus(natsStatus s)
Wraps a NATS status into a microError, if not a NATS_OK.
NATS_EXTERN microError * microError_Wrapf(microError *err, const char *format,...)
Wraps an exising microError with a higher printf-like formatted message.
NATS_EXTERN microError * microGroup_AddEndpoint(microGroup *g, microEndpointConfig *config)
Adds an endpoint to a microGroup and starts listening for messages.
NATS_EXTERN microError * microGroup_AddGroup(microGroup **new_group, microGroup *parent, microGroupConfig *config)
Adds a sub-group to microGroup.
NATS_EXTERN microService * microRequest_GetService(microRequest *req)
Returns the pointer to the microservice associated with the request.
NATS_EXTERN int microRequest_GetDataLength(microRequest *req)
Returns the number of data bytes in the the request.
NATS_EXTERN microError * microRequest_RespondError(microRequest *req, microError *err)
Respond to a request with a simple error.
NATS_EXTERN const char * microRequest_GetSubject(microRequest *req)
Returns the subject of the request message.
NATS_EXTERN const char * microRequest_GetData(microRequest *req)
Returns the data in the the request, as a byte array.
NATS_EXTERN microError * microRequest_AddHeader(microRequest *req, const char *key, const char *value)
Adds a header to the underlying NATS request message.
NATS_EXTERN natsConnection * microRequest_GetConnection(microRequest *req)
Returns the connection associated with the request.
NATS_EXTERN natsMsg * microRequest_GetMsg(microRequest *req)
Get the NATS message underlying the request.
NATS_EXTERN void * microRequest_GetServiceState(microRequest *req)
Returns the pointer to the user-provided service state.
NATS_EXTERN microError * microRequest_Respond(microRequest *req, const char *data, size_t len)
Respond to a request, on the same NATS connection.
NATS_EXTERN microError * microRequest_GetHeaderKeys(microRequest *req, const char ***keys, int *count)
Gets the list of all header keys in the NATS message underlying the request.
NATS_EXTERN microError * microRequest_SetHeader(microRequest *req, const char *key, const char *value)
Add value to the header associated with key in the NATS message underlying the request.
NATS_EXTERN void * microRequest_GetEndpointState(microRequest *req)
Returns the pointer to the user-provided endpoint state, if the request is associated with an endpoin...
NATS_EXTERN microError * microRequest_GetHeaderValue(microRequest *req, const char *key, const char **value)
Get the header entry associated with key from the NATS message underlying the request.
NATS_EXTERN microError * microRequest_DeleteHeader(microRequest *req, const char *key)
Deletes a header from the underlying NATS request message.
NATS_EXTERN microError * microRequest_GetHeaderValues(microRequest *req, const char *key, const char ***values, int *count)
Get all header values associated with key from the NATS message underlying the request.
NATS_EXTERN microError * microRequest_RespondCustom(microRequest *req, microError *err, const char *data, size_t len)
Respond to a message, with an OK or an error.
NATS_EXTERN const char * microRequest_GetReply(microRequest *req)
Returns the reply subject set in this message.
NATS_EXTERN microError * microService_GetStats(microServiceStats **new_stats, microService *m)
Returns run-time statistics for a microservice.
NATS_EXTERN natsConnection * microService_GetConnection(microService *m)
Returns the connection associated with the service. If the service was successfully started,...
NATS_EXTERN microError * microService_AddGroup(microGroup **new_group, microService *m, microGroupConfig *config)
Adds an group (prefix) to a microservice.
NATS_EXTERN microError * micro_AddService(microService **new_microservice, natsConnection *nc, microServiceConfig *config)
Creates and starts a new microservice.
NATS_EXTERN microError * microService_Destroy(microService *m)
Destroys a microservice, stopping it first if needed.
NATS_EXTERN microError * microService_Stop(microService *m)
Stops a running microservice.
NATS_EXTERN bool microService_IsStopped(microService *m)
Checks if the service is stopped.
NATS_EXTERN microError * microService_AddEndpoint(microService *m, microEndpointConfig *config)
Adds an endpoint to a microservice and starts listening for messages.
NATS_EXTERN microError * microService_GetInfo(microServiceInfo **new_info, microService *m)
Returns a microServiceInfo for a microservice.
NATS_EXTERN microError * microService_Run(microService *m)
Waits for a microservice to stop.
NATS_EXTERN void * microService_GetState(microService *m)
Returns the pointer to state data (closure). It is originally provided in microServiceConfig....
struct micro_client_s microClient
The Microservice client.
Definition nats.h:9402
struct micro_group_s microGroup
a collection of endpoints and other groups, with a common prefix to their subjects and names.
Definition nats.h:9471
struct micro_request_s microRequest
a request received by a microservice endpoint.
Definition nats.h:9486
struct micro_error_s microError
the Microservice error object.
Definition nats.h:9462
struct __for_forward_compatibility_only microClientConfig
The Microservice configuration object. For forward compatibility only.
Definition nats.h:9407
NATS_EXTERN microError * micro_ErrorInvalidArg
NATS_EXTERN microError * micro_ErrorOutOfMemory
struct micro_endpoint_s microEndpoint
microEndpoint represents a microservice endpoint.
Definition nats.h:9418
struct micro_service_s microService
the main object for a configured microservice.
Definition nats.h:9499
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 objStorePut_Add(objStorePut *put, const void *data, int dataLen)
Add data to the object.
NATS_EXTERN void objStoreGet_Destroy(objStoreGet *get)
Destroys the object store's get object.
NATS_EXTERN natsStatus objStoreGet_ReadAll(void **new_data, int *dataLen, objStoreGet *get, int64_t timeout)
Returns the remaining bytes of the pulled object.
NATS_EXTERN natsStatus objStore_PutFile(objStoreInfo **new_info, objStore *obs, const char *fileName)
Put the content of a file into this object.
NATS_EXTERN natsStatus objStore_Put(objStorePut **new_put, objStore *obs, objStoreMeta *meta)
Initiates a session to put bytes into an object.
NATS_EXTERN natsStatus objStoreMeta_Init(objStoreMeta *meta)
Initializes an object store meta structure.
NATS_EXTERN natsStatus objStoreGet_Read(bool *done, void **new_data, int *dataLen, objStoreGet *get, int64_t timeout)
Returns some bytes of the pulled object.
NATS_EXTERN natsStatus objStorePut_Complete(objStoreInfo **new_info, objStorePut *put, int64_t timeout)
Complete a put operation.
NATS_EXTERN natsStatus objStore_GetString(char **new_str, objStore *obs, const char *name, objStoreOptions *opts)
Pull the named object from the object store and return it as a string.
NATS_EXTERN natsStatus objStore_GetFile(objStore *obs, const char *name, const char *fileName, objStoreOptions *opts)
Pull the named object from the object store and place it into a file.
NATS_EXTERN natsStatus objStore_Get(objStoreGet **new_get, objStore *obs, const char *name, objStoreOptions *opts)
Pull the named object from the object store.
NATS_EXTERN natsStatus objStore_PutBytes(objStoreInfo **new_info, objStore *obs, const char *name, const void *data, int dataLen)
Put bytes into this object.
NATS_EXTERN natsStatus objStore_PutString(objStoreInfo **new_info, objStore *obs, const char *name, const char *data)
Put a string into this object.
NATS_EXTERN void objStorePut_Destroy(objStorePut *put)
Destroys the object store's put object.
NATS_EXTERN natsStatus objStoreGet_Info(const objStoreInfo **new_info, objStoreGet *get)
Returns a handle to the information object own by the objStoreGet object.
NATS_EXTERN natsStatus objStore_GetBytes(void **new_data, int *dataLen, objStore *obs, const char *name, objStoreOptions *opts)
Pull the named object from the object store and return it as a byte array.
NATS_EXTERN natsStatus js_ObjectStoreNames(objStoreNamesList **new_list, jsCtx *js)
Retrieves a list of bucket names.
NATS_EXTERN natsStatus js_DeleteObjectStore(jsCtx *js, const char *bucket)
Deletes an object store.
NATS_EXTERN natsStatus objStoreConfig_Init(objStoreConfig *cfg)
Initializes an Object Store configuration structure.
NATS_EXTERN natsStatus js_ObjectStoreStatuses(objStoreStatusesList **new_list, jsCtx *js)
Retrieves a list of bucket statuses.
NATS_EXTERN natsStatus js_CreateObjectStore(objStore **new_obs, jsCtx *js, objStoreConfig *cfg)
Creates an object store with a given configuration.
NATS_EXTERN void objStoreStatusesList_Destroy(objStoreStatusesList *list)
Destroys the object store statuses list object.
NATS_EXTERN void objStoreNamesList_Destroy(objStoreNamesList *list)
Destroys the object store names list object.
NATS_EXTERN natsStatus js_UpdateObjectStore(objStore **new_obs, jsCtx *js, objStoreConfig *cfg)
Updates an object store with a given configuration.
NATS_EXTERN natsStatus js_ObjectStore(objStore **new_obs, jsCtx *js, const char *bucket)
Looks-up and binds to an existing object store.
NATS_EXTERN void objStoreInfo_Destroy(objStoreInfo *info)
Destroys the ObjectStore information object.
NATS_EXTERN natsStatus objStoreWatchOptions_Init(objStoreWatchOptions *opts)
Initializes the object store watcher options object.
NATS_EXTERN void objStoreWatcher_Destroy(objStoreWatcher *watcher)
Destroys the object store's watcher object.
NATS_EXTERN natsStatus objStore_Status(objStoreStatus **new_status, objStore *obs)
Retreive the status and configuration of the bucket.
NATS_EXTERN void objStore_Destroy(objStore *obs)
Destroys an object store object.
NATS_EXTERN natsStatus objStore_AddBucketLink(objStoreInfo **new_info, objStore *obs, const char *name, objStore *bucket)
Adds a link to another object store.
NATS_EXTERN natsStatus objStoreOptions_Init(objStoreOptions *opts)
Initializes an Object Store options structure.
NATS_EXTERN natsStatus objStore_GetInfo(objStoreInfo **new_info, objStore *obs, const char *name, objStoreOptions *opts)
Retrieves the current information for the object.
NATS_EXTERN natsStatus objStore_AddLink(objStoreInfo **new_info, objStore *obs, const char *name, objStoreInfo *obj)
Adds a link to another object.
NATS_EXTERN natsStatus objStoreWatcher_Stop(objStoreWatcher *watcher)
Stops the object store watcher.
NATS_EXTERN void objStoreStatus_Destroy(objStoreStatus *status)
Destroys the object store status object.
NATS_EXTERN natsStatus objStore_Delete(objStore *obs, const char *name)
Deletes the named object from the object store.
NATS_EXTERN natsStatus objStore_UpdateMeta(objStore *obs, const char *name, objStoreMeta *meta)
Updates the metadata for the object.
NATS_EXTERN natsStatus objStore_Watch(objStoreWatcher **new_watcher, objStore *obs, objStoreWatchOptions *opts)
Watches for updates to objects in the store.
NATS_EXTERN natsStatus objStoreWatcher_Next(objStoreInfo **new_info, objStoreWatcher *watcher, int64_t timeout)
Returns the next object store information for this object store watcher.
NATS_EXTERN void objStoreInfoList_Destroy(objStoreInfoList *list)
Destroys the list of object informations.
NATS_EXTERN natsStatus objStore_Seal(objStore *obs)
Seals the object store.
NATS_EXTERN natsStatus objStore_List(objStoreInfoList **new_list, objStore *obs, objStoreOptions *opts)
Lists information about objects in the object store.
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_SetSSLVerificationCallback(natsOptions *opts, natsSSLVerifyCb callback)
EXPERIMENTAL Sets the certificate validation callback.
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_SetMessageBufferPadding(natsOptions *opts, int paddingSize)
Sets a custom padding when allocating buffer for incoming messages.
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_SetUserCredentialsFromMemory(natsOptions *opts, const char *jwtAndSeedContent)
Sets JWT handler and handler to sign nonce that uses seed.
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_AllowConcurrentTLSHandshakes(natsOptions *opts)
Allows concurrent TLS handshakes.
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_SetMaxPendingBytes(natsOptions *opts, int64_t maxPending)
Sets the maximum number of pending bytes per subscription.
NATS_EXTERN natsStatus natsOptions_IPResolutionOrder(natsOptions *opts, int order)
Dictates the order in which host name are resolved during connect.
NATS_EXTERN natsStatus natsOptions_SetIgnoreDiscoveredServers(natsOptions *opts, bool ignore)
Sets if the library should ignore or not discovered servers.
NATS_EXTERN natsStatus natsOptions_LoadCATrustedCertificatesPath(natsOptions *opts, const char *path)
Loads the trusted CA certificates from a directory.
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_LoadCertificatesChainDynamic(natsOptions *opts, const char *certsFileName, const char *keyFileName)
Loads the certificate chain and key from a file on every connection attempt.
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_SetCustomInboxPrefix(natsOptions *opts, const char *inboxPrefix)
Sets a custom inbox prefix.
NATS_EXTERN natsStatus natsOptions_TLSHandshakeFirst(natsOptions *opts)
Performs TLS handshake first.
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_SetProxyConnHandler(natsOptions *opts, natsProxyConnHandler proxyConnHandler, void *closure)
Sets the proxy connection handler.
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 int64_t natsSubscription_GetID(natsSubscription *sub)
Gets the subscription id.
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 const char * natsSubscription_GetSubject(natsSubscription *sub)
Gets the subject name.
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 __objStorePut objStorePut
Definition nats.h:1612
struct __stanSubOptions stanSubOptions
Way to configure a stanSubscription.
Definition nats.h:2041
struct __kvStore kvStore
Definition nats.h:1459
struct __objStore objStore
Definition nats.h:1598
jsStorageCompression
Definition nats.h:336
jsDeliverPolicy
Definition nats.h:345
struct __stanConnOptions stanConnOptions
Way to configure a stanConnection.
Definition nats.h:2035
jsStorageType
Definition nats.h:326
char natsInbox
Unique subject often used for point-to-point communication.
Definition nats.h:187
struct __stanMsg stanMsg
The Streaming message.
Definition nats.h:2029
jsRetentionPolicy
Definition nats.h:305
struct __kvWatcher kvWatcher
Definition nats.h:1474
struct __natsStatistics natsStatistics
Statistics of a natsConnection.
Definition nats.h:159
bool(* jsFetchNextHandler)(int *messages, int64_t *maxBytes, natsSubscription *sub, void *closure)
Callback used to customize flow control for js_PullSubscribeAsync.
Definition nats.h:1297
jsDiscardPolicy
Definition nats.h:316
jsReplayPolicy
Definition nats.h:371
struct __natsSubscription natsSubscription
Interest on a given subject.
Definition nats.h:165
kvOperation
Definition nats.h:1480
jsAckPolicy
Definition nats.h:359
struct __stanConnection stanConnection
A connection to a NATS Streaming Server.
Definition nats.h:2017
void(* jsFetchCompleteHandler)(natsConnection *nc, natsSubscription *sub, natsStatus s, void *closure)
Callback used to indicate that the work of js_PullSubscribeAsync is done.
Definition nats.h:1285
struct __jsCtx jsCtx
Definition nats.h:271
struct __natsOptions natsOptions
Way to configure a natsConnection.
Definition nats.h:178
struct __natsHeader natsHeader
Map with key being a string and value being an array of strings.
Definition nats.h:193
struct __objStoreGet objStoreGet
Definition nats.h:1619
struct __natsClientConfig natsClientConfig
An initial configuration for NATS client. Provides control over the threading model,...
struct __kvStatus kvStatus
Definition nats.h:1469
struct __kvEntry kvEntry
Definition nats.h:1464
struct __natsMsg natsMsg
A structure holding a subject, optional reply and payload.
Definition nats.h:172
struct __objStoreWatcher objStoreWatcher
Definition nats.h:1624
struct __stanSubscription stanSubscription
Interest on a given channel.
Definition nats.h:2023
struct __natsConnection natsConnection
A connection to a NATS Server.
Definition nats.h:152
@ js_StorageCompressionNone
Specifies no compression. It's the default.
Definition nats.h:337
@ js_StorageCompressionS2
Specifies S2.
Definition nats.h:338
@ js_DeliverByStartSequence
Starts from a given sequence.
Definition nats.h:349
@ js_DeliverByStartTime
Starts from a given UTC time (number of nanoseconds since epoch)
Definition nats.h:350
@ js_DeliverNew
Starts with messages sent after the consumer is created.
Definition nats.h:348
@ js_DeliverLastPerSubject
Starts with the last message for all subjects received.
Definition nats.h:351
@ js_DeliverLast
Starts with the last sequence received.
Definition nats.h:347
@ js_DeliverAll
Starts from the very beginning of a stream. This is the default.
Definition nats.h:346
@ js_FileStorage
Specifies on disk storage. It's the default.
Definition nats.h:327
@ js_MemoryStorage
Specifies in memory only.
Definition nats.h:328
@ js_LimitsPolicy
Specifies that messages are retained until any given limit is reached, which could be one of MaxMsgs,...
Definition nats.h:306
@ js_InterestPolicy
Specifies that when all known observables have acknowledged a message it can be removed.
Definition nats.h:307
@ js_WorkQueuePolicy
Specifies that when the first worker or subscriber acknowledges the message it can be removed.
Definition nats.h:308
@ js_DiscardNew
Will fail to store new messages.
Definition nats.h:318
@ js_DiscardOld
Will remove older messages to return to the limits. This is the default.
Definition nats.h:317
@ js_ReplayInstant
Replays messages as fast as possible.
Definition nats.h:372
@ js_ReplayOriginal
Maintains the same timing as the messages were received.
Definition nats.h:373
@ kvOp_Unknown
Definition nats.h:1481
@ kvOp_Delete
Definition nats.h:1483
@ kvOp_Put
Definition nats.h:1482
@ kvOp_Purge
Definition nats.h:1484
@ js_AckExplicit
Requires ack or nack for all messages.
Definition nats.h:360
@ js_AckAll
When acking a sequence number, this implicitly acks all sequences below this one as well.
Definition nats.h:362
@ js_AckNone
Requires no acks for delivered messages.
Definition nats.h:361
#define NATS_EXTERN
Needed for shared library.
Definition nats.h:49
int natsSock
Definition nats.h:50
jsErrCode
Definition status.h:143
natsStatus
Status returned by most of the APIs.
Definition status.h:50
natsConnStatus
The connection state.
Definition status.h:24
An initial configuration for NATS client. Provides control over the threading model,...
Definition nats.h:201
bool DefaultRepliesToThreadPool
Definition nats.h:211
bool UseSeparatePoolForReplies
Definition nats.h:212
int ReplyThreadPoolMax
Definition nats.h:213
int ThreadPoolMax
Definition nats.h:208
int64_t DefaultWriteDeadline
Definition nats.h:202
bool DefaultToThreadPool
Definition nats.h:207
int64_t LockSpinCount
Definition nats.h:204
Definition nats.h:1125
uint64_t Total
Definition nats.h:1126
uint64_t Errors
Definition nats.h:1127
Definition nats.h:1162
int64_t Consumers
Definition nats.h:1166
int64_t Streams
Definition nats.h:1165
int TiersLen
Definition nats.h:1171
uint64_t Memory
Definition nats.h:1163
jsAPIStats API
Definition nats.h:1168
jsAccountLimits Limits
Definition nats.h:1169
jsTier ** Tiers
Definition nats.h:1170
char * Domain
Definition nats.h:1167
uint64_t Store
Definition nats.h:1164
Definition nats.h:1135
int64_t MemoryMaxStreamBytes
Definition nats.h:1141
int64_t MaxStreams
Definition nats.h:1138
int64_t MaxAckPending
Definition nats.h:1140
int64_t MaxConsumers
Definition nats.h:1139
int64_t MaxStore
Definition nats.h:1137
int64_t MaxMemory
Definition nats.h:1136
bool MaxBytesRequired
Definition nats.h:1143
int64_t StoreMaxStreamBytes
Definition nats.h:1142
Definition nats.h:728
int ReplicasLen
Definition nats.h:732
char * Name
Definition nats.h:729
jsPeerInfo ** Replicas
Definition nats.h:731
char * Leader
Definition nats.h:730
Definition nats.h:854
int PriorityGroupsLen
Definition nats.h:919
bool MemoryStorage
Definition nats.h:891
const char * PriorityPolicy
Represents he priority policy the consumer is set to. Must be "pinned_client" or "overflow"....
Definition nats.h:909
const char * Name
Definition nats.h:855
int FilterSubjectsLen
Definition nats.h:896
uint64_t OptStartSeq
Definition nats.h:859
bool HeadersOnly
Definition nats.h:874
uint64_t RateLimit
Definition nats.h:868
jsDeliverPolicy DeliverPolicy
Definition nats.h:858
const char * Description
Definition nats.h:857
const char * Durable
Definition nats.h:856
const char * SampleFrequency
Definition nats.h:869
bool FlowControl
Definition nats.h:872
int64_t MaxRequestBatch
Maximum Pull Consumer request batch size.
Definition nats.h:877
int64_t AckWait
Definition nats.h:862
int64_t MaxRequestMaxBytes
Maximum Pull Consumer request maximum bytes.
Definition nats.h:879
int64_t OptStartTime
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:860
int64_t MaxWaiting
Definition nats.h:870
jsAckPolicy AckPolicy
Definition nats.h:861
natsMetadata Metadata
User-provided metadata for the consumer, encoded as an array of {"key", "value",.....
Definition nats.h:897
const char * DeliverSubject
Definition nats.h:882
const char ** PriorityGroups
The list of priority groups this consumer supports.
Definition nats.h:918
int64_t PinnedTTL
PinnedTTL represents the time after which the client will be unpinned if no new pull requests are sen...
Definition nats.h:915
int64_t * BackOff
Redelivery durations expressed in nanoseconds.
Definition nats.h:864
int64_t MaxRequestExpires
Maximum Pull Consumer request expiration, expressed in number of nanoseconds.
Definition nats.h:878
int64_t Heartbeat
Heartbeat interval expressed in number of nanoseconds.
Definition nats.h:873
int64_t PauseUntil
Suspends the consumer until this deadline, represented as number of nanoseconds since epoch....
Definition nats.h:904
int64_t Replicas
Definition nats.h:889
int BackOffLen
Definition nats.h:865
int64_t MaxDeliver
Definition nats.h:863
const char ** FilterSubjects
Multiple filter subjects.
Definition nats.h:895
jsReplayPolicy ReplayPolicy
Definition nats.h:867
const char * DeliverGroup
Definition nats.h:883
int64_t MaxAckPending
Definition nats.h:871
const char * FilterSubject
Definition nats.h:866
int64_t InactiveThreshold
How long the server keeps an ephemeral after detecting loss of interest, expressed in number of nanos...
Definition nats.h:886
Definition nats.h:1062
bool Paused
Definition nats.h:1075
jsSequenceInfo Delivered
Definition nats.h:1067
jsPriorityGroupState * PriorityGroups
Priority groups for the (pull) consumer.
Definition nats.h:1077
jsConsumerConfig * Config
Definition nats.h:1066
bool PushBound
Definition nats.h:1074
int64_t NumWaiting
Definition nats.h:1071
int PriorityGroupsLen
Number of priority groups.
Definition nats.h:1078
int64_t Created
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:1065
jsClusterInfo * Cluster
Definition nats.h:1073
int64_t PauseRemaining
Remaining time in nanoseconds.
Definition nats.h:1076
int64_t NumAckPending
Definition nats.h:1069
char * Stream
Definition nats.h:1063
int64_t NumRedelivered
Definition nats.h:1070
char * Name
Definition nats.h:1064
jsSequenceInfo AckFloor
Definition nats.h:1068
uint64_t NumPending
Definition nats.h:1072
Definition nats.h:1089
jsConsumerInfo ** List
Definition nats.h:1090
int Count
Definition nats.h:1091
Definition nats.h:1103
int Count
Definition nats.h:1105
char ** List
Definition nats.h:1104
Definition nats.h:1115
int64_t PauseRemaining
Remaining time in nanoseconds.
Definition nats.h:1118
bool Paused
Definition nats.h:1116
int64_t PauseUntil
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:1117
Definition nats.h:940
uint64_t Stream
This is the stream sequence that the application should resume from.
Definition nats.h:941
uint64_t ConsumerServer
This is the consumer sequence last sent by the server.
Definition nats.h:943
uint64_t ConsumerClient
This is the consumer sequence that was last received by the library.
Definition nats.h:942
Definition nats.h:1235
const char * NextBySubject
Get the next message (based on sequence) for that subject.
Definition nats.h:1237
uint64_t Sequence
Get the message at this sequence.
Definition nats.h:1236
const char * LastBySubject
Get the last message on that subject.
Definition nats.h:1238
Definition nats.h:407
const char * DeliverPrefix
Definition nats.h:409
const char * APIPrefix
Definition nats.h:408
Definition nats.h:1248
const char * ID
Definition nats.h:1258
const char * Group
Definition nats.h:1260
int64_t MaxBytes
Maximum bytes for the request (request complete based on whichever Batch or MaxBytes comes first)
Definition nats.h:1251
int64_t MinPending
Definition nats.h:1256
int Batch
Maximum number of messages to be received (see MaxBytes)
Definition nats.h:1250
int64_t MinAckPending
Definition nats.h:1257
int64_t Expires
Expiration of the request, expressed in nanoseconds.
Definition nats.h:1249
bool NoWait
Will not wait if the request cannot be completed.
Definition nats.h:1252
int64_t Heartbeat
Have server sends heartbeats to help detect communication failures.
Definition nats.h:1253
Definition nats.h:630
uint64_t * Msgs
Definition nats.h:631
uint64_t Bytes
Definition nats.h:633
int MsgsLen
Definition nats.h:632
Definition nats.h:1183
uint64_t NumPending
Definition nats.h:1186
jsSequencePair Sequence
Definition nats.h:1184
char * Stream
Definition nats.h:1188
char * Domain
Definition nats.h:1190
char * Consumer
Definition nats.h:1189
uint64_t NumDelivered
Definition nats.h:1185
int64_t Timestamp
Definition nats.h:1187
Definition nats.h:1446
jsOptionsPullSubscribeAsync PullSubscribeAsync
extra options for js_PullSubscribeAsync
Definition nats.h:1451
int64_t Wait
Amount of time (in milliseconds) to wait for various JetStream API requests, default is 5000 ms (5 se...
Definition nats.h:1449
jsOptionsPublishAsync PublishAsync
extra options for js_PublishAsync
Definition nats.h:1450
const char * Prefix
JetStream prefix, default is "$JS.API".
Definition nats.h:1447
jsOptionsStream Stream
Optional stream options.
Definition nats.h:1452
const char * Domain
Domain changes the domain part of JetSteam API prefix.
Definition nats.h:1448
Definition nats.h:1378
int64_t MaxPending
Maximum outstanding asynchronous publishes that can be inflight at one time.
Definition nats.h:1379
void * AckHandlerClosure
Closure (or user data) passed to jsPubAckHandler callback.
Definition nats.h:1387
jsPubAckHandler AckHandler
Callback invoked for each asynchronous published message.
Definition nats.h:1386
jsPubAckErrHandler ErrHandler
Callback invoked when error encountered publishing a given message.
Definition nats.h:1393
void * ErrHandlerClosure
Closure (or user data) passed to jsPubAckErrHandler callback.
Definition nats.h:1394
int64_t StallWait
Amount of time (in milliseconds) to wait in a PublishAsync call when there is MaxPending inflight mes...
Definition nats.h:1396
Definition nats.h:1305
int64_t MaxBytes
Auto-unsubscribe after receiving this many bytes.
Definition nats.h:1308
int FetchSize
When using the automatic Fetch flow control (default NextHandler), this is the number of messages to ...
Definition nats.h:1352
void * NextHandlerClosure
Definition nats.h:1368
int MaxMessages
Auto-unsubscribed after receiving this many messages.
Definition nats.h:1307
int64_t Timeout
Auto-unsubsribe after this many milliseconds.
Definition nats.h:1306
jsFetchNextHandler NextHandler
If set, switches to manual fetch flow control.
Definition nats.h:1367
int64_t MinAckPending
When specified, this Pull request will only receive messages when the consumer has at least this many...
Definition nats.h:1347
jsFetchCompleteHandler CompleteHandler
Fetch complete handler that receives the exit status code, the subscription's Complete handler is als...
Definition nats.h:1322
int64_t Heartbeat
Have server sends heartbeats at this interval (in milliseconds) to help detect communication failures...
Definition nats.h:1327
bool NoWait
If NoWait is set, the subscription will receive the messages already stored on the server subject to ...
Definition nats.h:1317
void * CompleteHandlerClosure
Definition nats.h:1323
int64_t MinPending
When specified, this subscription will only receive messages when the consumer has at least this many...
Definition nats.h:1340
const char * Group
The name of consumer priority group.
Definition nats.h:1333
int KeepAhead
When using the automatic Fetch flow control (default NextHandler), initiate the next fetch request (t...
Definition nats.h:1360
Definition nats.h:1434
jsOptionsStreamInfo Info
Optional stream information retrieval options.
Definition nats.h:1436
jsOptionsStreamPurge Purge
Optional stream purge options.
Definition nats.h:1435
Definition nats.h:1421
bool DeletedDetails
Get the list of deleted message sequences.
Definition nats.h:1422
const char * SubjectsFilter
Get the list of subjects in this stream.
Definition nats.h:1423
Definition nats.h:1410
uint64_t Keep
Number of messages to keep.
Definition nats.h:1413
const char * Subject
This is the subject to match against messages for the purge command.
Definition nats.h:1411
uint64_t Sequence
Purge up to but not including sequence.
Definition nats.h:1412
Definition nats.h:714
bool Offline
Definition nats.h:717
uint64_t Lag
Definition nats.h:719
int64_t Active
Definition nats.h:718
char * Name
Definition nats.h:715
bool Current
Definition nats.h:716
Definition nats.h:390
int TagsLen
Definition nats.h:393
const char * Cluster
Definition nats.h:391
const char ** Tags
Definition nats.h:392
Definition nats.h:1049
char * Group
Definition nats.h:1050
char * PinnedClientID
Definition nats.h:1051
int64_t PinnedTS
Definition nats.h:1052
Definition nats.h:1211
natsMsg * Msg
Definition nats.h:1212
natsStatus Err
Definition nats.h:1213
jsErrCode ErrCode
Definition nats.h:1214
const char * ErrText
Definition nats.h:1215
Definition nats.h:1198
uint64_t Sequence
Definition nats.h:1200
bool Duplicate
Definition nats.h:1202
char * Domain
Definition nats.h:1201
char * Stream
Definition nats.h:1199
Definition nats.h:289
int64_t MsgTTL
Message time to live (TTL) in milliseconds, used by the server to expire the message....
Definition nats.h:297
const char * ExpectLastMsgId
Expected last message ID in the stream.
Definition nats.h:293
int64_t MaxWait
Amount of time (in milliseconds) to wait for a publish response, default will the context's Wait valu...
Definition nats.h:290
uint64_t ExpectLastSeq
Expected last message sequence in the stream.
Definition nats.h:294
bool ExpectNoMessage
Expected no message (that is, sequence == 0) for the subject in the stream.
Definition nats.h:296
const char * ExpectStream
Expected stream to respond from the publish call.
Definition nats.h:292
const char * MsgId
Message ID used for de-duplication.
Definition nats.h:291
uint64_t ExpectLastSubjectSeq
Expected last message sequence for the subject in the stream.
Definition nats.h:295
Definition nats.h:443
bool HeadersOnly
Definition nats.h:446
const char * Source
Definition nats.h:444
const char * Destination
Definition nats.h:445
Definition nats.h:1038
int64_t Last
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:1041
uint64_t Stream
Definition nats.h:1040
uint64_t Consumer
Definition nats.h:1039
Definition nats.h:1028
uint64_t Consumer
Definition nats.h:1029
uint64_t Stream
Definition nats.h:1030
Definition nats.h:755
const char * Name
Definition nats.h:756
const char * Cluster
Definition nats.h:758
const char * Domain
Definition nats.h:757
Definition nats.h:549
jsDiscardPolicy Discard
Definition nats.h:561
const char ** Subjects
Definition nats.h:552
jsSubjectTransformConfig SubjectTransform
Applies a subject transform (to matching messages) before doing anything else when a new message is r...
Definition nats.h:609
bool AllowDirect
Allow higher performance, direct access to get individual messages. E.g. KeyValue.
Definition nats.h:585
int SourcesLen
Definition nats.h:570
bool DiscardNewPerSubject
Allow KV like semantics to also discard new on a per subject basis.
Definition nats.h:593
jsStorageCompression Compression
js_StorageCompressionNone (default) or js_StorageCompressionS2.
Definition nats.h:602
const char * Description
Definition nats.h:551
const char * Template
Definition nats.h:565
bool AllowMsgTTL
Allow the message to be sent with a time to live (TTL) value. Requires nats-server v2....
Definition nats.h:617
bool DenyPurge
Restrict the ability to purge messages.
Definition nats.h:573
jsStorageType Storage
Definition nats.h:562
jsStreamConsumerLimits ConsumerLimits
Sets the limits on certain options on all consumers of the stream.
Definition nats.h:613
jsRetentionPolicy Retention
Definition nats.h:554
int64_t MaxMsgs
Definition nats.h:556
int64_t MaxConsumers
Definition nats.h:555
natsMetadata Metadata
A user-provided array of key/value pairs, encoded as a string array [n1, v1, n2, v2,...
Definition nats.h:598
uint64_t FirstSeq
the starting sequence number for the stream.
Definition nats.h:605
const char * Name
Definition nats.h:550
bool NoAck
Definition nats.h:564
jsStreamSource ** Sources
Definition nats.h:569
int32_t MaxMsgSize
Definition nats.h:560
jsRePublish * RePublish
Allow republish of the message after being sequenced and stored.
Definition nats.h:581
bool MirrorDirect
Allow higher performance and unified direct access for mirrors as well.
Definition nats.h:589
int64_t Duplicates
Definition nats.h:566
int64_t MaxMsgsPerSubject
Definition nats.h:559
int64_t SubjectDeleteMarkerTTL
Enables and sets a duration for adding server markers for delete, purge and max age limits....
Definition nats.h:622
int64_t MaxAge
Max age of messages in nanoseconds.
Definition nats.h:558
int SubjectsLen
Definition nats.h:553
bool AllowRollup
Allow messages to be placed into the system and purge all older messages using a special message head...
Definition nats.h:577
jsStreamSource * Mirror
Definition nats.h:568
jsPlacement * Placement
Definition nats.h:567
int64_t MaxBytes
Definition nats.h:557
int64_t Replicas
Definition nats.h:563
bool Sealed
Seal a stream so no messages can get our or in.
Definition nats.h:571
bool DenyDelete
Restrict the ability to delete messages.
Definition nats.h:572
Definition nats.h:465
int MaxAckPending
Definition nats.h:467
int64_t InactiveThreshold
Definition nats.h:466
Definition nats.h:769
jsStreamSourceInfo ** Sources
Definition nats.h:775
int64_t Created
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:771
jsStreamAlternate ** Alternates
Definition nats.h:777
jsStreamState State
Definition nats.h:772
jsClusterInfo * Cluster
Definition nats.h:773
jsStreamSourceInfo * Mirror
Definition nats.h:774
int AlternatesLen
Definition nats.h:778
jsStreamConfig * Config
Definition nats.h:770
int SourcesLen
Definition nats.h:776
Definition nats.h:790
jsStreamInfo ** List
Definition nats.h:791
int Count
Definition nats.h:792
Definition nats.h:804
char ** List
Definition nats.h:805
int Count
Definition nats.h:806
Definition nats.h:426
jsExternalStream * External
Definition nats.h:431
int64_t OptStartTime
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:429
const char * Name
Definition nats.h:427
const char * Domain
Definition nats.h:435
uint64_t OptStartSeq
Definition nats.h:428
const char * FilterSubject
Definition nats.h:430
Definition nats.h:740
const char * FilterSubject
Definition nats.h:745
int64_t Active
Definition nats.h:744
int SubjectTransformsLen
Definition nats.h:747
char * Name
Definition nats.h:741
jsExternalStream * External
Definition nats.h:742
uint64_t Lag
Definition nats.h:743
jsSubjectTransformConfig * SubjectTransforms
Definition nats.h:746
Definition nats.h:692
jsLostStreamData * Lost
Definition nats.h:704
uint64_t LastSeq
Definition nats.h:697
int64_t Consumers
Definition nats.h:705
int DeletedLen
Definition nats.h:703
uint64_t Msgs
Definition nats.h:693
jsStreamStateSubjects * Subjects
Definition nats.h:700
uint64_t FirstSeq
Definition nats.h:695
int64_t LastTime
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:698
int64_t NumSubjects
Definition nats.h:699
uint64_t * Deleted
Definition nats.h:702
uint64_t NumDeleted
Definition nats.h:701
uint64_t Bytes
Definition nats.h:694
int64_t FirstTime
UTC time expressed as number of nanoseconds since epoch.
Definition nats.h:696
Definition nats.h:643
uint64_t Msgs
Definition nats.h:645
const char * Subject
Definition nats.h:644
Definition nats.h:679
int Count
Definition nats.h:681
jsStreamStateSubject * List
Definition nats.h:680
Definition nats.h:963
bool ManualAck
If true, the user will have to acknowledge the messages.
Definition nats.h:1008
const char * Consumer
If specified, the subscription will be bound to an existing consumer from the Stream without attempti...
Definition nats.h:980
const char * Stream
If specified, the consumer will be bound to this stream name.
Definition nats.h:970
bool Ordered
If true, this will be an ordered consumer.
Definition nats.h:1020
const char * Queue
Queue name for queue subscriptions.
Definition nats.h:995
jsConsumerConfig Config
Consumer configuration.
Definition nats.h:1013
Definition nats.h:455
const char * Destination
Definition nats.h:457
const char * Source
Definition nats.h:456
Definition nats.h:1148
const char * Name
Definition nats.h:1149
int64_t Streams
Definition nats.h:1152
uint64_t Store
Definition nats.h:1151
int64_t Consumers
Definition nats.h:1153
uint64_t Memory
Definition nats.h:1150
jsAccountLimits Limits
Definition nats.h:1154
Definition nats.h:1494
uint8_t History
Definition nats.h:1498
const char * Bucket
Definition nats.h:1495
int64_t MaxBytes
Definition nats.h:1500
int32_t MaxValueSize
Definition nats.h:1497
int Replicas
Definition nats.h:1502
const char * Description
Definition nats.h:1496
jsStreamSource * Mirror
Definition nats.h:1504
int64_t TTL
Definition nats.h:1499
jsStorageType StorageType
Definition nats.h:1501
jsRePublish * RePublish
Definition nats.h:1503
int SourcesLen
Definition nats.h:1506
jsStreamSource ** Sources
Definition nats.h:1505
A list of KeyValue store entries.
Definition nats.h:1565
kvEntry ** Entries
Definition nats.h:1566
int Count
Definition nats.h:1567
A list of KeyValue store keys.
Definition nats.h:1589
int Count
Definition nats.h:1591
char ** Keys
Definition nats.h:1590
Definition nats.h:1531
int64_t Timeout
Definition nats.h:1533
int64_t DeleteMarkersOlderThan
Definition nats.h:1543
Definition nats.h:1516
bool IgnoreDeletes
Definition nats.h:1517
bool IncludeHistory
Definition nats.h:1518
int64_t Timeout
How long to wait (in milliseconds) for some operations to complete.
Definition nats.h:1520
bool UpdatesOnly
Only receive updates, no initial snapshot.
Definition nats.h:1521
bool MetaOnly
Definition nats.h:1519
Definition nats.h:9607
const char * Name
The name of the endpoint.
Definition nats.h:9613
microRequestHandler Handler
The request handler for the endpoint.
Definition nats.h:9647
const char * Subject
The NATS subject the endpoint will listen on.
Definition nats.h:9624
natsMetadata Metadata
Metadata for the endpoint, a JSON-encoded user-provided object, e.g. {"key":"value"}
Definition nats.h:9642
bool NoQueueGroup
Disables the use of a queue group for the service.
Definition nats.h:9636
const char * QueueGroup
Overrides the default queue group for the service.
Definition nats.h:9630
void * State
A user-provided pointer to store with the endpoint (state/closure).
Definition nats.h:9653
Definition nats.h:9660
const char * Subject
The semantic version of the service.
Definition nats.h:9669
const char * Name
The name of the service.
Definition nats.h:9664
const char * QueueGroup
Endpoint's actual queue group (the default "q", or one explicitly set by the user),...
Definition nats.h:9675
natsMetadata Metadata
Metadata for the endpoint, a JSON-encoded user-provided object, e.g. {"key":"value"}
Definition nats.h:9681
Definition nats.h:9688
const char * Subject
Definition nats.h:9690
int64_t NumRequests
The number of requests received by the endpoint.
Definition nats.h:9701
char LastErrorString[2048]
a copy of the last error message.
Definition nats.h:9727
int64_t ProcessingTimeSeconds
total request processing time (the seconds part).
Definition nats.h:9712
int64_t ProcessingTimeNanoseconds
total request processing time (the nanoseconds part).
Definition nats.h:9717
const char * QueueGroup
Endpoint's actual queue group (the default "q", or one explicitly set by the user),...
Definition nats.h:9696
int64_t NumErrors
The number of errors, service-level and internal, associated with the endpoint.
Definition nats.h:9707
int64_t AverageProcessingTimeNanoseconds
average request processing time, in ns.
Definition nats.h:9722
const char * Name
Definition nats.h:9689
The Microservice endpoint group configuration object.
Definition nats.h:9734
bool NoQueueGroup
Disables the use of a queue group for the service.
Definition nats.h:9742
const char * QueueGroup
Overrides the default queue group for the service.
Definition nats.h:9739
const char * Prefix
The subject prefix for the group.
Definition nats.h:9736
The Microservice top-level configuration object.
Definition nats.h:9752
const char * Description
The description of the service.
Definition nats.h:9768
void * State
A user-provided pointer to state data.
Definition nats.h:9832
const char * Version
The (semantic) version of the service.
Definition nats.h:9763
microErrorHandler ErrHandler
An error notification handler.
Definition nats.h:9813
natsMetadata Metadata
Immutable metadata for the service, a JSON-encoded user-provided object, e.g. {"key":"value"}
Definition nats.h:9786
bool NoQueueGroup
Disables the use of a queue group for the service.
Definition nats.h:9780
microRequestHandler StatsHandler
A custom stats handler.
Definition nats.h:9804
microDoneHandler DoneHandler
A callback handler for handling the final cleanup Done event, right before the service is destroyed.
Definition nats.h:9823
const char * QueueGroup
Overrides the default queue group for the service ("q").
Definition nats.h:9774
const char * Name
The name of the service.
Definition nats.h:9758
microEndpointConfig * Endpoint
The "main" (aka default) endpoint configuration.
Definition nats.h:9795
Definition nats.h:9841
natsMetadata Metadata
Metadata for the service, a JSON-encoded user-provided object, e.g. {"key":"value"}
Definition nats.h:9870
const char * Name
The name of the service.
Definition nats.h:9850
const char * Version
The semantic version of the service.
Definition nats.h:9855
const char * Type
Response type. Always "io.nats.micro.v1.info_response".
Definition nats.h:9845
const char * Id
The ID of the service instance responding to the request.
Definition nats.h:9865
microEndpointInfo * Endpoints
Endpoints.
Definition nats.h:9875
const char * Description
The description of the service.
Definition nats.h:9860
int EndpointsLen
The number of endpoints in the Endpoints array.
Definition nats.h:9880
Definition nats.h:9887
int64_t Started
The timestamp of when the service was started.
Definition nats.h:9911
int EndpointsLen
The number of endpoints in the endpoints array.
Definition nats.h:9921
microEndpointStats * Endpoints
The stats for each endpoint of the service.
Definition nats.h:9916
const char * Version
The semantic version of the service.
Definition nats.h:9901
const char * Name
The name of the service.
Definition nats.h:9896
const char * Type
Response type. Always "io.nats.micro.v1.stats_response".
Definition nats.h:9891
const char * Id
The ID of the service instance responding to the request.
Definition nats.h:9906
A type to represent user-provided metadata, a list of k=v pairs.
Definition nats.h:251
int Count
Number of key/value pairs in Metadata, 1/2 of the length of the array.
Definition nats.h:259
const char ** List
User-provided metadata for the stream, encoded as an array of {"key", "value",...}.
Definition nats.h:255
A list of NATS messages.
Definition nats.h:240
int Count
Definition nats.h:242
natsMsg ** Msgs
Definition nats.h:241
Definition nats.h:1654
natsMetadata Metadata
Definition nats.h:1717
int64_t TTL
TTL is the maximum age (expressed in milliseconds) of objects in the store.
Definition nats.h:1674
jsStorageType Storage
Storage is the type of storage to use for the object store.
Definition nats.h:1688
int Replicas
Replicas is the number of replicas to keep for the object store in clustered jetstream.
Definition nats.h:1695
bool Compression
Compression enables the underlying stream compression.
Definition nats.h:1710
const char * Bucket
Bucket is the name of the object store.
Definition nats.h:1661
jsPlacement * Placement
Placement is used to declare where the object store should be placed.
Definition nats.h:1703
const char * Description
Description is an optional description for the object store.
Definition nats.h:1666
int64_t MaxBytes
MaxBytes is the maximum size of the object store.
Definition nats.h:1681
Definition nats.h:1902
objStoreMeta Meta
objStoreMeta contains high level information about the object.
Definition nats.h:1906
const char * Bucket
Bucket is the name of the object store.
Definition nats.h:1911
bool Deleted
Deleted indicates if the object is marked as deleted.
Definition nats.h:1945
uint64_t Size
Size is the size of the object in bytes. It only includes the size of the object itself,...
Definition nats.h:1921
uint32_t Chunks
Chunks is the number of chunks the object is split into.
Definition nats.h:1933
int64_t ModTime
ModTime is the last modification time of the object (in unix nanoseconds).
Definition nats.h:1926
const char * Digest
Digest is the SHA-256 digest of the object.
Definition nats.h:1940
const char * NUID
NUID is the unique identifier for the object set when putting the object into the store.
Definition nats.h:1916
Definition nats.h:1957
int Count
Definition nats.h:1959
objStoreInfo ** List
Definition nats.h:1958
Definition nats.h:1867
const char * Description
Description is an optional description for the object.
Definition nats.h:1879
const char * Name
Name is the name of the object.
Definition nats.h:1874
objStoreMetaOptions Opts
Additional options for the object.
Definition nats.h:1894
natsMetadata Metadata
Metadata is the user supplied metadata for the object.
Definition nats.h:1889
natsHeader * Headers
Headers is an optional set of user-defined headers for the object.
Definition nats.h:1884
Definition nats.h:1846
objStoreLink * Link
Link contains information about a link to another object or object store.
Definition nats.h:1852
uint32_t ChunkSize
ChunkSize is the maximum size of each chunk in bytes.
Definition nats.h:1859
Definition nats.h:1729
char ** List
Definition nats.h:1730
int Count
Definition nats.h:1731
Definition nats.h:1975
bool ShowDeleted
ShowDeleted includes deleted object in the result.
Definition nats.h:1982
Definition nats.h:1749
bool Sealed
Sealed indicates the stream is sealed and cannot be modified in any way.
Definition nats.h:1778
bool IsCompressed
IsCompressed indicates if the data is compressed on disk.
Definition nats.h:1805
const char * Description
Description is the description supplied when creating the bucket.
Definition nats.h:1758
jsStorageType Storage
Storage indicates the underlying JetStream storage technology used tostore data.
Definition nats.h:1768
uint64_t Size
Size is the combined size of all data in the bucket including metadata, in bytes.
Definition nats.h:1783
const char * Bucket
Bucket is the name of the object store.
Definition nats.h:1753
const char * BackingStore
BackingStore indicates what technology is used for storage of the bucket.
Definition nats.h:1790
jsStreamInfo * StreamInfo
StreamInfo is the stream info retrieved to create the status.
Definition nats.h:1800
int Replicas
Replicas indicates how many storage replicas are kept for the data in the bucket.
Definition nats.h:1773
int64_t TTL
TTL indicates how long (in milliseconds) objects are kept in the bucket.
Definition nats.h:1763
natsMetadata Metadata
Metadata is the user supplied metadata for the bucket.
Definition nats.h:1795
Definition nats.h:1817
int Count
Definition nats.h:1819
objStoreStatus ** List
Definition nats.h:1818
Definition nats.h:1992
bool UpdatesOnly
The watcher won't return information about existing objects.
Definition nats.h:2007
bool IgnoreDeletes
The watcher won't return information about deleted objects.
Definition nats.h:1999