NATS C Client with JetStream and Streaming support  3.2.0
The nats.io C Client, Supported by Synadia Communications Inc.
JetStream Assets Management

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 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 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 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_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 void jsConsumerInfo_Destroy (jsConsumerInfo *ci)
 Destroys the consumer information 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...
 

Detailed Description

JetStream Assets Management

Function Documentation

◆ jsStreamConfig_Init()

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.

Parameters
cfgthe pointer to the jsStreamConfig to initialize.

◆ jsPlacement_Init()

NATS_EXTERN natsStatus jsPlacement_Init ( jsPlacement *  placement)

Use this before setting specific stream placement options.

Parameters
placementthe pointer to the jsPlacement to initialize.

◆ jsStreamSource_Init()

NATS_EXTERN natsStatus jsStreamSource_Init ( jsStreamSource *  source)

Use this before setting specific stream source options.

Parameters
sourcethe pointer to the jsStreamSource to initialize.

◆ jsExternalStream_Init()

NATS_EXTERN natsStatus jsExternalStream_Init ( jsExternalStream *  external)

Use this before setting specific external stream options.

Parameters
externalthe pointer to the jsExternalStream to initialize.

◆ js_AddStream()

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.

Note
If you do not need a jsStreamInfo to be returned, you can pass NULL, otherwise, on success you are responsible for freeing this object.
See also
jsStreamConfig_Init
jsStreamInfo_Destroy
Parameters
sithe 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.
jsthe pointer to the jsCtx context.
cfgthe pointer to the jsStreamConfig.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_UpdateStream()

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.

Note
If you do not need a jsStreamInfo to be returned, you can pass NULL, otherwise, on success you are responsible for freeing this object.
See also
jsStreamConfig_Init
jsStreamInfo_Destroy
Parameters
sithe 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.
jsthe pointer to the jsCtx context.
cfgthe pointer to the jsStreamConfig.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_PurgeStream()

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.

jsOptions o;
jsOptions_Init(&o);
o.Stream.Purge.Subject = "foo";
o.Stream.Purge.Sequence = 4;
js_PurgeStream(js, "MY_STREAM", &o, &jerr);
Parameters
jsthe pointer to the jsCtx context.
streamthe name of the stream to purge.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_DeleteStream()

NATS_EXTERN natsStatus js_DeleteStream ( jsCtx *  js,
const char *  stream,
jsOptions *  opts,
jsErrCode *  errCode 
)

Deletes the stream named stream.

Parameters
jsthe pointer to the jsCtx context.
streamthe name of the stream to delete.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_GetMsg()

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.

Note
The message needs to be destroyed by calling natsMsg_Destroy.
See also
js_GetLastMsg
natsMsg_Destroy
Parameters
msgthe memory location where the library will store the pointer to the natsMsg.
jsthe pointer to the jsCtx context.
streamthe name of the stream.
seqthe sequence in the stream of the message being retrieved.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_GetLastMsg()

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.

Note
The message needs to be destroyed by calling natsMsg_Destroy.
See also
js_GetMsg
natsMsg_Destroy
Parameters
msgthe memory location where the library will store the pointer to the natsMsg.
jsthe pointer to the jsCtx context.
streamthe name of the stream.
subjectthe subject for which the last message is being retrieved.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_DeleteMsg()

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.

Note
To completely erase the content of the deleted message when stored on disk, use js_EraseMsg instead.
See also
js_EraseMsg
Parameters
jsthe pointer to the jsCtx context.
streamthe name of the stream.
seqthe sequence in the stream of the message to delete.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_EraseMsg()

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.

See also
js_DeleteMsg
Parameters
jsthe pointer to the jsCtx context.
streamthe name of the stream.
seqthe sequence in the stream of the message to erase.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_GetStreamInfo()

NATS_EXTERN natsStatus js_GetStreamInfo ( jsStreamInfo **  si,
jsCtx *  js,
const char *  stream,
jsOptions *  opts,
jsErrCode *  errCode 
)

Returns information about the stream named stream.

Note
You need to free the returned object.

To get some detailed information about deleted messages, set this option:

jsOptions o;
jsOptions_Init(&o);
o.Stream.Info.DeletedDetails = true;
js_GetStreamInfo(&si, js, "MY_STREAM", &o, &jerr);
See also
jsStreamInfo_Destroy
Parameters
sithe location where to store the pointer to the new jsStreamInfo object in response to the creation request.
jsthe pointer to the jsCtx context.
streamthe name of the stream which information is retrieved.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ jsStreamInfo_Destroy()

NATS_EXTERN void jsStreamInfo_Destroy ( jsStreamInfo *  si)

Releases memory allocated for this stream information object.

Parameters
sithe pointer to the jsStreamInfo object.

◆ jsConsumerConfig_Init()

NATS_EXTERN natsStatus jsConsumerConfig_Init ( jsConsumerConfig *  cc)

Use this before adding a consumer.

See also
jsConsumerConfig
Parameters
ccthe pointer to the jsConsumerConfig to initialize.

◆ js_AddConsumer()

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).

Note
If you do not need a jsConsumerInfo to be returned, you can pass NULL, otherwise, on success you are responsible for freeing this object.
See also
jsConsumerConfig_Init
jsConsumerInfo_Destroy
Parameters
cithe 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.
jsthe pointer to the jsCtx context.
streamthe name of the stream.
cfgthe pointer to the jsConsumerConfig.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_GetConsumerInfo()

NATS_EXTERN natsStatus js_GetConsumerInfo ( jsConsumerInfo **  ci,
jsCtx *  js,
const char *  stream,
const char *  consumer,
jsOptions *  opts,
jsErrCode *  errCode 
)
Note
The returned object should be destroyed using jsConsumerInfo_Destroy in order to free allocated memory.
Parameters
cithe location where to store the pointer to the new jsConsumerInfo object.
jsthe pointer to the jsCtx context.
streamthe name of the stream.
consumerthe name of the consumer.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ js_DeleteConsumer()

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.

Parameters
jsthe pointer to the jsCtx context.
streamthe name of the stream.
consumerthe name of the consumer.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ jsConsumerInfo_Destroy()

NATS_EXTERN void jsConsumerInfo_Destroy ( jsConsumerInfo *  ci)

Releases memory allocated for this consumer information object.

Parameters
cithe pointer to the jsConsumerInfo object.

◆ js_GetAccountInfo()

NATS_EXTERN natsStatus js_GetAccountInfo ( jsAccountInfo **  ai,
jsCtx *  js,
jsOptions *  opts,
jsErrCode *  errCode 
)

Retrieves information about the JetStream usage from an account.

Note
The returned object should be destroyed using jsAccountInfo_Destroy in order to free allocated memory.
Parameters
aithe location where to store the pointer to the new jsAccountInfo object in response to the account information request.
jsthe pointer to the jsCtx context.
optsthe pointer to the jsOptions object, possibly NULL.
errCodethe location where to store the JetStream specific error code, or NULL if not needed.

◆ jsAccountInfo_Destroy()

NATS_EXTERN void jsAccountInfo_Destroy ( jsAccountInfo *  ai)

Releases memory allocated for this account information object.

Parameters
aithe pointer to the jsAccountInfo object.