diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ce286040..24680af60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,8 +233,8 @@ endif(NATS_BUILD_WITH_TLS) # Versionning and Doc set(NATS_VERSION_MAJOR 2) -set(NATS_VERSION_MINOR 5) -set(NATS_VERSION_PATCH 1) +set(NATS_VERSION_MINOR 6) +set(NATS_VERSION_PATCH 0) set(NATS_VERSION_SUFFIX "") set(NATS_VERSION_REQUIRED_NUMBER 0x020200) diff --git a/README.md b/README.md index 8a0fb9733..c38f374d8 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This NATS Client implementation is heavily based on the [NATS GO Client](https:/ [](https://www.apache.org/licenses/LICENSE-2.0) [](https://travis-ci.com/github/nats-io/nats.c) [](https://coveralls.io/github/nats-io/nats.c?branch=main) -[](https://github.com/nats-io/nats.c/releases/tag/v2.5.1) +[](https://github.com/nats-io/nats.c/releases/tag/v2.6.0) [](http://nats-io.github.io/nats.c) [](https://lgtm.com/projects/g/nats-io/nats.c/alerts/) [](https://lgtm.com/projects/g/nats-io/nats.c/context:cpp) diff --git a/doc/DoxyFile.NATS.Client b/doc/DoxyFile.NATS.Client index 915ad7a85..dcd2b041f 100644 --- a/doc/DoxyFile.NATS.Client +++ b/doc/DoxyFile.NATS.Client @@ -38,7 +38,7 @@ PROJECT_NAME = "NATS C Client with Streaming support" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.5.1 +PROJECT_NUMBER = 2.6.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/html/deprecated.html b/doc/html/deprecated.html index 1ac163a83..ad6dd2709 100644 --- a/doc/html/deprecated.html +++ b/doc/html/deprecated.html @@ -4,7 +4,7 @@
- +NATS Callbacks.
This is the callback that one provides when creating an asynchronous subscription. The library will invoke this callback for each message arriving through the subscription's connection.
-This callback is used for asynchronous events such as disconnected and closed connections.
-userData | the pointer to an user object created in natsEvLoop_Attach. |
userData | the pointer to an user object created in natsEvLoop_Attach. |
add | true if the event library should start polling, false otherwise. |
userData | the pointer to an user object created in natsEvLoop_Attach. |
userData | the pointer to an user object created in natsEvLoop_Attach. |
add | true if the event library should start polling, false otherwise. |
userData | the pointer to an user object created in natsEvLoop_Attach. |
userData | the pointer to an user object created in natsEvLoop_Attach. |
This is the function that one provides to build a different token at each reconnect.
-Currently used for asynchronous natsSubscription objects. When set, this callback will be invoked after the subscription is closed and the message handler has returned.
- +Currently used for asynchronous natsSubscription objects. When set, this callback will be invoked after the subscription is closed and the message handler has returned.
+This callback is used to get from the user the desired delay the library should pause before attempting to reconnect again. Note that this is invoked after the library tried the whole list of URLs and failed to reconnect.
-nc | the pointer to the natsConnection invoking this handler. |
nc | the pointer to the natsConnection invoking this handler. |
attempts | the number of times the library tried the whole list of server URLs. |
closure | an optional pointer to a user defined object that was specified when registering the callback. |
This is used for asynchronous publishing to provide status of the acknowledgment. The function will be passed the GUID and any error state. No error means the message was successfully received by NATS Streaming.
-This is the callback that one provides when creating an asynchronous subscription. The library will invoke this callback for each message arriving through the subscription's connection.
-
NATS C Client with Streaming support
- 2.5.1
+ 2.6.0
The nats.io C Client, Supported by Synadia Communications Inc.
|
@@ -42,34 +35,22 @@
NATS Server
using the provided options. More...NATS Server
using the provided options. More...NATS Server
using any of the URL from the given list. More...NATS Server
using any of the URL from the given list. More...Functions related to connection management.
Attempts to connect to a NATS Server
with multiple options.
This call is cloning the natsOptions object. Once this call returns, changes made to the options
will not have an effect to this connection. The options
can however be changed prior to be passed to another natsConnection_Connect() call if desired.
This call is cloning the natsOptions object. Once this call returns, changes made to the options
will not have an effect to this connection. The options
can however be changed prior to be passed to another natsConnection_Connect() call if desired.
nc | the location where to store the pointer to the newly created natsConnection object. |
options | the options to use for this connection. If NULL this call is equivalent to natsConnection_ConnectTo() with NATS_DEFAULT_URL. |
nc | the location where to store the pointer to the newly created natsConnection object. |
options | the options to use for this connection. If NULL this call is equivalent to natsConnection_ConnectTo() with NATS_DEFAULT_URL. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
Attempts to connect to a NATS Server
.
This call supports multiple comma separated URLs. If more than one is specified, it behaves as if you were using a natsOptions object and called natsOptions_SetServers() with the equivalent array of URLs. The list is randomized before the connect sequence starts.
-This call supports multiple comma separated URLs. If more than one is specified, it behaves as if you were using a natsOptions object and called natsOptions_SetServers() with the equivalent array of URLs. The list is randomized before the connect sequence starts.
+ +natsOptions_SetServers()nc | the location where to store the pointer to the newly created natsConnection object. |
urls | the URL to connect to, or the list of URLs to chose from. If NULL this call is equivalent to natsConnection_ConnectTo() with NATS_DEFAULT_URL |
nc | the location where to store the pointer to the newly created natsConnection object. |
urls | the URL to connect to, or the list of URLs to chose from. If NULL this call is equivalent to natsConnection_ConnectTo() with NATS_DEFAULT_URL |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
Returns the current state of the connection.
-nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
Performs a round trip to the server and return when it receives the internal reply, or if the call times-out (timeout is expressed in milliseconds).
-See possible failure case described in natsConnection_Flush().
+See possible failure case described in natsConnection_Flush().
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
timeout | in milliseconds, is the time allowed for the flush to complete before NATS_TIMEOUT error is returned. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
stats | the pointer to a natsStatistics object in which statistics will be copied. |
nc | the pointer to the natsConnection object. |
stats | the pointer to a natsStatistics object in which statistics will be copied. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
buffer | the buffer in which the URL is copied. |
bufferSize | the size of the buffer. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
buffer | the buffer in which the server id is copied. |
bufferSize | the size of the buffer. |
Returns the list of known servers, including additional servers discovered after a connection has been established (with servers version 0.9.2 and above).
-No credential information is included in any of the server URLs returned by this call.
- If you want to use any of these URLs to connect to a server that requires authentication, you will need to use natsOptions_SetUserInfo or natsOptions_SetToken.
No credential information is included in any of the server URLs returned by this call.
+ If you want to use any of these URLs to connect to a server that requires authentication, you will need to use natsOptions_SetUserInfo or natsOptions_SetToken.
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
servers | the location where to store the pointer to the array of server URLs. |
count | the location where to store the number of elements of the returned array. |
Unlike natsConnection_GetServers, this function only returns the list of servers that have been discovered after the a connection has been established (with servers version 0.9.2 and above).
-No credential information is included in any of the server URLs returned by this call.
- If you want to use any of these URLs to connect to a server that requires authentication, you will need to use natsOptions_SetUserInfo or natsOptions_SetToken.
Unlike natsConnection_GetServers, this function only returns the list of servers that have been discovered after the a connection has been established (with servers version 0.9.2 and above).
+No credential information is included in any of the server URLs returned by this call.
+ If you want to use any of these URLs to connect to a server that requires authentication, you will need to use natsOptions_SetUserInfo or natsOptions_SetToken.
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
servers | the location where to store the pointer to the array of server URLs. |
count | the location where to store the number of elements of the returned array. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
lastError | the location where the pointer to the connection's last error string is copied. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
cid | the location where to store the client ID. |
Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the natsOptions_SetClosedCB() option to know when the connection has moved from draining to closed.
+Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the natsOptions_SetClosedCB() option to know when the connection has moved from draining to closed.
This call uses a default drain timeout of 30 seconds.
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
Identical to natsConnection_Drain but the timeout can be specified here.
+Identical to natsConnection_Drain but the timeout can be specified here.
The value is expressed in milliseconds. Zero or negative value means that the operation will not timeout.
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
timeout | the allowed time for a drain operation to complete, expressed in milliseconds. |
The connection must have been created with the natsOptions_SetUserCredentialsFromFiles.
+The connection must have been created with the natsOptions_SetUserCredentialsFromFiles.
This call will sign the given message with the private key extracted through the user credentials file(s).
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
message | the byte array to sign. |
messageLen | the length of the given byte array. |
sig | an array of 64 bytes in which the signature will be copied. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
ip | the memory location where to store the client's IP string. The user is responsible from freeing this memory. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
rtt | the memory location where to store the rtt. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
Unlike natsConnection_GetClientIP, this function returns the connection's local IP and port.
+Unlike natsConnection_GetClientIP, this function returns the connection's local IP and port.
nc | the pointer of the natsConnection object. |
nc | the pointer of the natsConnection object. |
ip | the memory location where to store the local IP string. The user is responsible from freeing this memory. |
port | the memory location where to store the local port. |
Closes the connection to the server. This call will release all blocking calls, such as natsConnection_Flush() and natsSubscription_NextMsg(). The connection object is still usable until the call to natsConnection_Destroy().
+Closes the connection to the server. This call will release all blocking calls, such as natsConnection_Flush() and natsSubscription_NextMsg(). The connection object is still usable until the call to natsConnection_Destroy().
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
requestMsg
and waits for a reply. More...requestMsg
and waits for a reply. More...Publishing functions
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
subj | the subject the data is sent to. |
data | the data to be sent, can be NULL . |
dataLen | the length of the data to be sent. |
Convenient function to publish a string. This call is equivalent to:
-nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
subj | the subject the data is sent to. |
str | the string to be sent. |
Publishes the natsMsg, which includes the subject, an optional reply and optional data.
-Publishes the natsMsg, which includes the subject, an optional reply and optional data.
+nc | the pointer to the natsConnection object. |
msg | the pointer to the natsMsg object to send. |
nc | the pointer to the natsConnection object. |
msg | the pointer to the natsMsg object to send. |
Publishes the data argument to the given subject expecting a response on the reply subject. Use natsConnection_Request() for automatically waiting for a response inline.
+Publishes the data argument to the given subject expecting a response on the reply subject. Use natsConnection_Request() for automatically waiting for a response inline.
nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
subj | the subject the request is sent to. |
reply | the reply on which resonses are expected. |
data | the data to be sent, can be NULL . |
Convenient function to publish a request as a string. This call is equivalent to:
-nc | the pointer to the natsConnection object. |
nc | the pointer to the natsConnection object. |
subj | the subject the request is sent to. |
reply | the reply on which resonses are expected. |
str | the string to send. |
Sends a request payload and delivers the first response message, or an error, including a timeout if no message was received properly.
-replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
subj | the subject the request is sent to. |
data | the data of the request, can be NULL . |
dataLen | the length of the data to send. |
Convenient function to send a request as a string. This call is equivalent to:
-replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
subj | the subject the request is sent to. |
str | the string to send. |
timeout | in milliseconds, before this call returns NATS_TIMEOUT if no response is received in this alloted time. |
Similar to natsConnection_Request but uses requestMsg
to extract subject, and payload to send.
Similar to natsConnection_Request but uses requestMsg
to extract subject, and payload to send.
replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
replyMsg | the location where to store the pointer to the received natsMsg reply. |
nc | the pointer to the natsConnection object. |
requestMsg | the message used for the request. |
timeout | in milliseconds, before this call returns NATS_TIMEOUT if no response is received in this alloted time. |
Subscribing functions.
Expresses interest in the given subject. The subject can have wildcards (see Wildcards). Messages will be delivered to the associated natsMsgHandler.
+Expresses interest in the given subject. The subject can have wildcards (see Wildcards). Messages will be delivered to the associated natsMsgHandler.
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
Expresses interest in the given subject. The subject can have wildcards (see Wildcards). Messages will be delivered to the associated natsMsgHandler.
-If no message is received by the given timeout (in milliseconds), the message handler is invoked with a NULL
message.
+
Expresses interest in the given subject. The subject can have wildcards (see Wildcards). Messages will be delivered to the associated natsMsgHandler.
+If no message is received by the given timeout (in milliseconds), the message handler is invoked with a NULL
message.
You can then destroy the subscription in the callback, or simply return, in which case, the message handler will fire again when a message is received or the subscription times-out again.
NULL
.sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
timeout | the interval (in milliseconds) after which, if no message is received, the message handler is invoked with a NULL message. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
Similar to natsConnection_Subscribe, but creates a synchronous subscription that can be polled via natsSubscription_NextMsg().
+Similar to natsConnection_Subscribe, but creates a synchronous subscription that can be polled via natsSubscription_NextMsg().
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
queueGroup | the name of the group. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
Creates an asynchronous queue subscriber on the given subject. All subscribers with the same queue name will form the queue group and only one member of the group will be selected to receive any given message asynchronously.
-If no message is received by the given timeout (in milliseconds), the message handler is invoked with a NULL
message.
+
If no message is received by the given timeout (in milliseconds), the message handler is invoked with a NULL
message.
You can then destroy the subscription in the callback, or simply return, in which case, the message handler will fire again when a message is received or the subscription times-out again.
NULL
.sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
queueGroup | the name of the group. |
timeout | the interval (in milliseconds) after which, if no message is received, the message handler is invoked with a NULL message. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
cb | the natsMsgHandler callback. |
cbClosure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
Similar to natsConnection_QueueSubscribe, but creates a synchronous subscription that can be polled via natsSubscription_NextMsg().
+Similar to natsConnection_QueueSubscribe, but creates a synchronous subscription that can be polled via natsSubscription_NextMsg().
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
sub | the location where to store the pointer to the newly created natsSubscription object. |
nc | the pointer to the natsConnection object. |
subject | the subject this subscription is created for. |
queueGroup | the name of the group. |
You will find here the environment variables that change the default behavior of the NATS C Client library.
-
-
Name | Effect |
---|---|
NATS_DEFAULT_TO_LIB_MSG_DELIVERY | On nats_Open, the library looks for this environment variable. If set (to any value), the library will default to using a global thread pool to perform message delivery. See natsOptions_UseGlobalMessageDelivery and nats_SetMessageDeliveryPoolSize. |
Name | Effect |
---|---|
NATS_DEFAULT_TO_LIB_MSG_DELIVERY | On nats_Open, the library looks for this environment variable. If set (to any value), the library will default to using a global thread pool to perform message delivery. See natsOptions_UseGlobalMessageDelivery and nats_SetMessageDeliveryPoolSize. |
NATS Inboxes.
inbox | the pointer to the natsInbox object to destroy. |
inbox | the pointer to the natsInbox object to destroy. |
Adapter to plug a NATS
connection to a libevent
event loop.
userData | the user object created in natsLibevent_Attach |
userData | the user object created in natsLibevent_Attach |
add | true if the library needs to start polling, false otherwise. |
userData | the user object created in natsLibevent_Attach |
userData | the user object created in natsLibevent_Attach |
add | true if the library needs to start polling, false otherwise. |
userData | the user object created in natsLibevent_Attach |
userData | the user object created in natsLibevent_Attach |
Library and helper functions.
lockSpinCount | The number of times the library will spin trying to lock a mutex object. |
Returns the calling thread's last known error. This can be useful when natsConnection_Connect fails. Since no connection object is returned, you would not be able to call natsConnection_GetLastError.
+Returns the calling thread's last known error. This can be useful when natsConnection_Connect fails. Since no connection object is returned, you would not be able to call natsConnection_GetLastError.
status | if not NULL , this function will store the last error status in there. |
Copies the calling thread's last known error stack into the provided buffer. If the buffer is not big enough, NATS_INSUFFICIENT_BUFFER is returned.
+Copies the calling thread's last known error stack into the provided buffer. If the buffer is not big enough, NATS_INSUFFICIENT_BUFFER is returned.
buffer | the buffer into the stack is copied. |
file | the file the stack is printed to. |
Normally, each asynchronous subscriber that is created has its own message delivery thread. The advantage is that it reduces lock contentions, therefore improving performance.
+
Normally, each asynchronous subscriber that is created has its own message delivery thread. The advantage is that it reduces lock contentions, therefore improving performance.
However, if an application creates many subscribers, this is not scaling well since the process would use too many threads.
The library has a thread pool that can perform message delivery. If a connection is created with the proper option set (natsOptions_UseGlobalMessageDelivery), then this thread pool will be responsible for delivering the messages. The thread pool is lazily initialized, that is, no thread is used as long as no subscriber (requiring global message delivery) is created.
+The library has a thread pool that can perform message delivery. If a connection is created with the proper option set (natsOptions_UseGlobalMessageDelivery), then this thread pool will be responsible for delivering the messages. The thread pool is lazily initialized, that is, no thread is used as long as no subscriber (requiring global message delivery) is created.
Each subscriber will be attached to a given worker on the pool so that message delivery order is guaranteed.
This call allows you to set the maximum size of the pool.
This needs to be called on user-created threads where NATS calls are performed. This does not need to be called in threads created by the library. For instance, do not call this function in the message handler that you specify when creating a subscription.
-Also, you do not need to call this in an user thread (or the main) if you are calling nats_Close() there.
+Also, you do not need to call this in an user thread (or the main) if you are calling nats_Close() there.
encodedSeed | the string encoded private key, also known as seed. |
Similar to nats_Close() except that this call will make sure that all references to the library are decremented before returning (up to the given timeout). Internal threads (such as subscriptions dispatchers, etc..) hold a reference to the library. Only when all references have been released that this call will return. It means that you must call all the "destroy" calls before calling this function, otherwise it will block forever (or up to given timeout).
-For instance, this code would "deadlock":
But this would work as expected:
The library and other objects (such as connections, subscriptions, etc) use internal threads. After the destroy call, it is possible or even likely that some threads are still running, holding references to the library. Unlike nats_Close(), which will simply ensure that the library is ultimately releasing memory, the nats_CloseAndWait() API will ensure that all those internal threads have unrolled and that the memory used by the library is released before returning.
-Similar to nats_Close() except that this call will make sure that all references to the library are decremented before returning (up to the given timeout). Internal threads (such as subscriptions dispatchers, etc..) hold a reference to the library. Only when all references have been released that this call will return. It means that you must call all the "destroy" calls before calling this function, otherwise it will block forever (or up to given timeout).
+For instance, this code would "deadlock":
But this would work as expected:
The library and other objects (such as connections, subscriptions, etc) use internal threads. After the destroy call, it is possible or even likely that some threads are still running, holding references to the library. Unlike nats_Close(), which will simply ensure that the library is ultimately releasing memory, the nats_CloseAndWait() API will ensure that all those internal threads have unrolled and that the memory used by the library is released before returning.
+timeout | the maximum time to wait for the library to be closed. If negative or 0, waits for as long as needed. |
NATS C Client with Streaming support
- 2.5.1
+ 2.6.0
The nats.io C Client, Supported by Synadia Communications Inc.
|
@@ -42,34 +35,22 @@
uv_run()
. More...uv_run()
. More...Adapter to plug a NATS
connection to a libuv
event loop.
userData | the user object created in natsLibuv_Attach |
userData | the user object created in natsLibuv_Attach |
add | true if the library needs to start polling, false otherwise. |
userData | the user object created in natsLibuv_Attach |
userData | the user object created in natsLibuv_Attach |
add | true if the library needs to start polling, false otherwise. |
userData | the user object created in natsLibuv_Attach |
userData | the user object created in natsLibuv_Attach |
key
to the single element value
. More...key
to the single element value
. More...value
to the header associated with key
. More...value
to the header associated with key
. More...key
. More...key
. More...key
. More...key
. More...key
. More...key
. More...NATS Message.
Creates a natsMsg object. This is used by the subscription related calls and by natsConnection_PublishMsg().
-Creates a natsMsg object. This is used by the subscription related calls and by natsConnection_PublishMsg().
+newMsg | the location where to store the pointer to the newly created natsMsg object. |
newMsg | the location where to store the pointer to the newly created natsMsg object. |
subj | the subject this message will be sent to. Cannot be NULL . |
reply | the optional reply for this message. |
data | the optional message payload. |
Returns the message payload, possibly NULL
.
Note that although the data sent and received from the server is not NULL
terminated, the NATS C Client does add a NULL
byte to the received payload. If you expect the received data to be a "string", then this conveniently allows you to call natsMsg_GetData() without having to copy the returned data to a buffer to add the NULL
byte at the end.
Note that although the data sent and received from the server is not NULL
terminated, the NATS C Client does add a NULL
byte to the received payload. If you expect the received data to be a "string", then this conveniently allows you to call natsMsg_GetData() without having to copy the returned data to a buffer to add the NULL
byte at the end.
msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
key | the key under which the value will be stored. It can't ne NULL or empty. |
value | the string to store under the given key . The value can be NULL or empty string. |
msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
key | the key under which the value will be stored. It can't ne NULL or empty. |
value | the string to add to the values associated with the given key . The value can be NULL or empty string. |
msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
key | the key for which the value is requested. |
value | the memory location where the library will store the pointer to the first value (if more than one is found) associated with the key . |
The returned strings are own by the library and MUST not be freed or altered. However, the returned array values
MUST be freed by the user.
key
will be store as its canonical form, that is, the key "my-key" is stored as "My-Key".key
will be store as its canonical form, that is, the key "my-key" is stored as "My-Key".natsMsg
may possible be altered during this call.msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
key | the key for which the values are requested. |
values | the memory location where the library will store the pointer to the array of values. |
count | the memory location where the library will store the number of values returned. |
The returned strings are own by the library and MUST not be freed or altered. However, the returned array keys
MUST be freed by the user.
natsMsg
may possible be altered during this call.natsMsg
may possible be altered during this call.msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
keys | the memory location where the library will store the pointer to the array of keys. |
count | the memory location where the library will store the number of keys returned. |
msg | the pointer to the natsMsg object. |
msg | the pointer to the natsMsg object. |
key | the key to delete from the headers map. |
Starting with the NATS Server v2.2.0+ and the C client v2.2.0+ releases, which introduced support for message headers and the "no responders" feature, if a request is received by the server and there are no subscriptions on the request's subject, the server sends a message with no payload but with a header "Status" with value "503".
-The call natsConnection_Request() and its variants intercept this special message and instead of returning it to the user, they return NATS_NO_RESPONDERS.
-If a synchronous subscription is created on a subject used as a reply subject to a natsConnection_PublishRequest call (and its variants), natsSubscription_NextMsg also detects this message and returns NATS_NO_RESPONDERS (but it was not from release v2.2.0 to v2.4.1).
+The call natsConnection_Request() and its variants intercept this special message and instead of returning it to the user, they return NATS_NO_RESPONDERS.
+If a synchronous subscription is created on a subject used as a reply subject to a natsConnection_PublishRequest call (and its variants), natsSubscription_NextMsg also detects this message and returns NATS_NO_RESPONDERS (but it was not from release v2.2.0 to v2.4.1).
For asynchronous subscriptions, the user may want to know that the request failed because there are no responders. For that reason, the message is passed to the message callback, and this function can be used to detect that this is a "no responders" message from the server and act accordingly.
@@ -592,7 +624,9 @@msg | the pointer to the natsMsg object to destroy. |
msg | the pointer to the natsMsg object to destroy. |
PING
s without corresponding PONG
s. More...PING
s without corresponding PONG
s. More...NATS Options.
Creates a natsOptions object. This object is used when one wants to set specific options prior to connecting to the NATS Server
.
After making the appropriate natsOptions_Set calls, this object is passed to the natsConnection_Connect() call, which will clone this object. After natsConnection_Connect() returns, modifications to the options object will not affect the connection.
+Creates a natsOptions object. This object is used when one wants to set specific options prior to connecting to the NATS Server
.
After making the appropriate natsOptions_Set calls, this object is passed to the natsConnection_Connect() call, which will clone this object. After natsConnection_Connect() returns, modifications to the options object will not affect the connection.
newOpts | the location where store the pointer to the newly created natsOptions object. |
newOpts | the location where store the pointer to the newly created natsOptions object. |
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
url | the string representing the URL the connection should use to connect to the server. |
This specifies a list of servers to try to connect (or reconnect) to. Note that if you call natsOptions_SetURL() too, the actual list will contain the one from natsOptions_SetURL() and the ones specified in this call.
-This specifies a list of servers to try to connect (or reconnect) to. Note that if you call natsOptions_SetURL() too, the actual list will contain the one from natsOptions_SetURL() and the ones specified in this call.
+ +natsOptions_SetTokenopts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
servers | the array of strings representing the server URLs. |
serversCount | the size of the array. |
Credentials are usually provided through the URL in the form: nats://foo:bar@localhost:4222
.
- Until now, you could specify URLs in two ways, with natsOptions_SetServers or natsConnection_ConnectTo. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate credentials in the URLs.
-
- However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded credentials.
- You need to use this function (or natsOptions_SetToken) to instruct the client library to use those credentials when connecting to a server that requires authentication and for which there is no embedded credentials in the URL.
Credentials are usually provided through the URL in the form: nats://foo:bar@localhost:4222
.
+ Until now, you could specify URLs in two ways, with natsOptions_SetServers or natsConnection_ConnectTo. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate credentials in the URLs.
+
+ However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded credentials.
+ You need to use this function (or natsOptions_SetToken) to instruct the client library to use those credentials when connecting to a server that requires authentication and for which there is no embedded credentials in the URL.
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
user | the user name to send to the server during connect. |
password | the password to send to the server during connect. |
Tokens are usually provided through the URL in the form: nats://mytoken@localhost:4222
.
- Until now, you could specify URLs in two ways, with natsOptions_SetServers or natsConnection_ConnectTo. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate token in the URLs.
-
- However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded tokens.
- You need to use this function (or natsOptions_SetUserInfo) to instruct the client library to use this token when connecting to a server that requires authentication and for which there is no embedded token in the URL.
Tokens are usually provided through the URL in the form: nats://mytoken@localhost:4222
.
+ Until now, you could specify URLs in two ways, with natsOptions_SetServers or natsConnection_ConnectTo. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate token in the URLs.
+
+ However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded tokens.
+ You need to use this function (or natsOptions_SetUserInfo) to instruct the client library to use this token when connecting to a server that requires authentication and for which there is no embedded token in the URL.
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
token | the token to send to the server during connect. |
For use cases where setting a static token through the URL
- or through natsOptions_SetToken is not desirable.
-
- This function can be used to generate a token whenever the client needs one.
+
For use cases where setting a static token through the URL
+ or through natsOptions_SetToken is not desirable.
+
+ This function can be used to generate a token whenever the client needs one.
Some example of use cases: expiring token, credential rotation, ...
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
tokenCb | the tokenCb to use to generate a token to the server during connect. |
closure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
closure | a pointer to an user defined object (can be NULL ). See the natsMsgHandler prototype. |
If 'noRandomize' is true, then the list of server URLs is used in the order provided by natsOptions_SetURL() + natsOptions_SetServers(). Otherwise, the list is formed in a random order.
+If 'noRandomize' is true, then the list of server URLs is used in the order provided by natsOptions_SetURL() + natsOptions_SetServers(). Otherwise, the list is formed in a random order.
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
noRandomize | if true , the list will be used as-is. |
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
timeout | the time, in milliseconds, allowed for an individual connect (or reconnect) to complete. |
opts | the pointer to the natsOptions object. |
opts | the pointer to the natsOptions object. |
name | the name to set. |