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

Functions

NATS_EXTERN microErrormicro_AddService (microService **new_microservice, natsConnection *nc, microServiceConfig *config)
 Creates and starts a new microservice. More...
 
NATS_EXTERN microErrormicroService_AddEndpoint (microService *m, microEndpointConfig *config)
 Adds an endpoint to a microservice and starts listening for messages. More...
 
NATS_EXTERN microErrormicroService_AddGroup (microGroup **new_group, microService *m, microGroupConfig *config)
 Adds an group (prefix) to a microservice. More...
 
NATS_EXTERN microErrormicroService_Destroy (microService *m)
 Destroys a microservice, stopping it first if needed. More...
 
NATS_EXTERN natsConnectionmicroService_GetConnection (microService *m)
 Returns the connection associated with the service. If the service was successfully started, it is safe to assume it's not NULL, however it may already have been disconnected or closed. More...
 
NATS_EXTERN microErrormicroService_GetInfo (microServiceInfo **new_info, microService *m)
 Returns a microServiceInfo for a microservice. More...
 
NATS_EXTERN void * microService_GetState (microService *m)
 Returns the pointer to state data (closure). It is originally provided in microServiceConfig.State. More...
 
NATS_EXTERN microErrormicroService_GetStats (microServiceStats **new_stats, microService *m)
 Returns run-time statistics for a microservice. More...
 
NATS_EXTERN bool microService_IsStopped (microService *m)
 Checks if the service is stopped. More...
 
NATS_EXTERN microErrormicroService_Run (microService *m)
 Waits for a microservice to stop. More...
 
NATS_EXTERN microErrormicroService_Stop (microService *m)
 Stops a running microservice. More...
 

Detailed Description

Functions that operate with microService.

Function Documentation

◆ micro_AddService()

NATS_EXTERN microError* micro_AddService ( microService **  new_microservice,
natsConnection nc,
microServiceConfig config 
)
Note
The microservice should be destroyed to clean up using microService_Destroy.
Parameters
new_microservicethe location where to store the pointer to the new microService object.
ncthe natsConnection the service will use to receive and respond to requests.
configa microServiceConfig object with the configuration of the service. See micro_service_config_s for descriptions of the fields.
Returns
a microError if an error occurred.
See also
microService_Destroy, microService_AddEndpoint, microServiceConfig, microEndpointConfig

◆ microService_AddEndpoint()

NATS_EXTERN microError* microService_AddEndpoint ( microService m,
microEndpointConfig config 
)

Endpoints are currently destroyed when the service is stopped, there is no present way to remove or stop individual endpoints.

Parameters
mthe microService that the endpoint will be added to.
configa microEndpointConfig object with the configuration of the endpoint. See micro_endpoint_config_s for descriptions of the fields.
Returns
a microError if an error occurred.
See also
microService_Destroy, microEndpointConfig

◆ microService_AddGroup()

NATS_EXTERN microError* microService_AddGroup ( microGroup **  new_group,
microService m,
microGroupConfig config 
)

Groups are associated with a service, and are destroyed when the service is destroyed.

Parameters
new_groupthe location where to store the pointer to the new microGroup object.
mthe microService that the group will be added to.
configgroup parameters.
Returns
a microError if an error occurred.
See also
microGroup_AddGroup, microGroup_AddEndpoint

◆ microService_Destroy()

NATS_EXTERN microError* microService_Destroy ( microService m)
Note
This function may fail while stopping the service, do not assume unconditional success if clean up is important.
Parameters
mthe microService to stop and destroy.
Returns
a microError if an error occurred.
See also
microService_Stop, microService_Run

◆ microService_GetConnection()

NATS_EXTERN natsConnection* microService_GetConnection ( microService m)
Parameters
mthe microService.
Returns
a natsConnection associated with the service.

◆ microService_GetInfo()

NATS_EXTERN microError* microService_GetInfo ( microServiceInfo **  new_info,
microService m 
)
Note
the microServiceInfo struct returned by this call should be freed with microServiceInfo_Destroy.
Parameters
new_inforeceives the pointer to the microServiceInfo.
mthe microService to query.
Returns
a microError if an error occurred.
See also
microServiceInfo, micro_service_info_s

◆ microService_GetState()

NATS_EXTERN void* microService_GetState ( microService m)
Parameters
mthe microService.
Returns
the state pointer.
See also
microServiceConfig

◆ microService_GetStats()

NATS_EXTERN microError* microService_GetStats ( microServiceStats **  new_stats,
microService m 
)
Note
the microServiceStats struct returned by this call should be freed with microServiceStats_Destroy.
Parameters
new_statsreceives the pointer to the microServiceStats.
mthe microService to query.
Returns
a microError if an error occurred.
See also
microServiceStats, micro_service_stats_s

◆ microService_IsStopped()

NATS_EXTERN bool microService_IsStopped ( microService m)
Parameters
mthe microService.
Returns
true if stopped, otherwise false.
See also
micro_AddService, microService_Stop, microService_Run

◆ microService_Run()

NATS_EXTERN microError* microService_Run ( microService m)

micro_AddService starts the service with async subscriptions. microService_Run waits for the service to stop.

Parameters
mthe microService.
Returns
a microError for invalid arguments, otherwise always succeeds.
See also
micro_AddService, microService_Stop

◆ microService_Stop()

NATS_EXTERN microError* microService_Stop ( microService m)

Drains and closes the all subscriptions (endpoints and monitoring), resets the stats, and calls the Done callback for the service, so it can do its own clean up if needed.

It is possible that this call encounters an error while stopping the service, in which case it aborts and returns the error. The service then may be in a partially stopped state, and the Done callback will not have been called.

Parameters
mthe microService.
Returns
a microError if an error occurred.
See also
micro_AddService, microService_Run