NATS C Client with JetStream and Streaming support
3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
|
Typedefs | |
typedef struct __natsConnection | natsConnection |
A connection to a NATS Server . More... | |
typedef struct __natsStatistics | natsStatistics |
Statistics of a natsConnection. More... | |
typedef struct __natsSubscription | natsSubscription |
Interest on a given subject. More... | |
typedef struct __natsMsg | natsMsg |
A structure holding a subject, optional reply and payload. More... | |
typedef struct __natsOptions | natsOptions |
Way to configure a natsConnection. More... | |
typedef char | natsInbox |
Unique subject often used for point-to-point communication. More... | |
typedef struct __natsClientConfig | natsClientConfig |
An initial configuration for NATS client. Provides control over the threading model, and sets many default option values. More... | |
typedef struct natsMsgList | natsMsgList |
A list of NATS messages. More... | |
typedef struct natsMetadata | natsMetadata |
A type to represent user-provided metadata, a list of k=v pairs. More... | |
typedef struct __jsCtx | jsCtx |
typedef struct jsPubOptions | jsPubOptions |
typedef struct jsPlacement | jsPlacement |
typedef struct jsExternalStream | jsExternalStream |
typedef struct jsStreamSource | jsStreamSource |
typedef struct jsRePublish | jsRePublish |
typedef struct jsSubjectTransformConfig | jsSubjectTransformConfig |
typedef struct jsStreamConsumerLimits | jsStreamConsumerLimits |
typedef struct jsStreamConfig | jsStreamConfig |
typedef struct jsLostStreamData | jsLostStreamData |
typedef struct jsStreamStateSubject | jsStreamStateSubject |
typedef struct jsStreamStateSubjects | jsStreamStateSubjects |
typedef struct jsStreamState | jsStreamState |
typedef struct jsPeerInfo | jsPeerInfo |
typedef struct jsClusterInfo | jsClusterInfo |
typedef struct jsStreamSourceInfo | jsStreamSourceInfo |
typedef struct jsStreamAlternate | jsStreamAlternate |
typedef struct jsStreamInfo | jsStreamInfo |
typedef struct jsStreamInfoList | jsStreamInfoList |
typedef struct jsStreamNamesList | jsStreamNamesList |
typedef struct jsConsumerConfig | jsConsumerConfig |
typedef struct jsConsumerSequenceMismatch | jsConsumerSequenceMismatch |
typedef struct jsSubOptions | jsSubOptions |
typedef struct jsSequencePair | jsSequencePair |
typedef struct jsSequenceInfo | jsSequenceInfo |
typedef struct jsConsumerInfo | jsConsumerInfo |
typedef struct jsConsumerInfoList | jsConsumerInfoList |
typedef struct jsConsumerNamesList | jsConsumerNamesList |
typedef struct jsConsumerPauseResponse | jsConsumerPauseResponse |
typedef struct jsAPIStats | jsAPIStats |
typedef struct jsAccountLimits | jsAccountLimits |
typedef struct jsTier | jsTier |
typedef struct jsAccountInfo | jsAccountInfo |
typedef struct jsMsgMetaData | jsMsgMetaData |
typedef struct jsPubAck | jsPubAck |
typedef struct jsPubAckErr | jsPubAckErr |
typedef struct jsDirectGetMsgOptions | jsDirectGetMsgOptions |
typedef struct jsFetchRequest | jsFetchRequest |
typedef void(* | jsFetchCompleteHandler) (natsConnection *nc, natsSubscription *sub, natsStatus s, void *closure) |
Callback used to indicate that the work of js_PullSubscribeAsync is done. More... | |
typedef bool(* | jsFetchNextHandler) (int *messages, int64_t *maxBytes, natsSubscription *sub, void *closure) |
Callback used to customize flow control for js_PullSubscribeAsync. More... | |
typedef struct jsOptions | jsOptions |
typedef struct __kvStore | kvStore |
typedef struct __kvEntry | kvEntry |
typedef struct __kvStatus | kvStatus |
typedef struct __kvWatcher | kvWatcher |
typedef struct kvConfig | kvConfig |
typedef struct kvWatchOptions | kvWatchOptions |
typedef struct kvPurgeOptions | kvPurgeOptions |
typedef struct kvEntryList | kvEntryList |
A list of KeyValue store entries. More... | |
typedef struct kvKeysList | kvKeysList |
A list of KeyValue store keys. More... | |
typedef struct __stanConnection | stanConnection |
A connection to a NATS Streaming Server . More... | |
typedef struct __stanSubscription | stanSubscription |
Interest on a given channel. More... | |
typedef struct __stanMsg | stanMsg |
The Streaming message. More... | |
typedef struct __stanConnOptions | stanConnOptions |
Way to configure a stanConnection. More... | |
typedef struct __stanSubOptions | stanSubOptions |
Way to configure a stanSubscription. More... | |
Enumerations | |
enum | jsRetentionPolicy { js_LimitsPolicy = 0 , js_InterestPolicy , js_WorkQueuePolicy } |
enum | jsDiscardPolicy { js_DiscardOld = 0 , js_DiscardNew } |
enum | jsStorageType { js_FileStorage = 0 , js_MemoryStorage } |
enum | jsStorageCompression { js_StorageCompressionNone = 0 , js_StorageCompressionS2 } |
enum | jsDeliverPolicy { js_DeliverAll = 0 , js_DeliverLast , js_DeliverNew , js_DeliverByStartSequence , js_DeliverByStartTime , js_DeliverLastPerSubject } |
enum | jsAckPolicy { js_AckExplicit = 0 , js_AckNone , js_AckAll } |
enum | jsReplayPolicy { js_ReplayInstant = 0 , js_ReplayOriginal } |
enum | kvOperation { kvOp_Unknown = 0 , kvOp_Put , kvOp_Delete , kvOp_Purge } |
NATS Types.
typedef struct __natsConnection natsConnection |
A natsConnection represents a bare connection to a NATS Server
. It will send and receive byte array payloads.
typedef struct __natsStatistics natsStatistics |
Tracks various statistics received and sent on a connection, including counts for messages and bytes.
typedef struct __natsSubscription natsSubscription |
A natsSubscription represents interest in a given subject.
typedef struct __natsMsg natsMsg |
natsMsg is a structure used by Subscribers and natsConnection_PublishMsg().
typedef struct __natsOptions natsOptions |
Options can be used to create a customized natsConnection.
typedef char natsInbox |
This can be used as the reply for a request. Inboxes are meant to be unique so that replies can be sent to a specific subscriber. That being said, inboxes can be shared across multiple subscribers if desired.
typedef struct __natsClientConfig natsClientConfig |
typedef struct natsMsgList natsMsgList |
Used by some APIs which return a list of natsMsg objects.
Those APIs will not create the object, but instead initialize the object to which a pointer to that object will be passed to it. Typically, the user will define the object on the stack and pass a pointer to this object to APIs that require a pointer to a natsMsgList object.
Similarly, calling natsMsgList_Destroy will call natsMsg_Destroy on any message still in the list, free the array containing pointers to the messages, but not free the natsMsgList object itself.
Msgs
array should be set to NULL
. The value Count
MUST not be changed. The function natsMsgList_Destroy will iterate through all pointers in the list and only destroy the ones that have not been set to NULL
.typedef struct natsMetadata natsMetadata |
Used in JetStream, microservice configuration.
typedef struct __jsCtx jsCtx |
The JetStream context. Use for JetStream assets management and communication.
typedef struct jsPubOptions jsPubOptions |
JetStream publish options.
These are options that you can provide to JetStream publish APIs.
The common usage will be to initialize a structure on the stack by calling jsPubOptions_Init. Note that strings are owned by the application and need to be valid for the duration of the API call this object is passed to.
typedef struct jsPlacement jsPlacement |
Used to guide placement of streams in clustered JetStream.
Initialize the object with jsPlacement_Init.
See jsStreamConfig for information on how to configure a stream.
typedef struct jsExternalStream jsExternalStream |
Allows you to qualify access to a stream source in another account.
Initialize the object with jsExternalStream_Init.
See jsStreamConfig for information on how to configure a stream.
typedef struct jsStreamSource jsStreamSource |
Dictates how streams can source from other streams.
Initialize the object with jsStreamSource_Init.
OptStartTime
needs to be expressed as the number of nanoseconds passed since 00:00:00 UTC Thursday, 1 January 1970.See jsStreamConfig for information on how to configure a stream.
typedef struct jsRePublish jsRePublish |
Allows a source subject to be mapped to a destination subject for republishing.
typedef struct jsSubjectTransformConfig jsSubjectTransformConfig |
SubjectTransformConfig is for applying a subject transform (to matching messages) before doing anything else when a new message is received
typedef struct jsStreamConsumerLimits jsStreamConsumerLimits |
SubjectTransformConfig is for applying a subject transform (to matching messages) before doing anything else when a new message is received
typedef struct jsStreamConfig jsStreamConfig |
Configuration of a JetStream stream.
There are sensible defaults for most. If no subjects are given the name will be used as the only subject.
In order to add/update a stream, a configuration needs to be set. The typical usage would be to initialize all required objects on the stack and configure them, then pass the pointer to the configuration to js_AddStream or js_UpdateStream.
typedef struct jsLostStreamData jsLostStreamData |
Information about messages that have been lost
typedef struct jsStreamStateSubject jsStreamStateSubject |
This indicate that the given Subject
in a stream contains Msgs
messages.
typedef struct jsStreamStateSubjects jsStreamStateSubjects |
List of subjects optionally returned in the stream information request.
This structure indicates the number of elements in the list, that is, the list contains Count
jsStreamStateSubject elements.
To get this list in jsStreamState, you have to ask for it through jsOptions.
typedef struct jsStreamState jsStreamState |
Information about the given stream
FirstTime
and LastTime
are message timestamps expressed as the number of nanoseconds passed since 00:00:00 UTC Thursday, 1 January 1970. typedef struct jsPeerInfo jsPeerInfo |
Information about all the peers in the cluster that are supporting the stream or consumer.
typedef struct jsClusterInfo jsClusterInfo |
Information about the underlying set of servers that make up the stream or consumer.
typedef struct jsStreamSourceInfo jsStreamSourceInfo |
Information about an upstream stream source.
typedef struct jsStreamAlternate jsStreamAlternate |
Information about an alternate stream represented by a mirror.
typedef struct jsStreamInfo jsStreamInfo |
Configuration and current state for this stream.
Created
is the timestamp when the stream was created, expressed as the number of nanoseconds passed since 00:00:00 UTC Thursday, 1 January 1970. typedef struct jsStreamInfoList jsStreamInfoList |
List of stream information objects returned by js_Streams
typedef struct jsStreamNamesList jsStreamNamesList |
List of stream names returned by js_StreamNames
typedef struct jsConsumerConfig jsConsumerConfig |
Configuration of a JetStream consumer.
In order to add a consumer, a configuration needs to be set. The typical usage would be to initialize all required objects on the stack and configure them, then pass the pointer to the configuration to js_AddConsumer.
OptStartTime
needs to be expressed as the number of nanoseconds passed since 00:00:00 UTC Thursday, 1 January 1970.SampleFrequency
is a sampling value, represented as a string such as "50" for 50%, that causes the server to produce advisories for consumer ack metrics.Durable
cannot contain the character ".".HeadersOnly
means that the subscription will not receive any message payload, instead, it will receive only messages headers (if present) with the addition of the header JSMsgSize ("Nats-Msg-Size"), whose value is the payload size.typedef struct jsConsumerSequenceMismatch jsConsumerSequenceMismatch |
This represents a consumer sequence mismatch between the server and client views.
This can help applications find out if messages have been missed. Without this and during a disconnect, it would be possible that a subscription is not aware that it missed messages from the server. When acknowledgment mode is other than js_AckNone, messages would ultimately be redelivered, but for js_AckNone, they would not. But even with an acknowledgment mode this may help finding sooner that something went wrong and let the application decide if it wants to recreate the subscription starting at a given sequence.
The gap of missing messages could be calculated as ConsumerServer-ConsumerClient
.
typedef struct jsSubOptions jsSubOptions |
JetStream subscribe options.
These are options that you can provide to JetStream subscribe APIs.
The common usage will be to initialize a structure on the stack by calling jsSubOptions_Init. Note that strings are owned by the application and need to be valid for the duration of the API call this object is passed to.
typedef struct jsSequencePair jsSequencePair |
Includes the consumer and stream sequence info from a JetStream consumer.
typedef struct jsSequenceInfo jsSequenceInfo |
Has both the consumer and the stream sequence and last activity.
typedef struct jsConsumerInfo jsConsumerInfo |
Configuration and current state for this consumer.
Created
is the timestamp when the consumer was created, expressed as the number of nanoseconds passed since 00:00:00 UTC Thursday, 1 January 1970. typedef struct jsConsumerInfoList jsConsumerInfoList |
List of consumers information objects returned by js_Consumers
typedef struct jsConsumerNamesList jsConsumerNamesList |
List of consumer names returned by js_ConsumerNames
typedef struct jsConsumerPauseResponse jsConsumerPauseResponse |
Request to pause the consumer, used to call js_PauseConsumer.
typedef struct jsAPIStats jsAPIStats |
Reports on API calls to JetStream for this account.
typedef struct jsAccountLimits jsAccountLimits |
Includes the JetStream limits of the current account.
typedef struct jsAccountInfo jsAccountInfo |
Information about the JetStream usage from the current account.
typedef struct jsMsgMetaData jsMsgMetaData |
This represents the JetStream metadata associated with received messages.
typedef struct jsPubAckErr jsPubAckErr |
Publish acknowledgment failure that will be passed to the optional jsPubAckErrHandler callback.
typedef struct jsDirectGetMsgOptions jsDirectGetMsgOptions |
Options for the js_DirectGetMsg() call, which retrieves a message from any server (not only the leader) as long as the stream has been created with a AllowDirect option.
Note that some options are mutually exclusive but are not checked byt the library. The server will reject invalid requests and the library will return the error returned from the server.
typedef struct jsFetchRequest jsFetchRequest |
Options for the natsSubscription_FetchRequest() call, which is similar to natsSubscription_Fetch() but gives more control in the configuration of the fetch.
typedef void(* jsFetchCompleteHandler) (natsConnection *nc, natsSubscription *sub, natsStatus s, void *closure) |
nc | - Connection to the NATS server |
sub | - Subscription being used |
s | - Completion status code
|
closure | completeClosure that was passed to js_PullSubscribeAsync |
typedef bool(* jsFetchNextHandler) (int *messages, int64_t *maxBytes, natsSubscription *sub, void *closure) |
The library will invoke this callback when it may be time to request more messages from the server.
messages
and maxBytes
should be set to the number of messages and max bytes to fetch.JetStream context options.
Initialize the object with jsOptions_Init.
typedef struct __kvStore kvStore |
The KeyValue store object.
typedef struct __kvEntry kvEntry |
The KeyValue entry object.
typedef struct __kvStatus kvStatus |
The KeyValue status object.
typedef struct __kvWatcher kvWatcher |
The KeyValue watcher object.
KeyValue configuration object.
Initialize the object with kvConfig_Init.
typedef struct kvWatchOptions kvWatchOptions |
KeyValue watcher options object.
Initialize the object with kvWatchOptions_Init
typedef struct kvPurgeOptions kvPurgeOptions |
KeyValue purge options object.
Initialize the object with kvPurgeOptions_Init
typedef struct kvEntryList kvEntryList |
Used by some APIs which return a list of kvEntry objects.
Those APIs will not create the object, but instead initialize the object.
Typically, the user will define the object on the stack and pass a pointer to this object to APIs that require a pointer to a kvEntryList object.
Similarly, calling kvEntryList_Destroy will call kvEntry_Destroy on entries in the list, free the array containing pointers to the entries, but not free the kvEntryList object itself.
typedef struct kvKeysList kvKeysList |
Used by some APIs which return a list of key names.
Those APIs will not create the object, but instead initialize the object.
Typically, the user will define the object on the stack and pass a pointer to this object to APIs that require a pointer to a kvKeysList object.
Similarly, calling kvKeysList_Destroy will free key strings in the list, free the array containing pointers to the keys, but not free the kvKeysList object itself.
typedef struct __stanConnection stanConnection |
A stanConnection represents a connection to a NATS Streaming Server
.
typedef struct __stanSubscription stanSubscription |
A stanSubscription represents interest in a given channel.
typedef struct __stanMsg stanMsg |
stanMsg is the object passed to the subscriptions' message callbacks.
typedef struct __stanConnOptions stanConnOptions |
Options can be used to create a customized stanConnection.
typedef struct __stanSubOptions stanSubOptions |
Options can be used to create a customized stanSubscription.
enum jsRetentionPolicy |
Determines how messages in a set are retained.
enum jsDiscardPolicy |
enum jsStorageType |
enum jsStorageCompression |
enum jsDeliverPolicy |
Determines how the consumer should select the first message to deliver.
enum jsAckPolicy |
enum jsReplayPolicy |
enum kvOperation |
Determines the type of operation of a kvEntry
Enumerator | |
---|---|
kvOp_Unknown | |
kvOp_Put | |
kvOp_Delete | |
kvOp_Purge |