NATS C Client with JetStream and Streaming support
3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
|
Functions | |
NATS_EXTERN natsStatus | jsStreamConfig_Init (jsStreamConfig *cfg) |
Initializes a streaming configuration structure. More... | |
NATS_EXTERN natsStatus | jsPlacement_Init (jsPlacement *placement) |
Initializes a placement configuration structure. More... | |
NATS_EXTERN natsStatus | jsStreamSource_Init (jsStreamSource *source) |
Initializes a stream source configuration structure. More... | |
NATS_EXTERN natsStatus | jsExternalStream_Init (jsExternalStream *external) |
Initializes an external stream configuration structure. More... | |
NATS_EXTERN natsStatus | jsRePublish_Init (jsRePublish *rp) |
Initializes a republish structure. More... | |
NATS_EXTERN natsStatus | js_AddStream (jsStreamInfo **si, jsCtx *js, jsStreamConfig *cfg, jsOptions *opts, jsErrCode *errCode) |
Creates a stream. More... | |
NATS_EXTERN natsStatus | js_UpdateStream (jsStreamInfo **si, jsCtx *js, jsStreamConfig *cfg, jsOptions *opts, jsErrCode *errCode) |
Updates a stream. More... | |
NATS_EXTERN natsStatus | js_PurgeStream (jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode) |
Purges a stream. More... | |
NATS_EXTERN natsStatus | js_DeleteStream (jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode) |
Deletes a stream. More... | |
NATS_EXTERN natsStatus | js_GetMsg (natsMsg **msg, jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode) |
Retrieves a JetStream message from the stream by sequence. More... | |
NATS_EXTERN natsStatus | js_GetLastMsg (natsMsg **msg, jsCtx *js, const char *stream, const char *subject, jsOptions *opts, jsErrCode *errCode) |
Retrieves the last JetStream message from the stream for a given subject. More... | |
NATS_EXTERN natsStatus | jsDirectGetMsgOptions_Init (jsDirectGetMsgOptions *opts) |
Initializes a direct get message options structure. More... | |
NATS_EXTERN natsStatus | js_DirectGetMsg (natsMsg **msg, jsCtx *js, const char *stream, jsOptions *opts, jsDirectGetMsgOptions *dgOpts) |
Retrieves directly a JetStream message based on provided options. More... | |
NATS_EXTERN natsStatus | js_DeleteMsg (jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode) |
Deletes a message from the stream. More... | |
NATS_EXTERN natsStatus | js_EraseMsg (jsCtx *js, const char *stream, uint64_t seq, jsOptions *opts, jsErrCode *errCode) |
Erases a message from the stream. More... | |
NATS_EXTERN natsStatus | js_GetStreamInfo (jsStreamInfo **si, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode) |
Retreives information from a stream. More... | |
NATS_EXTERN void | jsStreamInfo_Destroy (jsStreamInfo *si) |
Destroys the stream information object. More... | |
NATS_EXTERN natsStatus | js_Streams (jsStreamInfoList **list, jsCtx *js, jsOptions *opts, jsErrCode *errCode) |
Retrieves the list of all available streams. More... | |
NATS_EXTERN void | jsStreamInfoList_Destroy (jsStreamInfoList *list) |
Destroys the stream information list object. More... | |
NATS_EXTERN natsStatus | js_StreamNames (jsStreamNamesList **list, jsCtx *js, jsOptions *opts, jsErrCode *errCode) |
Retrieves the list of all available stream names. More... | |
NATS_EXTERN void | jsStreamNamesList_Destroy (jsStreamNamesList *list) |
Destroys the stream names list object. More... | |
NATS_EXTERN natsStatus | jsConsumerConfig_Init (jsConsumerConfig *cc) |
Initializes a consumer configuration structure. More... | |
NATS_EXTERN natsStatus | js_AddConsumer (jsConsumerInfo **ci, jsCtx *js, const char *stream, jsConsumerConfig *cfg, jsOptions *opts, jsErrCode *errCode) |
Adds a JetStream consumer. More... | |
NATS_EXTERN natsStatus | js_UpdateConsumer (jsConsumerInfo **ci, jsCtx *js, const char *stream, jsConsumerConfig *cfg, jsOptions *opts, jsErrCode *errCode) |
Updates a JetStream consumer. More... | |
NATS_EXTERN natsStatus | js_GetConsumerInfo (jsConsumerInfo **ci, jsCtx *js, const char *stream, const char *consumer, jsOptions *opts, jsErrCode *errCode) |
Retrieves information about a consumer. More... | |
NATS_EXTERN natsStatus | js_DeleteConsumer (jsCtx *js, const char *stream, const char *consumer, jsOptions *opts, jsErrCode *errCode) |
Deletes a consumer. More... | |
NATS_EXTERN natsStatus | js_PauseConsumer (jsConsumerPauseResponse **new_cpr, jsCtx *js, const char *stream, const char *consumer, uint64_t pauseUntil, jsOptions *opts, jsErrCode *errCode) |
Pauses a consumer. More... | |
NATS_EXTERN void | jsConsumerPauseResponse_Destroy (jsConsumerPauseResponse *cpr) |
Destroys the PauseConsumer response object. More... | |
NATS_EXTERN void | jsConsumerInfo_Destroy (jsConsumerInfo *ci) |
Destroys the consumer information object. More... | |
NATS_EXTERN natsStatus | js_Consumers (jsConsumerInfoList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode) |
Retrieves the list of all available consumers for a stream. More... | |
NATS_EXTERN void | jsConsumerInfoList_Destroy (jsConsumerInfoList *list) |
Destroys the consumer information list object. More... | |
NATS_EXTERN natsStatus | js_ConsumerNames (jsConsumerNamesList **list, jsCtx *js, const char *stream, jsOptions *opts, jsErrCode *errCode) |
Retrieves the list of all available consumer names for a stream. More... | |
NATS_EXTERN void | jsConsumerNamesList_Destroy (jsConsumerNamesList *list) |
Destroys the consumer names list object. More... | |
NATS_EXTERN natsStatus | js_GetAccountInfo (jsAccountInfo **ai, jsCtx *js, jsOptions *opts, jsErrCode *errCode) |
Retrieves information about the JetStream usage from an account. More... | |
NATS_EXTERN void | jsAccountInfo_Destroy (jsAccountInfo *ai) |
Destroys the account information object. More... | |
JetStream Assets Management
NATS_EXTERN natsStatus jsStreamConfig_Init | ( | jsStreamConfig * | cfg | ) |
Use this before setting specific stream configuration options and passing this configuration to some of the stream management APIs.
cfg | the pointer to the jsStreamConfig to initialize. |
NATS_EXTERN natsStatus jsPlacement_Init | ( | jsPlacement * | placement | ) |
Use this before setting specific stream placement options.
placement | the pointer to the jsPlacement to initialize. |
NATS_EXTERN natsStatus jsStreamSource_Init | ( | jsStreamSource * | source | ) |
Use this before setting specific stream source options.
source | the pointer to the jsStreamSource to initialize. |
NATS_EXTERN natsStatus jsExternalStream_Init | ( | jsExternalStream * | external | ) |
Use this before setting specific external stream options.
external | the pointer to the jsExternalStream to initialize. |
NATS_EXTERN natsStatus jsRePublish_Init | ( | jsRePublish * | rp | ) |
Use this to set the source, destination and/or headers only for a stream re-publish.
rp | the pointer to the jsRePublish to initialize. |
NATS_EXTERN natsStatus js_AddStream | ( | jsStreamInfo ** | si, |
jsCtx * | js, | ||
jsStreamConfig * | cfg, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Creates a stream based on the provided configuration (that cannot be NULL
). The name is mandatory and cannot contain .
characters.
NULL
, otherwise, on success you are responsible for freeing this object.si | the location where to store the pointer to the new jsStreamInfo object in response to the creation request, or NULL if the stream information is not needed. |
js | the pointer to the jsCtx context. |
cfg | the pointer to the jsStreamConfig. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_UpdateStream | ( | jsStreamInfo ** | si, |
jsCtx * | js, | ||
jsStreamConfig * | cfg, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Updates a stream based on the provided configuration (that cannot be NULL
). The name is mandatory and cannot contain .
characters.
NULL
, otherwise, on success you are responsible for freeing this object.si | the location where to store the pointer to the new jsStreamInfo object in response to the creation request, or NULL if the stream information is not needed. |
js | the pointer to the jsCtx context. |
cfg | the pointer to the jsStreamConfig. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_PurgeStream | ( | jsCtx * | js, |
const char * | stream, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Purges the stream named stream
.
For more advanced purge options, you can specify them through jsOptions.
NATS_EXTERN natsStatus js_DeleteStream | ( | jsCtx * | js, |
const char * | stream, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
NATS_EXTERN natsStatus js_GetMsg | ( | natsMsg ** | msg, |
jsCtx * | js, | ||
const char * | stream, | ||
uint64_t | seq, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves a raw stream message stored in JetStream by sequence number.
msg | the memory location where the library will store the pointer to the natsMsg. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
seq | the sequence in the stream of the message being retrieved. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_GetLastMsg | ( | natsMsg ** | msg, |
jsCtx * | js, | ||
const char * | stream, | ||
const char * | subject, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves the last JetStream message from the stream for a given subject.
msg | the memory location where the library will store the pointer to the natsMsg. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
subject | the subject for which the last message is being retrieved. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus jsDirectGetMsgOptions_Init | ( | jsDirectGetMsgOptions * | opts | ) |
Use this before setting specific direct get message options and passing it to js_DirectGetMsg API.
opts | the pointer to the jsDirectGetMsgOptions object. |
NATS_EXTERN natsStatus js_DirectGetMsg | ( | natsMsg ** | msg, |
jsCtx * | js, | ||
const char * | stream, | ||
jsOptions * | opts, | ||
jsDirectGetMsgOptions * | dgOpts | ||
) |
If a stream is created with AllowDirect
, it is possible to retrieve a message without going through the leader.
To specify the options, call jsDirectGetMsgOptions_Init first and the set the appropriate options, then invoke this function.
v2.9.0+
. If running against an older server the call will likely timeout.msg | the location where to store the pointer to the retrieved message. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
opts | the pointer to the jsOptions object, possibly NULL . |
dgOpts | the pointer to the jsDirectGetMsgOptions object, cannot be NULL . |
NATS_EXTERN natsStatus js_DeleteMsg | ( | jsCtx * | js, |
const char * | stream, | ||
uint64_t | seq, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Deletes the message at sequence seq
in the stream named stream
.
NATS_EXTERN natsStatus js_EraseMsg | ( | jsCtx * | js, |
const char * | stream, | ||
uint64_t | seq, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Similar to js_DeleteMsg except that the content of the deleted message is erased from stable storage.
NATS_EXTERN natsStatus js_GetStreamInfo | ( | jsStreamInfo ** | si, |
jsCtx * | js, | ||
const char * | stream, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Returns information about the stream named stream
.
To get some detailed information about deleted messages, set this option:
si | the location where to store the pointer to the new jsStreamInfo object in response to the creation request. |
js | the pointer to the jsCtx context. |
stream | the name of the stream which information is retrieved. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsStreamInfo_Destroy | ( | jsStreamInfo * | si | ) |
Releases memory allocated for this stream information object.
si | the pointer to the jsStreamInfo object. |
NATS_EXTERN natsStatus js_Streams | ( | jsStreamInfoList ** | list, |
jsCtx * | js, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves the list of all jsStreamInfo. It is possible to filter which streams are to be retrieved based on a subject filter.
list | the location where to store the pointer to the new jsStreamInfoList object. |
js | the pointer to the jsCtx context. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsStreamInfoList_Destroy | ( | jsStreamInfoList * | list | ) |
Releases memory allocated for this stream information list.
list | the pointer to the jsStreamInfoList object. |
NATS_EXTERN natsStatus js_StreamNames | ( | jsStreamNamesList ** | list, |
jsCtx * | js, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves the list of all stream names. It is possible to filter which streams are to be retrieved based on a subject filter.
list | the location where to store the pointer to the new jsStreamNamesList object. |
js | the pointer to the jsCtx context. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsStreamNamesList_Destroy | ( | jsStreamNamesList * | list | ) |
Releases memory allocated for this list of stream names.
list | the pointer to the jsStreamNamesList object. |
NATS_EXTERN natsStatus jsConsumerConfig_Init | ( | jsConsumerConfig * | cc | ) |
Use this before adding a consumer.
cc | the pointer to the jsConsumerConfig to initialize. |
NATS_EXTERN natsStatus js_AddConsumer | ( | jsConsumerInfo ** | ci, |
jsCtx * | js, | ||
const char * | stream, | ||
jsConsumerConfig * | cfg, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Adds a consumer based on the provided configuration (that cannot be NULL
).
NULL
, otherwise, on success you are responsible for freeing this object.ci | the location where to store the pointer to the new jsConsumerInfo object in response to the creation request, or NULL if the consumer information is not needed. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
cfg | the pointer to the jsConsumerConfig. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_UpdateConsumer | ( | jsConsumerInfo ** | ci, |
jsCtx * | js, | ||
const char * | stream, | ||
jsConsumerConfig * | cfg, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Updates a consumer based on the provided configuration (that cannot be NULL
).
NULL
, otherwise, on success you are responsible for freeing this object.ci | the location where to store the pointer to the new jsConsumerInfo object in response to the creation request, or NULL if the consumer information is not needed. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
cfg | the pointer to the jsConsumerConfig. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_GetConsumerInfo | ( | jsConsumerInfo ** | ci, |
jsCtx * | js, | ||
const char * | stream, | ||
const char * | consumer, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
ci | the location where to store the pointer to the new jsConsumerInfo object. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
consumer | the name of the consumer. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_DeleteConsumer | ( | jsCtx * | js, |
const char * | stream, | ||
const char * | consumer, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Deletes the consumer named consumer
from stream named stream
.
NATS_EXTERN natsStatus js_PauseConsumer | ( | jsConsumerPauseResponse ** | new_cpr, |
jsCtx * | js, | ||
const char * | stream, | ||
const char * | consumer, | ||
uint64_t | pauseUntil, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Pauses the consumer named consumer
on stream named stream
.
new_cpr | if not NULL, will receive the response of the operation. |
js | the pointer to the jsCtx context. |
stream | the name of the stream. |
consumer | the name of the consumer. |
pauseUntil | the time in nanoseconds since the Unix epoch to pause the consumer until. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsConsumerPauseResponse_Destroy | ( | jsConsumerPauseResponse * | cpr | ) |
Releases memory allocated for this object.
cpr | the pointer to the jsConsumerPauseResponse object. |
NATS_EXTERN void jsConsumerInfo_Destroy | ( | jsConsumerInfo * | ci | ) |
Releases memory allocated for this consumer information object.
ci | the pointer to the jsConsumerInfo object. |
NATS_EXTERN natsStatus js_Consumers | ( | jsConsumerInfoList ** | list, |
jsCtx * | js, | ||
const char * | stream, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves the list of all jsConsumerInfo for a given stream.
list | the location where to store the pointer to the new jsConsumerInfoList object. |
js | the pointer to the jsCtx context. |
stream | the stream name whose consumer list is requested. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsConsumerInfoList_Destroy | ( | jsConsumerInfoList * | list | ) |
Releases memory allocated for this consumer information list.
list | the pointer to the jsConsumerInfoList object. |
NATS_EXTERN natsStatus js_ConsumerNames | ( | jsConsumerNamesList ** | list, |
jsCtx * | js, | ||
const char * | stream, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves the list of all consumer names for a given stream.
list | the location where to store the pointer to the new jsConsumerNamesList object. |
js | the pointer to the jsCtx context. |
stream | the stream name whose consumer list is requested. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsConsumerNamesList_Destroy | ( | jsConsumerNamesList * | list | ) |
Releases memory allocated for this list of consumer names.
list | the pointer to the jsConsumerNamesList object. |
NATS_EXTERN natsStatus js_GetAccountInfo | ( | jsAccountInfo ** | ai, |
jsCtx * | js, | ||
jsOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Retrieves information about the JetStream usage from an account.
ai | the location where to store the pointer to the new jsAccountInfo object in response to the account information request. |
js | the pointer to the jsCtx context. |
opts | the pointer to the jsOptions object, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsAccountInfo_Destroy | ( | jsAccountInfo * | ai | ) |
Releases memory allocated for this account information object.
ai | the pointer to the jsAccountInfo object. |