NATS C Client with Streaming support  2.5.1
The nats.io C Client, Supported by Synadia Communications Inc.
nats.h
Go to the documentation of this file.
1 // Copyright 2015-2021 The NATS Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef NATS_H_
15 #define NATS_H_
16 
17 #ifdef __cplusplus
18 extern "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 
88 //
89 // Types.
90 //
102 typedef struct __natsConnection natsConnection;
103 
109 typedef struct __natsStatistics natsStatistics;
110 
115 typedef struct __natsSubscription natsSubscription;
116 
122 typedef struct __natsMsg natsMsg;
123 
128 typedef struct __natsOptions natsOptions;
129 
137 typedef char natsInbox;
138 
139 #if defined(NATS_HAS_STREAMING)
140 
144 typedef struct __stanConnection stanConnection;
145 
150 typedef struct __stanSubscription stanSubscription;
151 
156 typedef struct __stanMsg stanMsg;
157 
162 typedef struct __stanConnOptions stanConnOptions;
163 
168 typedef struct __stanSubOptions stanSubOptions;
169 #endif
170  // end of typesGroup
172 
173 //
174 // Callbacks.
175 //
176 
199 typedef void (*natsMsgHandler)(
200  natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure);
201 
215 typedef void (*natsConnectionHandler)(
216  natsConnection *nc, void *closure);
217 
224 typedef void (*natsErrHandler)(
225  natsConnection *nc, natsSubscription *subscription, natsStatus err,
226  void *closure);
227 
242  void **userData,
243  void *loop,
244  natsConnection *nc,
245  natsSock socket);
246 
257  void *userData,
258  bool add);
259 
270  void *userData,
271  bool add);
272 
281  void *userData);
282 
305  char **userJWT,
306  char **customErrTxt,
307  void *closure);
308 
309 
336  char **customErrTxt,
337  unsigned char **signature,
338  int *signatureLength,
339  const char *nonce,
340  void *closure);
341 
350 typedef const char* (*natsTokenHandler)(void *closure);
351 
352 
360 typedef void (*natsOnCompleteCB)(void *closure);
361 
382 typedef int64_t (*natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure);
383 
384 #if defined(NATS_HAS_STREAMING)
385 
393 typedef void (*stanPubAckHandler)(const char *guid, const char *error, void *closure);
394 
404 typedef void (*stanMsgHandler)(
405  stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure);
406 
414  stanConnection *sc, const char* errorTxt, void *closure);
415 #endif
416  // end of callbacksGroup
418 
419 //
420 // Functions.
421 //
448 nats_Open(int64_t lockSpinCount);
449 
450 
455 NATS_EXTERN const char*
456 nats_GetVersion(void);
457 
465 NATS_EXTERN uint32_t
467 
468 #ifdef BUILD_IN_DOXYGEN
469 
484 #else
485 
486 #define nats_CheckCompatibility() nats_CheckCompatibilityImpl(NATS_VERSION_REQUIRED_NUMBER, \
487  NATS_VERSION_NUMBER, \
488  NATS_VERSION_STRING)
489 
490 NATS_EXTERN bool
491 nats_CheckCompatibilityImpl(uint32_t reqVerNumber, uint32_t verNumber, const char *verString);
492 
493 #endif
494 
499 NATS_EXTERN int64_t
500 nats_Now(void);
501 
507 NATS_EXTERN int64_t
509 
517 NATS_EXTERN void
518 nats_Sleep(int64_t sleepTime);
519 
532 NATS_EXTERN const char*
534 
544 nats_GetLastErrorStack(char *buffer, size_t bufLen);
545 
566 NATS_EXTERN void
567 nats_PrintLastErrorStack(FILE *file);
568 
600 
611 NATS_EXTERN void
613 
639 nats_Sign(const char *encodedSeed,
640  const char *input,
641  unsigned char **signature,
642  int *signatureLength);
643 
664 NATS_EXTERN void
665 nats_Close(void);
666 
713 nats_CloseAndWait(int64_t timeout);
714  // end of libraryGroup
716 
732 NATS_EXTERN const char*
734  // end of statusGroup
736 
756 
775  uint64_t *inMsgs, uint64_t *inBytes,
776  uint64_t *outMsgs, uint64_t *outBytes,
777  uint64_t *reconnects);
778 
785 NATS_EXTERN void
787  // end of statsGroup
789 
816 
837 /*
838  * The above is for doxygen. The proper syntax for username/password
839  * is without the '\' character:
840  *
841  * nats://localhost:4222
842  * nats://user@localhost:4222
843  * nats://user:password@localhost:4222
844  */
846 natsOptions_SetURL(natsOptions *opts, const char *url);
847 
863 natsOptions_SetServers(natsOptions *opts, const char** servers, int serversCount);
864 
891 natsOptions_SetUserInfo(natsOptions *opts, const char *user, const char *password);
892 
918 natsOptions_SetToken(natsOptions *opts, const char *token);
919 
937  void *closure);
938 
949 natsOptions_SetNoRandomize(natsOptions *opts, bool noRandomize);
950 
964 natsOptions_SetTimeout(natsOptions *opts, int64_t timeout);
965 
974 natsOptions_SetName(natsOptions *opts, const char *name);
975 
986 natsOptions_SetSecure(natsOptions *opts, bool secure);
987 
1002 natsOptions_LoadCATrustedCertificates(natsOptions *opts, const char *fileName);
1003 
1030 natsOptions_SetCATrustedCertificates(natsOptions *opts, const char *certificates);
1031 
1048  const char *certsFileName,
1049  const char *keyFileName);
1050 
1064  const char *cert,
1065  const char *key);
1066 
1083 natsOptions_SetCiphers(natsOptions *opts, const char *ciphers);
1084 
1099 natsOptions_SetCipherSuites(natsOptions *opts, const char *ciphers);
1100 
1111 natsOptions_SetExpectedHostname(natsOptions *opts, const char *hostname);
1112 
1125 
1137 natsOptions_SetVerbose(natsOptions *opts, bool verbose);
1138 
1150 natsOptions_SetPedantic(natsOptions *opts, bool pedantic);
1151 
1162 natsOptions_SetPingInterval(natsOptions *opts, int64_t interval);
1163 
1176 natsOptions_SetMaxPingsOut(natsOptions *opts, int maxPingsOut);
1177 
1190 natsOptions_SetIOBufSize(natsOptions *opts, int ioBufSize);
1191 
1204 natsOptions_SetAllowReconnect(natsOptions *opts, bool allow);
1205 
1214 natsOptions_SetMaxReconnect(natsOptions *opts, int maxReconnect);
1215 
1230 natsOptions_SetReconnectWait(natsOptions *opts, int64_t reconnectWait);
1231 
1256 natsOptions_SetReconnectJitter(natsOptions *opts, int64_t jitter, int64_t jitterTLS);
1257 
1279  void *closure);
1280 
1294 natsOptions_SetReconnectBufSize(natsOptions *opts, int reconnectBufSize);
1295 
1310 natsOptions_SetMaxPendingMsgs(natsOptions *opts, int maxPending);
1311 
1328  void *closure);
1329 
1344  void *closure);
1345 
1364  natsConnectionHandler disconnectedCb,
1365  void *closure);
1366 
1384  natsConnectionHandler reconnectedCb,
1385  void *closure);
1386 
1403  natsConnectionHandler discoveredServersCb,
1404  void *closure);
1405 
1424  natsConnectionHandler lameDuckCb,
1425  void *closure);
1426 
1446  void *loop,
1447  natsEvLoop_Attach attachCb,
1448  natsEvLoop_ReadAddRemove readCb,
1449  natsEvLoop_WriteAddRemove writeCb,
1450  natsEvLoop_Detach detachCb);
1451 
1476 
1500 natsOptions_IPResolutionOrder(natsOptions *opts, int order);
1501 
1530 natsOptions_SetSendAsap(natsOptions *opts, bool sendAsap);
1531 
1542 natsOptions_UseOldRequestStyle(natsOptions *opts, bool useOldStyle);
1543 
1559 natsOptions_SetFailRequestsOnDisconnect(natsOptions *opts, bool failRequests);
1560 
1580 natsOptions_SetNoEcho(natsOptions *opts, bool noEcho);
1581 
1637  natsConnectionHandler connectedCb, void* closure);
1638 
1669  natsUserJWTHandler ujwtCB,
1670  void *ujwtClosure,
1671  natsSignatureHandler sigCB,
1672  void *sigClosure);
1673 
1714  const char *userOrChainedFile,
1715  const char *seedFile);
1716 
1742  const char *pubKey,
1743  natsSignatureHandler sigCB,
1744  void *sigClosure);
1745 
1772  const char *pubKey,
1773  const char *seedFile);
1774 
1789 natsOptions_SetWriteDeadline(natsOptions *opts, int64_t deadline);
1790 
1826 natsOptions_DisableNoResponders(natsOptions *opts, bool disabled);
1827 
1835 NATS_EXTERN void
1837  // end of optsGroup
1839 
1840 #if defined(NATS_HAS_STREAMING)
1841 
1876 
1899 stanConnOptions_SetURL(stanConnOptions *opts, const char *url);
1900 
1919 
1931 
1942 stanConnOptions_SetPubAckWait(stanConnOptions *opts, int64_t wait);
1943 
1952 stanConnOptions_SetDiscoveryPrefix(stanConnOptions *opts, const char *prefix);
1953 
1954 
1970 stanConnOptions_SetMaxPubAcksInflight(stanConnOptions *opts, int maxPubAcksInflight, float percentage);
1971 
1988 stanConnOptions_SetPings(stanConnOptions *opts, int interval, int maxOut);
1989 
2002 
2010 NATS_EXTERN void
2012  // end of stanConnOptsGroup
2014 
2047 
2067 stanSubOptions_SetDurableName(stanSubOptions *opts, const char *durableName);
2068 
2083 stanSubOptions_SetAckWait(stanSubOptions *opts, int64_t wait);
2084 
2097 stanSubOptions_SetMaxInflight(stanSubOptions *opts, int maxInflight);
2098 
2115 stanSubOptions_StartAtSequence(stanSubOptions *opts, uint64_t seq);
2116 
2132 stanSubOptions_StartAtTime(stanSubOptions *opts, int64_t time);
2133 
2146 stanSubOptions_StartAtTimeDelta(stanSubOptions *opts, int64_t delta);
2147 
2158 
2168 
2185 
2193 NATS_EXTERN void
2195  // end of stanSubOptsGroup
2197 #endif
2198 
2219 natsInbox_Create(natsInbox **newInbox);
2220 
2227 NATS_EXTERN void
2228 natsInbox_Destroy(natsInbox *inbox);
2229  // end of inboxGroup
2231 
2256 natsMsg_Create(natsMsg **newMsg, const char *subj, const char *reply,
2257  const char *data, int dataLen);
2258 
2267 NATS_EXTERN const char*
2268 natsMsg_GetSubject(const natsMsg *msg);
2269 
2279 NATS_EXTERN const char*
2280 natsMsg_GetReply(const natsMsg *msg);
2281 
2297 NATS_EXTERN const char*
2298 natsMsg_GetData(const natsMsg *msg);
2299 
2306 NATS_EXTERN int
2307 natsMsg_GetDataLength(const natsMsg *msg);
2308 
2325 natsMsgHeader_Set(natsMsg *msg, const char *key, const char *value);
2326 
2343 natsMsgHeader_Add(natsMsg *msg, const char *key, const char *value);
2344 
2364 natsMsgHeader_Get(natsMsg *msg, const char *key, const char **value);
2365 
2400 natsMsgHeader_Values(natsMsg *msg, const char *key, const char* **values, int *count);
2401 
2432 natsMsgHeader_Keys(natsMsg *msg, const char* **keys, int *count);
2433 
2447 natsMsgHeader_Delete(natsMsg *msg, const char *key);
2448 
2474 NATS_EXTERN bool
2476 
2483 NATS_EXTERN void
2484 natsMsg_Destroy(natsMsg *msg);
2485  // end of msgGroup
2487 
2488 #if defined(NATS_HAS_STREAMING)
2489 
2501 NATS_EXTERN uint64_t
2502 stanMsg_GetSequence(const stanMsg *msg);
2503 
2510 NATS_EXTERN int64_t
2511 stanMsg_GetTimestamp(const stanMsg *msg);
2512 
2521 NATS_EXTERN bool
2522 stanMsg_IsRedelivered(const stanMsg *msg);
2523 
2539 NATS_EXTERN const char*
2540 stanMsg_GetData(const stanMsg *msg);
2541 
2548 NATS_EXTERN int
2549 stanMsg_GetDataLength(const stanMsg *msg);
2550 
2557 NATS_EXTERN void
2558 stanMsg_Destroy(stanMsg *msg);
2559  // end of stanMsgGroup
2561 #endif
2562 
2595 
2606 NATS_EXTERN void
2608 
2619 NATS_EXTERN void
2621 
2641 natsConnection_ConnectTo(natsConnection **nc, const char *urls);
2642 
2649 NATS_EXTERN bool
2651 
2658 NATS_EXTERN bool
2660 
2667 bool
2669 
2680 
2692 NATS_EXTERN int
2694 
2712 
2726 natsConnection_FlushTimeout(natsConnection *nc, int64_t timeout);
2727 
2737 NATS_EXTERN int64_t
2739 
2751 
2762 natsConnection_GetConnectedUrl(natsConnection *nc, char *buffer, size_t bufferSize);
2763 
2774 natsConnection_GetConnectedServerId(natsConnection *nc, char *buffer, size_t bufferSize);
2775 
2797 natsConnection_GetServers(natsConnection *nc, char ***servers, int *count);
2798 
2820 natsConnection_GetDiscoveredServers(natsConnection *nc, char ***servers, int *count);
2821 
2835 natsConnection_GetLastError(natsConnection *nc, const char **lastError);
2836 
2851 natsConnection_GetClientID(natsConnection *nc, uint64_t *cid);
2852 
2873 
2892 natsConnection_DrainTimeout(natsConnection *nc, int64_t timeout);
2893 
2908  const unsigned char *message, int messageLen,
2909  unsigned char sig[64]);
2910 
2931 
2943 natsConnection_GetRTT(natsConnection *nc, int64_t *rtt);
2944 
2954 
2974 natsStatus
2975 natsConnection_GetLocalIPAndPort(natsConnection *nc, char **ip, int *port);
2976 
2986 NATS_EXTERN void
2988 
2996 NATS_EXTERN void
2998  // end of connMgtGroup
3000 
3018 natsConnection_Publish(natsConnection *nc, const char *subj,
3019  const void *data, int dataLen);
3020 
3036 natsConnection_PublishString(natsConnection *nc, const char *subj,
3037  const char *str);
3038 
3051 
3065 natsConnection_PublishRequest(natsConnection *nc, const char *subj,
3066  const char *reply, const void *data, int dataLen);
3067 
3086  const char *reply, const char *str);
3087 
3106 natsConnection_Request(natsMsg **replyMsg, natsConnection *nc, const char *subj,
3107  const void *data, int dataLen, int64_t timeout);
3108 
3132  const char *subj, const char *str,
3133  int64_t timeout);
3134 
3151  natsMsg *requestMsg, int64_t timeout);
3152  // end of connPubGroup
3154 
3177  const char *subject, natsMsgHandler cb,
3178  void *cbClosure);
3179 
3212  const char *subject, int64_t timeout,
3213  natsMsgHandler cb, void *cbClosure);
3214 
3227  const char *subject);
3228 
3248  const char *subject, const char *queueGroup,
3249  natsMsgHandler cb, void *cbClosure);
3250 
3285  const char *subject, const char *queueGroup,
3286  int64_t timeout, natsMsgHandler cb, void *cbClosure);
3287 
3301  const char *subject, const char *queueGroup);
3302  // end of connSubGroup
3304  // end of connGroup
3306 
3327 
3352  int64_t timeout);
3353 
3364 
3378 
3389 natsSubscription_QueuedMsgs(natsSubscription *sub, uint64_t *queuedMsgs);
3390 
3412 natsSubscription_SetPendingLimits(natsSubscription *sub, int msgLimit, int bytesLimit);
3413 
3434 natsSubscription_GetPendingLimits(natsSubscription *sub, int *msgLimit, int *bytesLimit);
3435 
3451 natsSubscription_GetPending(natsSubscription *sub, int *msgs, int *bytes);
3452 
3462 natsSubscription_GetDelivered(natsSubscription *sub, int64_t *msgs);
3463 
3480 natsSubscription_GetDropped(natsSubscription *sub, int64_t *msgs);
3481 
3495 natsSubscription_GetMaxPending(natsSubscription *sub, int *msgs, int *bytes);
3496 
3505 
3534  int *pendingMsgs,
3535  int *pendingBytes,
3536  int *maxPendingMsgs,
3537  int *maxPendingBytes,
3538  int64_t *deliveredMsgs,
3539  int64_t *droppedMsgs);
3540 
3549 NATS_EXTERN bool
3551 
3571 
3623 natsSubscription_DrainTimeout(natsSubscription *sub, int64_t timeout);
3624 
3649 
3677 
3708 
3716 NATS_EXTERN void
3718  // end of subGroup
3720 
3721 #if defined(NATS_HAS_STREAMING)
3722 
3763 stanConnection_Connect(stanConnection **sc, const char *clusterID, const char *clientID,
3764  stanConnOptions *options);
3765 
3790 
3815 NATS_EXTERN void
3817 
3830 
3840  // end of stanConnMgtGroup
3842 
3860 stanConnection_Publish(stanConnection *sc, const char *channel,
3861  const void *data, int dataLen);
3862 
3887 stanConnection_PublishAsync(stanConnection *sc, const char *channel,
3888  const void *data, int dataLen,
3889  stanPubAckHandler ah, void *ahClosure);
3890  // end of stanConnPubGroup
3892 
3917  const char *channel, stanMsgHandler cb,
3918  void *cbClosure, stanSubOptions *options);
3919 
3941  const char *channel, const char *queueGroup,
3942  stanMsgHandler cb, void *cbClosure, stanSubOptions *options);
3943  // end of stanConnSubGroup
3945  // end of stanConnGroup
3947 
3978 
3990 
4012 
4025 
4033 NATS_EXTERN void
4035  // end of stanSubGroup
4037 #endif
4038  // end of funcGroup
4040 
4077 #ifdef __cplusplus
4078 }
4079 #endif
4080 
4081 #endif /* NATS_H_ */
NATS_EXTERN natsStatus natsOptions_SetWriteDeadline(natsOptions *opts, int64_t deadline)
Sets the write deadline.
char natsInbox
Unique subject often used for point-to-point communication.
Definition: nats.h:137
NATS_EXTERN natsStatus nats_CloseAndWait(int64_t timeout)
Tear down the library and wait for all resources to be released.
NATS_EXTERN const char * nats_GetLastError(natsStatus *status)
Returns the calling thread&#39;s last known error.
NATS_EXTERN void natsStatistics_Destroy(natsStatistics *stats)
Destroys the natsStatistics object.
NATS_EXTERN int64_t nats_NowInNanoSeconds(void)
Gives the current time in nanoseconds.
NATS_EXTERN natsStatus stanConnOptions_SetConnectionWait(stanConnOptions *opts, int64_t wait)
Sets the timeout for establishing a connection.
NATS_EXTERN natsStatus nats_Open(int64_t lockSpinCount)
Initializes the library.
NATS_EXTERN natsStatus natsOptions_SetCipherSuites(natsOptions *opts, const char *ciphers)
Sets the list of available ciphers for TLSv1.3.
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_SetName(natsOptions *opts, const char *name)
Sets the name.
struct __stanSubOptions stanSubOptions
Way to configure a stanSubscription.
Definition: nats.h:168
NATS_EXTERN natsStatus natsConnection_Connect(natsConnection **nc, natsOptions *options)
Connects to a NATS Server using the provided options.
NATS_EXTERN natsStatus natsSubscription_DrainTimeout(natsSubscription *sub, int64_t timeout)
Drains the subscription with the specified timeout.
natsStatus(* natsUserJWTHandler)(char **userJWT, char **customErrTxt, void *closure)
Callback used to fetch and return account signed user JWT.
Definition: nats.h:304
NATS_EXTERN natsStatus natsMsgHeader_Keys(natsMsg *msg, const char ***keys, int *count)
Get all header keys.
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_SetServers(natsOptions *opts, const char **servers, int serversCount)
Set the list of servers to try to (re)connect to.
NATS_EXTERN void stanMsg_Destroy(stanMsg *msg)
Destroys the message object.
NATS_EXTERN int stanMsg_GetDataLength(const stanMsg *msg)
Returns the message length.
NATS_EXTERN natsStatus natsConnection_Subscribe(natsSubscription **sub, natsConnection *nc, const char *subject, natsMsgHandler cb, void *cbClosure)
Creates an asynchronous subscription.
NATS_EXTERN natsStatus stanConnection_Subscribe(stanSubscription **sub, stanConnection *sc, const char *channel, stanMsgHandler cb, void *cbClosure, stanSubOptions *options)
Creates a subscription.
NATS_EXTERN natsStatus natsConnection_PublishString(natsConnection *nc, const char *subj, const char *str)
Publishes a string on a subject.
NATS_EXTERN natsStatus natsSubscription_NoDeliveryDelay(natsSubscription *sub)
Enables the No Delivery Delay mode.
NATS_EXTERN natsStatus stanSubOptions_Create(stanSubOptions **newOpts)
Creates a stanSubOptions object.
NATS_EXTERN natsStatus natsSubscription_GetPending(natsSubscription *sub, int *msgs, int *bytes)
Returns the number of pending messages and bytes.
NATS_EXTERN bool natsConnection_IsClosed(natsConnection *nc)
Test if connection has been closed.
NATS_EXTERN natsStatus stanSubOptions_StartAtSequence(stanSubOptions *opts, uint64_t seq)
Sets the desired start position based on the given sequence number.
NATS_EXTERN void nats_Sleep(int64_t sleepTime)
Sleeps for a given number of milliseconds.
NATS_EXTERN natsStatus natsConnection_QueueSubscribeSync(natsSubscription **sub, natsConnection *nc, const char *subject, const char *queueGroup)
Creates a synchronous queue subscriber.
NATS_EXTERN natsStatus stanSubOptions_StartWithLastReceived(stanSubOptions *opts)
The subscription should start with the last message in the channel.
struct __natsSubscription natsSubscription
Interest on a given subject.
Definition: nats.h:115
NATS_EXTERN natsStatus natsMsg_Create(natsMsg **newMsg, const char *subj, const char *reply, const char *data, int dataLen)
Creates a natsMsg object.
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 void nats_Close(void)
Tear down the library.
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 natsConnection_GetClientIP(natsConnection *nc, char **ip)
Returns the client&#39;s IP address as reported by the server.
NATS_EXTERN natsStatus natsOptions_SetMaxPingsOut(natsOptions *opts, int maxPingsOut)
Sets the limit of outstanding PINGs without corresponding PONGs.
bool natsConnection_IsDraining(natsConnection *nc)
Test if connection is draining.
NATS_EXTERN natsStatus natsOptions_UseOldRequestStyle(natsOptions *opts, bool useOldStyle)
Switches the use of old style requests.
NATS_EXTERN natsStatus stanConnection_GetNATSConnection(stanConnection *sc, natsConnection **nc)
Returns the underlying NATS Connection.
NATS_EXTERN natsStatus natsConnection_GetStats(natsConnection *nc, natsStatistics *stats)
Gets the connection statistics.
struct __stanMsg stanMsg
The Streaming message.
Definition: nats.h:156
NATS_EXTERN natsStatus natsOptions_SetNoEcho(natsOptions *opts, bool noEcho)
Sets if connection receives its own messages.
NATS_EXTERN natsStatus natsSubscription_QueuedMsgs(natsSubscription *sub, uint64_t *queuedMsgs)
Gets the number of pending messages.
NATS_EXTERN natsStatus stanSubOptions_SetManualAckMode(stanSubOptions *opts, bool manual)
Sets the subscription&#39;s acknowledgment mode.
int64_t(* natsCustomReconnectDelayHandler)(natsConnection *nc, int attempts, void *closure)
Callback used to specify how long to wait between reconnects.
Definition: nats.h:382
NATS_EXTERN bool natsConnection_IsReconnecting(natsConnection *nc)
Test if connection is reconnecting.
NATS_EXTERN natsStatus natsOptions_SetExpectedHostname(natsOptions *opts, const char *hostname)
Sets the server certificate&#39;s expected hostname.
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 stanConnOptions_SetPings(stanConnOptions *opts, int interval, int maxOut)
Sets the ping interval and max out values.
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 int natsConnection_Buffered(natsConnection *nc)
Returns the number of bytes to be sent to the server.
NATS_EXTERN natsStatus natsSubscription_GetPendingLimits(natsSubscription *sub, int *msgLimit, int *bytesLimit)
Returns the current limit for pending messages and bytes.
NATS_EXTERN natsStatus natsSubscription_GetDelivered(natsSubscription *sub, int64_t *msgs)
Returns the number of delivered messages.
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:224
NATS_EXTERN void nats_ReleaseThreadMemory(void)
Release thread-local memory possibly allocated by the library.
NATS_EXTERN void natsConnection_ProcessWriteEvent(natsConnection *nc)
Process a write event when using external event loop.
struct __natsStatistics natsStatistics
Statistics of a natsConnection.
Definition: nats.h:109
NATS_EXTERN natsStatus natsSubscription_Unsubscribe(natsSubscription *sub)
Unsubscribes.
NATS_EXTERN natsStatus stanConnOptions_Create(stanConnOptions **newOpts)
Creates a stanConnOptions object.
NATS_EXTERN const char * natsMsg_GetSubject(const natsMsg *msg)
Returns the subject set in this message.
NATS_EXTERN natsStatus natsConnection_GetClientID(natsConnection *nc, uint64_t *cid)
Gets the current client ID assigned by the server.
NATS_EXTERN natsStatus natsOptions_SetAllowReconnect(natsOptions *opts, bool allow)
Indicates if the connection will be allowed to reconnect.
NATS_EXTERN void stanConnOptions_Destroy(stanConnOptions *opts)
Destroys a stanConnOptions object.
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:335
NATS_EXTERN natsStatus natsOptions_SetSendAsap(natsOptions *opts, bool sendAsap)
Sets if Publish calls should send data right away.
NATS_EXTERN natsStatus natsConnection_Flush(natsConnection *nc)
Flushes the connection.
NATS_EXTERN natsStatus natsConnection_GetConnectedUrl(natsConnection *nc, char *buffer, size_t bufferSize)
Gets the URL of the currently connected server.
NATS_EXTERN natsStatus natsOptions_SetMaxPendingMsgs(natsOptions *opts, int maxPending)
Sets the maximum number of pending messages per subscription.
NATS_EXTERN natsStatus natsConnection_Sign(natsConnection *nc, const unsigned char *message, int messageLen, unsigned char sig[64])
Signs any &#39;message&#39; using the connection&#39;s user credentials.
NATS_EXTERN bool nats_CheckCompatibility(void)
Check that the header is compatible with the library.
NATS_EXTERN natsStatus stanSubscription_Unsubscribe(stanSubscription *sub)
Permanently remove a subscription.
natsStatus natsConnection_GetLocalIPAndPort(natsConnection *nc, char **ip, int *port)
Returns the connection local IP and port.
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 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 natsOptions_SetMaxReconnect(natsOptions *opts, int maxReconnect)
Sets the maximum number of reconnect attempts.
natsStatus
Status returned by most of the APIs.
Definition: status.h:49
NATS_EXTERN natsStatus natsConnection_SubscribeSync(natsSubscription **sub, natsConnection *nc, const char *subject)
Creates a synchronous subcription.
natsStatus(* natsEvLoop_WriteAddRemove)(void *userData, bool add)
Write event needs to be added or removed.
Definition: nats.h:269
NATS_EXTERN natsStatus natsOptions_SetVerbose(natsOptions *opts, bool verbose)
Sets the verbose mode.
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 const char * natsStatus_GetText(natsStatus s)
Get the text corresponding to a natsStatus.
NATS_EXTERN natsStatus natsOptions_SkipServerVerification(natsOptions *opts, bool skip)
Switch server certificate verification.
NATS_EXTERN natsStatus natsConnection_DrainTimeout(natsConnection *nc, int64_t timeout)
Drains the connection with given timeout.
struct __natsOptions natsOptions
Way to configure a natsConnection.
Definition: nats.h:128
void(* natsOnCompleteCB)(void *closure)
Callback used to notify that an object lifecycle is complete.
Definition: nats.h:360
NATS_EXTERN void natsConnection_Close(natsConnection *nc)
Closes the connection.
NATS_EXTERN natsStatus stanSubOptions_StartAtTimeDelta(stanSubOptions *opts, int64_t delta)
Sets the desired start position based on the given delta.
NATS_EXTERN natsStatus natsOptions_SetURL(natsOptions *opts, const char *url)
Sets the URL to connect to.
NATS_EXTERN void nats_PrintLastErrorStack(FILE *file)
Prints the calling thread&#39;s last known error stack into the file.
NATS_EXTERN natsStatus stanConnOptions_SetConnectionLostHandler(stanConnOptions *opts, stanConnectionLostHandler handler, void *closure)
Sets the connection lost handler.
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_UseGlobalMessageDelivery(natsOptions *opts, bool global)
Switch on/off the use of a central message delivery thread pool.
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 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 stanConnOptions_SetURL(stanConnOptions *opts, const char *url)
Sets the URL to connect to.
NATS_EXTERN uint64_t stanMsg_GetSequence(const stanMsg *msg)
Returns the message&#39;s sequence number.
int natsSock
Definition: nats.h:50
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 void natsInbox_Destroy(natsInbox *inbox)
Destroys the inbox.
NATS_EXTERN natsStatus natsConnection_HasHeaderSupport(natsConnection *nc)
Returns if the connection to current server supports headers.
struct __stanConnOptions stanConnOptions
Way to configure a stanConnection.
Definition: nats.h:162
NATS_EXTERN natsStatus natsOptions_SetTimeout(natsOptions *opts, int64_t timeout)
Sets the (re)connect process timeout.
NATS_EXTERN int64_t natsConnection_GetMaxPayload(natsConnection *nc)
Returns the maximum message payload.
NATS_EXTERN natsStatus natsMsgHeader_Values(natsMsg *msg, const char *key, const char ***values, int *count)
Get all header values associated with key.
natsStatus(* natsEvLoop_Detach)(void *userData)
Detach from the event loop.
Definition: nats.h:280
void(* natsConnectionHandler)(natsConnection *nc, void *closure)
Callback used to notify the user of asynchronous connection events.
Definition: nats.h:215
NATS_EXTERN uint32_t nats_GetVersionNumber(void)
Returns the Library&#39;s version as a number.
NATS_EXTERN natsStatus natsSubscription_GetMaxPending(natsSubscription *sub, int *msgs, int *bytes)
Returns the maximum number of pending messages and bytes.
NATS_EXTERN natsStatus natsOptions_SetFailRequestsOnDisconnect(natsOptions *opts, bool failRequests)
Fails pending requests on disconnect event.
NATS_EXTERN natsStatus stanSubOptions_SetAckWait(stanSubOptions *opts, int64_t wait)
Sets the timeout for waiting for an ACK from the cluster&#39;s point of view for delivered messages...
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 natsSubscription_WaitForDrainCompletion(natsSubscription *sub, int64_t timeout)
Blocks until the drain operation completes.
NATS_EXTERN const char * natsMsg_GetData(const natsMsg *msg)
Returns the message payload.
NATS_EXTERN natsStatus natsConnection_GetConnectedServerId(natsConnection *nc, char *buffer, size_t bufferSize)
Gets the server Id.
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 stanConnOptions_SetPubAckWait(stanConnOptions *opts, int64_t wait)
Sets the timeout for waiting for an ACK for a published message.
NATS_EXTERN void stanSubOptions_Destroy(stanSubOptions *opts)
Destroys a stanSubOptions object.
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 stanSubOptions_StartAtTime(stanSubOptions *opts, int64_t time)
Sets the desired start position based on the given time.
NATS_EXTERN natsStatus natsConnection_GetDiscoveredServers(natsConnection *nc, char ***servers, int *count)
Returns the list of discovered server URLs.
NATS_EXTERN natsConnStatus natsConnection_Status(natsConnection *nc)
Returns the current state of the connection.
NATS_EXTERN natsStatus natsOptions_SetCATrustedCertificates(natsOptions *opts, const char *certificates)
Sets the trusted CA certificates from memory.
natsConnStatus
The connection state.
Definition: status.h:23
NATS_EXTERN const char * stanMsg_GetData(const stanMsg *msg)
Returns the message payload.
NATS_EXTERN natsStatus natsOptions_SetIOBufSize(natsOptions *opts, int ioBufSize)
Sets the size of the internal read/write buffers.
natsStatus(* natsEvLoop_ReadAddRemove)(void *userData, bool add)
Read event needs to be added or removed.
Definition: nats.h:256
struct __stanSubscription stanSubscription
Interest on a given channel.
Definition: nats.h:150
NATS_EXTERN natsStatus natsOptions_SetReconnectBufSize(natsOptions *opts, int reconnectBufSize)
Sets the size of the backing buffer used during reconnect.
NATS_EXTERN natsStatus stanConnOptions_SetDiscoveryPrefix(stanConnOptions *opts, const char *prefix)
Sets the subject prefix the library sends the connect request to.
NATS_EXTERN natsStatus natsStatistics_Create(natsStatistics **newStats)
Creates a natsStatistics object.
NATS_EXTERN natsStatus natsOptions_SetReconnectWait(natsOptions *opts, int64_t reconnectWait)
Sets the time between reconnect attempts.
NATS_EXTERN natsStatus natsOptions_SetUserCredentialsFromFiles(natsOptions *opts, const char *userOrChainedFile, const char *seedFile)
Sets the file(s) to use to fetch user JWT and seed required to sign nonce.
NATS_EXTERN natsStatus natsOptions_SetUserInfo(natsOptions *opts, const char *user, const char *password)
Sets the user name/password to use when not specified in the URL.
NATS_EXTERN natsStatus 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.
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:413
NATS_EXTERN natsStatus natsSubscription_DrainCompletionStatus(natsSubscription *sub)
Returns the status of the drain after completion.
void(* stanPubAckHandler)(const char *guid, const char *error, void *closure)
Callback used to notify of an asynchronous publish result.
Definition: nats.h:393
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&#39;s nonce.
NATS_EXTERN void natsMsg_Destroy(natsMsg *msg)
Destroys the message object.
NATS_EXTERN natsStatus natsMsgHeader_Add(natsMsg *msg, const char *key, const char *value)
Add value to the header associated with key.
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 natsConnection_GetRTT(natsConnection *nc, int64_t *rtt)
Returns the round trip time between this client and the server.
NATS_EXTERN natsStatus natsSubscription_SetPendingLimits(natsSubscription *sub, int msgLimit, int bytesLimit)
Sets the limit for pending messages and bytes.
NATS_EXTERN natsStatus natsOptions_SetPedantic(natsOptions *opts, bool pedantic)
Sets the pedantic mode.
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_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 const char * natsMsg_GetReply(const natsMsg *msg)
Returns the reply set in this message.
NATS_EXTERN natsStatus natsOptions_SetToken(natsOptions *opts, const char *token)
Sets the token to use when not specified in the URL.
NATS_EXTERN bool stanMsg_IsRedelivered(const stanMsg *msg)
Returns the message&#39;s redelivered flag.
NATS_EXTERN natsStatus natsMsgHeader_Get(natsMsg *msg, const char *key, const char **value)
Get the header entry associated with key.
NATS_EXTERN natsStatus natsOptions_SetCiphers(natsOptions *opts, const char *ciphers)
Sets the list of available ciphers.
NATS_EXTERN natsStatus stanSubscription_SetOnCompleteCB(stanSubscription *sub, natsOnCompleteCB cb, void *closure)
Sets a completion callback.
NATS_EXTERN int natsMsg_GetDataLength(const natsMsg *msg)
Returns the message length.
NATS_EXTERN natsStatus natsOptions_SetSecure(natsOptions *opts, bool secure)
Sets the secure mode.
NATS_EXTERN void stanSubscription_Destroy(stanSubscription *sub)
Destroys the subscription.
NATS_EXTERN void natsOptions_Destroy(natsOptions *opts)
Destroys a natsOptions object.
NATS_EXTERN void natsConnection_ProcessReadEvent(natsConnection *nc)
Process a read event when using external event loop.
natsStatus(* natsEvLoop_Attach)(void **userData, void *loop, natsConnection *nc, natsSock socket)
Attach this connection to the external event loop.
Definition: nats.h:241
NATS_EXTERN natsStatus natsOptions_Create(natsOptions **newOpts)
Creates a natsOptions object.
NATS_EXTERN bool natsMsg_IsNoResponders(natsMsg *msg)
Indicates if this message is a "no responders" message from the server.
NATS_EXTERN natsStatus natsOptions_SetErrorHandler(natsOptions *opts, natsErrHandler errHandler, void *closure)
Sets the error handler for asynchronous events.
NATS_EXTERN natsStatus stanConnOptions_SetNATSOptions(stanConnOptions *opts, natsOptions *nOpts)
Sets the NATS Options to use to create the connection.
NATS_EXTERN void natsSubscription_Destroy(natsSubscription *sub)
Destroys the subscription.
NATS_EXTERN natsStatus nats_GetLastErrorStack(char *buffer, size_t bufLen)
Returns the calling thread&#39;s last known error stack.
NATS_EXTERN natsStatus natsInbox_Create(natsInbox **newInbox)
Creates an inbox.
NATS_EXTERN natsStatus natsSubscription_GetDropped(natsSubscription *sub, int64_t *msgs)
Returns the number of dropped messages.
NATS_EXTERN natsStatus natsSubscription_ClearMaxPending(natsSubscription *sub)
Clears the statistics regarding the maximum pending values.
struct __stanConnection stanConnection
A connection to a NATS Streaming Server.
Definition: nats.h:144
NATS_EXTERN natsStatus natsSubscription_SetOnCompleteCB(natsSubscription *sub, natsOnCompleteCB cb, void *closure)
Sets a completion callback.
NATS_EXTERN natsStatus natsOptions_IPResolutionOrder(natsOptions *opts, int order)
Dictates the order in which host name are resolved during connect.
NATS_EXTERN natsStatus natsSubscription_AutoUnsubscribe(natsSubscription *sub, int max)
Auto-Unsubscribes.
NATS_EXTERN void natsConnection_Destroy(natsConnection *nc)
Destroys the connection object.
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 const char * nats_GetVersion(void)
Returns the Library&#39;s version.
NATS_EXTERN natsStatus natsSubscription_NextMsg(natsMsg **nextMsg, natsSubscription *sub, int64_t timeout)
Returns the next available message.
NATS_EXTERN int64_t nats_Now(void)
Gives the current time in milliseconds.
void(* stanMsgHandler)(stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition: nats.h:404
NATS_EXTERN natsStatus stanSubscription_AckMsg(stanSubscription *sub, stanMsg *msg)
Acknowledge a message.
NATS_EXTERN natsStatus stanConnection_Close(stanConnection *sc)
Closes the connection.
NATS_EXTERN natsStatus nats_SetMessageDeliveryPoolSize(int max)
Sets the maximum size of the global message delivery thread pool.
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_DisableNoResponders(natsOptions *opts, bool disabled)
Enable/Disable the "no responders" feature.
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_LoadCertificatesChain(natsOptions *opts, const char *certsFileName, const char *keyFileName)
Loads the certificate chain from a file, using the given key.
NATS_EXTERN natsStatus stanSubOptions_DeliverAllAvailable(stanSubOptions *opts)
The subscription should start with the first message in the channel.
NATS_EXTERN natsStatus natsConnection_GetLastError(natsConnection *nc, const char **lastError)
Gets the last connection error.
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 natsMsgHeader_Delete(natsMsg *msg, const char *key)
Delete the value(s) associated with key.
NATS_EXTERN natsStatus natsOptions_SetPingInterval(natsOptions *opts, int64_t interval)
Sets the ping interval.
NATS_EXTERN natsStatus stanConnection_Publish(stanConnection *sc, const char *channel, const void *data, int dataLen)
Publishes data on a channel.
NATS_EXTERN natsStatus stanSubscription_Close(stanSubscription *sub)
Closes the subscription.
NATS_EXTERN bool natsSubscription_IsValid(natsSubscription *sub)
Checks the validity of the subscription.
struct __natsMsg natsMsg
A structure holding a subject, optional reply and payload.
Definition: nats.h:122
NATS_EXTERN natsStatus natsSubscription_Drain(natsSubscription *sub)
Drains the subscription with a default timeout.
void(* natsMsgHandler)(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure)
Callback used to deliver messages to the application.
Definition: nats.h:199
NATS_EXTERN natsStatus stanConnection_Destroy(stanConnection *sc)
Destroys the connection object.
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.
#define NATS_EXTERN
Needed for shared library.
Definition: nats.h:49
const char *(* natsTokenHandler)(void *closure)
Callback used to build a token on connections and reconnections.
Definition: nats.h:350
NATS_EXTERN natsStatus natsConnection_Publish(natsConnection *nc, const char *subj, const void *data, int dataLen)
Publishes data on a subject.
NATS_EXTERN natsStatus natsConnection_FlushTimeout(natsConnection *nc, int64_t timeout)
Flushes the connection with a given timeout.
NATS_EXTERN natsStatus stanSubOptions_SetDurableName(stanSubOptions *opts, const char *durableName)
Sets the Durable Name for this subscription.
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_LoadCATrustedCertificates(natsOptions *opts, const char *fileName)
Loads the trusted CA certificates from a file.
NATS_EXTERN natsStatus natsOptions_SetReconnectedCB(natsOptions *opts, natsConnectionHandler reconnectedCb, void *closure)
Sets the callback to be invoked when the connection has reconnected.
struct __natsConnection natsConnection
A connection to a NATS Server.
Definition: nats.h:102
NATS_EXTERN void stanConnection_ReleaseNATSConnection(stanConnection *sc)
Releases the NATS Connection.
NATS_EXTERN natsStatus natsConnection_Drain(natsConnection *nc)
Drains the connection with default timeout.
NATS_EXTERN natsStatus natsOptions_SetNoRandomize(natsOptions *opts, bool noRandomize)
Indicate if the servers list should be randomized.
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 int64_t stanMsg_GetTimestamp(const stanMsg *msg)
Returns the message&#39;s timestamp.
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 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 natsOptions_SetCertificatesChain(natsOptions *opts, const char *cert, const char *key)
Sets the client certificate and key.
NATS_EXTERN natsStatus stanConnOptions_SetMaxPubAcksInflight(stanConnOptions *opts, int maxPubAcksInflight, float percentage)
Sets the maximum number of published messages without outstanding ACKs from the server.