NATS C Client with JetStream and Streaming support
3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
|
Typedefs | |
typedef void(* | natsMsgHandler) (natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure) |
Callback used to deliver messages to the application. More... | |
typedef void(* | natsConnectionHandler) (natsConnection *nc, void *closure) |
Callback used to notify the user of asynchronous connection events. More... | |
typedef void(* | natsErrHandler) (natsConnection *nc, natsSubscription *subscription, natsStatus err, void *closure) |
Callback used to notify the user of errors encountered while processing inbound messages. More... | |
typedef natsStatus(* | natsEvLoop_Attach) (void **userData, void *loop, natsConnection *nc, natsSock socket) |
Attach this connection to the external event loop. More... | |
typedef natsStatus(* | natsEvLoop_ReadAddRemove) (void *userData, bool add) |
Read event needs to be added or removed. More... | |
typedef natsStatus(* | natsEvLoop_WriteAddRemove) (void *userData, bool add) |
Write event needs to be added or removed. More... | |
typedef natsStatus(* | natsEvLoop_Detach) (void *userData) |
Detach from the event loop. More... | |
typedef natsStatus(* | natsUserJWTHandler) (char **userJWT, char **customErrTxt, void *closure) |
Callback used to fetch and return account signed user JWT. More... | |
typedef natsStatus(* | natsSignatureHandler) (char **customErrTxt, unsigned char **signature, int *signatureLength, const char *nonce, void *closure) |
Callback used to sign a nonce sent by the server. More... | |
typedef const char *(* | natsTokenHandler) (void *closure) |
Callback used to build a token on connections and reconnections. More... | |
typedef void(* | natsOnCompleteCB) (void *closure) |
Callback used to notify that an object lifecycle is complete. More... | |
typedef int64_t(* | natsCustomReconnectDelayHandler) (natsConnection *nc, int attempts, void *closure) |
Callback used to specify how long to wait between reconnects. More... | |
typedef void(* | jsPubAckErrHandler) (jsCtx *js, jsPubAckErr *pae, void *closure) |
Callback used to process asynchronous publish errors from JetStream. More... | |
typedef void(* | jsPubAckHandler) (jsCtx *js, natsMsg *msg, jsPubAck *pa, jsPubAckErr *pae, void *closure) |
Callback used to process asynchronous publish responses from JetStream. More... | |
typedef void(* | stanPubAckHandler) (const char *guid, const char *error, void *closure) |
Callback used to notify of an asynchronous publish result. More... | |
typedef void(* | stanMsgHandler) (stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure) |
Callback used to deliver messages to the application. More... | |
typedef void(* | stanConnectionLostHandler) (stanConnection *sc, const char *errorTxt, void *closure) |
Callback used to notify the user of the permanent loss of the connection. More... | |
NATS Callbacks.
typedef void(* natsMsgHandler) (natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure) |
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.
typedef void(* natsConnectionHandler) (natsConnection *nc, void *closure) |
This callback is used for asynchronous events such as disconnected and closed connections.
typedef void(* natsErrHandler) (natsConnection *nc, natsSubscription *subscription, natsStatus err, void *closure) |
This callback is used to process asynchronous errors encountered while processing inbound messages, such as NATS_SLOW_CONSUMER.
typedef natsStatus(* natsEvLoop_Attach) (void **userData, void *loop, natsConnection *nc, natsSock socket) |
After a connection has (re)connected, this callback is invoked. It should perform the necessary work to start polling the given socket for READ events.
userData | location where the adapter implementation will store the object it created and that will later be passed to all other callbacks. If *userData is not NULL , this means that this is a reconnect event. |
loop | the event loop (as a generic void*) this connection is being attached to. |
nc | the connection being attached to the event loop. |
socket | the socket to poll for read/write events. |
typedef natsStatus(* natsEvLoop_ReadAddRemove) (void *userData, bool add) |
The NATS
library will invoke this callback to indicate if the event loop should start (add is
true) or stop (
addis
false`) polling for read events on the socket.
userData | the pointer to an user object created in natsEvLoop_Attach. |
add | true if the event library should start polling, false otherwise. |
typedef natsStatus(* natsEvLoop_WriteAddRemove) (void *userData, bool add) |
The NATS
library will invoke this callback to indicate if the event loop should start (add is
true) or stop (
addis
false`) polling for write events on the socket.
userData | the pointer to an user object created in natsEvLoop_Attach. |
add | true if the event library should start polling, false otherwise. |
typedef natsStatus(* natsEvLoop_Detach) (void *userData) |
The NATS
library will invoke this callback to indicate that the connection no longer needs to be attached to the event loop. User can cleanup some state.
userData | the pointer to an user object created in natsEvLoop_Attach. |
typedef natsStatus(* natsUserJWTHandler) (char **userJWT, char **customErrTxt, void *closure) |
This handler is invoked when connecting and reconnecting. It should return the user JWT that will be sent to the server.
The user JWT is returned as a string that is allocated by the user and is freed by the library after the handler is invoked.
If the user is unable to return the JWT, a status other than NATS_OK
should be returned (we recommend NATS_ERR
). A custom error message can be returned through customErrTxt
. The user must allocate the memory for this error message and the library will free it after the invocation of the handler.
userJWT
after each invocation of this handler.typedef natsStatus(* natsSignatureHandler) (char **customErrTxt, unsigned char **signature, int *signatureLength, const char *nonce, void *closure) |
This handler is invoked when connecting and reconnecting. It should sign the given nonce
and return a raw signature through signature
and specify how many characters the signature has using signatureLength
.
The memory pointed by signature
must be allocated by the user and will be freed by the library after each invocation of this handler.
If the user is unable to sign, a status other than NATS_OK
(we recommend NATS_ERR
) should be returned. A custom error message can be returned through customErrTxt
. The user must allocate the memory for this error message and the library will free it after the invocation of this handler.
The library will base64 encode this raw signature and send that to the server.
signature
after each invocation of this handler.typedef const char*(* natsTokenHandler) (void *closure) |
This is the function that one provides to build a different token at each reconnect.
typedef void(* natsOnCompleteCB) (void *closure) |
Currently used for asynchronous natsSubscription objects. When set, this callback will be invoked after the subscription is closed and the message handler has returned.
typedef int64_t(* natsCustomReconnectDelayHandler) (natsConnection *nc, int attempts, void *closure) |
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. |
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. |
typedef void(* jsPubAckErrHandler) (jsCtx *js, jsPubAckErr *pae, void *closure) |
Callback used to process asynchronous publish errors from JetStream js_PublishAsync and js_PublishMsgAsync calls. The provided jsPubAckErr object gives the user access to the encountered error along with the original message sent to the server for possible restransmitting.
Msg
field from the jsPubAckErr object).js | the pointer to the jsCtx object. |
pae | the pointer to the jsPubAckErr object. |
closure | an optional pointer to a user defined object that was specified when registering the callback. |
typedef void(* jsPubAckHandler) (jsCtx *js, natsMsg *msg, jsPubAck *pa, jsPubAckErr *pae, void *closure) |
Callback used to process asynchronous publish responses (positive and negatives) from JetStream js_PublishAsync and js_PublishMsgAsync calls. The provided jsPubAck or jsPubAckErr objects give the user access to the successful acknowledgment from the server or the encountered error along with the original message sent to the server for possible restransmitting.
NULL
. So it is recommended to always call natsMsg_Destroy at the end of the function.js | the pointer to the jsCtx object. |
msg | the pointer to the original published natsMsg. |
pa | the pointer to the jsPubAck object. |
pae | the pointer to the jsPubAckErr object. |
closure | an optional pointer to a user defined object that was specified when registering the callback. |
typedef void(* stanPubAckHandler) (const char *guid, const char *error, void *closure) |
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.
typedef void(* stanMsgHandler) (stanConnection *sc, stanSubscription *sub, const char *channel, stanMsg *msg, void *closure) |
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.
typedef void(* stanConnectionLostHandler) (stanConnection *sc, const char *errorTxt, void *closure) |
This callback is used to notify the user that the connection to the Streaming server is permanently lost.