|
| enum | KSI_AsyncHandleState_en {
KSI_ASYNC_STATE_UNDEFINED = 0,
KSI_ASYNC_STATE_WAITING_FOR_DISPATCH,
KSI_ASYNC_STATE_WAITING_FOR_RESPONSE,
KSI_ASYNC_STATE_RESPONSE_RECEIVED,
KSI_ASYNC_STATE_PUSH_CONFIG_RECEIVED,
KSI_ASYNC_STATE_ERROR
} |
| |
| enum | KSI_AsyncOption_en {
KSI_ASYNC_OPT_CON_TIMEOUT = 0,
KSI_ASYNC_OPT_RCV_TIMEOUT,
KSI_ASYNC_OPT_SND_TIMEOUT,
KSI_ASYNC_OPT_REQUEST_CACHE_SIZE,
KSI_ASYNC_OPT_MAX_REQUEST_COUNT,
KSI_ASYNC_OPT_PUSH_CONF_CALLBACK,
KSI_ASYNC_OPT_HA_SUBSERVICE_LIST,
__KSI_ASYNC_OPT_COUNT
} |
| |
|
| void | KSI_AsyncHandle_free (KSI_AsyncHandle *o) |
| |
| int | KSI_AbstractAsyncHandle_new (KSI_CTX *ctx, KSI_AsyncHandle **o) |
| |
| int | KSI_AsyncAggregationHandle_new (KSI_CTX *ctx, KSI_AggregationReq *req, KSI_AsyncHandle **o) |
| |
| int | KSI_AsyncExtendHandle_new (KSI_CTX *ctx, KSI_ExtendReq *req, KSI_AsyncHandle **o) |
| |
| int | KSI_AsyncExtendingHandle_new (KSI_CTX *ctx, const KSI_Signature *sig, const KSI_PublicationRecord *pubRec, KSI_AsyncHandle **o) |
| |
| KSI_AsyncHandle * | KSI_AsyncHandle_ref (KSI_AsyncHandle *o) |
| |
| int | KSI_AsyncHandle_setRequestCtx (KSI_AsyncHandle *o, void *reqCtx, void(*reqCtx_free)(void *)) |
| |
| int | KSI_AsyncHandle_getRequestCtx (const KSI_AsyncHandle *o, const void **reqCtx) |
| |
| int | KSI_AsyncHandle_getState (const KSI_AsyncHandle *h, int *state) |
| |
| int | KSI_AsyncHandle_getError (const KSI_AsyncHandle *h, int *error) |
| |
| int | KSI_AsyncHandle_getExtError (const KSI_AsyncHandle *h, long *ext) |
| |
| int | KSI_AsyncHandle_getErrorMessage (const KSI_AsyncHandle *h, KSI_Utf8String **msg) |
| |
| int | KSI_AsyncHandle_getRequestId (const KSI_AsyncHandle *h, KSI_uint64_t *id) |
| |
| int | KSI_AsyncHandle_getAggregationReq (const KSI_AsyncHandle *h, KSI_AggregationReq **req) |
| |
| int | KSI_AsyncHandle_getExtendReq (const KSI_AsyncHandle *h, KSI_ExtendReq **req) |
| |
| int | KSI_AsyncHandle_getAggregationResp (const KSI_AsyncHandle *h, KSI_AggregationResp **resp) |
| |
| int | KSI_AsyncHandle_getExtendResp (const KSI_AsyncHandle *h, KSI_ExtendResp **resp) |
| |
| int | KSI_AsyncHandle_getSignature (const KSI_AsyncHandle *h, KSI_Signature **signature) |
| |
| int | KSI_AsyncHandle_getConfig (const KSI_AsyncHandle *h, KSI_Config **config) |
| |
| void | KSI_AsyncClient_free (KSI_AsyncClient *c) |
| |
| int | KSI_AbstractAsyncClient_new (KSI_CTX *ctx, KSI_AsyncClient **c) |
| |
| void | KSI_AsyncService_free (KSI_AsyncService *service) |
| |
| int | KSI_SigningAsyncService_new (KSI_CTX *ctx, KSI_AsyncService **service) |
| |
| int | KSI_ExtendingAsyncService_new (KSI_CTX *ctx, KSI_AsyncService **service) |
| |
| int | KSI_AsyncService_addRequest (KSI_AsyncService *service, KSI_AsyncHandle *handle) |
| |
| int | KSI_AsyncService_run (KSI_AsyncService *service, KSI_AsyncHandle **handle, size_t *waiting) |
| |
| int | KSI_AsyncService_getPendingCount (KSI_AsyncService *s, size_t *count) |
| |
| int | KSI_AsyncService_getReceivedCount (KSI_AsyncService *s, size_t *count) |
| |
| int | KSI_AsyncService_setOption (KSI_AsyncService *s, const int option, void *value) |
| |
| int | KSI_AsyncService_getOption (const KSI_AsyncService *s, const int option, void *value) |
| |
| int | KSI_AsyncService_setEndpoint (KSI_AsyncService *service, const char *uri, const char *loginId, const char *key) |
| |
| int | KSI_AsyncService_addEndpoint (KSI_AsyncService *service, const char *uri, const char *loginId, const char *key) |
| |
| int | KSI_SigningHighAvailabilityService_new (KSI_CTX *ctx, KSI_AsyncService **service) |
| |
| int | KSI_ExtendingHighAvailabilityService_new (KSI_CTX *ctx, KSI_AsyncService **service) |
| |
The asynchronous API provides the ability to send KSI service requests in a non-blocking manner. As a drawback, it is not guaranteed that received responses are returned in the same order as the requests have been queued. However, you can associate each request with a private pointer. The interface incorporates two major parts:
◆ KSI_AsyncHandleState
Enum defining async handle state.
◆ KSI_AsyncOption
◆ KSI_AsyncHandleState_en
Enum defining async handle state.
| Enumerator |
|---|
| KSI_ASYNC_STATE_UNDEFINED | The state of the request is undefined.
|
| KSI_ASYNC_STATE_WAITING_FOR_DISPATCH | The request is cached in the output queue.
|
| KSI_ASYNC_STATE_WAITING_FOR_RESPONSE | The request has been dispathed.
|
| KSI_ASYNC_STATE_RESPONSE_RECEIVED | The response has been received and is ready to be read. This is the final state of a request. - See also
- KSI_AsyncHandle_getAggregationResp for extracting aggregation response.
-
KSI_AsyncHandle_getSignature for extracting KSI KSI Signature.
-
KSI_AsyncHandle_free for cleaning up resources.
|
| KSI_ASYNC_STATE_PUSH_CONFIG_RECEIVED | Push configuration has been received from the server. This is the final state of a request. - See also
- KSI_AsyncHandle_getConfig for extracting server configuration response.
-
KSI_AsyncHandle_free for cleaning up resources.
|
| KSI_ASYNC_STATE_ERROR | An error has occured while the request was in process. This is the final state of a request. - See also
- KSI_AsyncHandle_getError for reading the error code.
-
KSI_AsyncHandle_free for cleaning up resources.
-
KSI_AsyncService_addRequest for re-adding the request back into the request queue.
|
◆ KSI_AsyncOption_en
Enum defining async service options. Pay attention to the used parameter type.
- See also
- KSI_AsyncService_setOption for applying option values.
-
KSI_AsyncService_getOption for extracting option values.
| Enumerator |
|---|
| KSI_ASYNC_OPT_CON_TIMEOUT | Async connection timeout. Time interval between when network connection has been initiated and the point it has been established. Default setting is 10 sec. - Parameters
-
| timeout | Timeout in seconds. Paramer of type size_t. |
- See also
- KSI_AsyncHandle_getState for the request state.
-
KSI_AsyncHandle_getError for the request error.
- Note
- In case of timeout, if there are any request that have not been responded yet, the request state will be set to KSI_ASYNC_STATE_ERROR and error KSI_NETWORK_CONNECTION_TIMEOUT.
|
| KSI_ASYNC_OPT_RCV_TIMEOUT | Async request response receive timeout. Represents the time interval between when the request was sent out and a response has been received. Default setting is 10 sec. - Parameters
-
| timeout | Timeout in seconds. Paramer of type size_t. |
- See also
- KSI_AsyncHandle_getState for the request state.
-
KSI_AsyncHandle_getError for the request error.
- Note
- In case of timeout the request state will be set to KSI_ASYNC_STATE_ERROR and error to KSI_NETWORK_RECIEVE_TIMEOUT.
|
| KSI_ASYNC_OPT_SND_TIMEOUT | Async request send timeout. Represent the time interval between when the request has been added to the request queue and it has been sent out. Default setting is 10 sec. - Parameters
-
| timeout | Timeout in seconds. Paramer of type size_t. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncHandle_getState for the request state.
-
KSI_AsyncHandle_getError for the request error.
- Note
- In case of timeout the request state will be set to KSI_ASYNC_STATE_ERROR and error to KSI_NETWORK_SEND_TIMEOUT.
|
| KSI_ASYNC_OPT_REQUEST_CACHE_SIZE | Maximum parallel running request count. New value may not be less than the allready set value. Default setting is 1. - Parameters
-
| count | Paramer of type size_t. |
- See also
- KSI_AsyncService_addRequest for adding asynchronous request to the output queue.
|
| KSI_ASYNC_OPT_MAX_REQUEST_COUNT | Maximum number of request permitted per round. Default setting is 1. - Parameters
-
| count | Paramer of type size_t. |
- Note
- In case the maximum number of request is allready sent out during a round interval, additional request will be buffered in intenal cache.
|
| KSI_ASYNC_OPT_PUSH_CONF_CALLBACK | If configured, on reception of KSI_Config the callback is invoked instead of returning the configuration via KSI_AsyncHandle with the state KSI_ASYNC_STATE_PUSH_CONFIG_RECEIVED. - Parameters
-
- Note
- For reading the stored value via KSI_AsyncService_getOption a parameter of type size_t should be used, and casted to KSI_Config_Callback before use.
-
The KSI_CTX push config callback configuration will be overriden by current setting.
- See also
- KSI_OPT_AGGR_CONF_RECEIVED_CALLBACK and KSI_OPT_EXT_CONF_RECEIVED_CALLBACK for KSI_CTX callback configuration.
|
| KSI_ASYNC_OPT_HA_SUBSERVICE_LIST | Get the list of high availability service subservices. - Parameters
-
- Note
- Only functioning as option getter on a high availability service.
-
For reading the stored value via KSI_AsyncService_getOption a parameter of type size_t should be used, and casted to KSI_AsyncServiceList before use.
- See also
- KSI_AsyncService_addEndpoint for adding a subservice to the high availability service.
|
| __KSI_ASYNC_OPT_COUNT | |
◆ KSI_AbstractAsyncClient_new()
Construct an abstract async client object.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | c | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AbstractAsyncHandle_new()
Constructor for the abstract async handle.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | client | Abstract async handle. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncAggregationHandle_new()
Constructor for the async handle object.
- Parameters
-
| [in] | ctx | KSI context. |
| [in] | req | Aggregation request. |
| [out] | o | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The handle takes ownership of the
req resource, thus it may not be freed after a successful call to this function.
◆ KSI_AsyncClient_free()
◆ KSI_AsyncExtendHandle_new()
Constructor for the async handle object.
- Parameters
-
| [in] | ctx | KSI context. |
| [in] | req | Extend request. |
| [out] | o | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The handle takes ownership of the provided request resource, thus they may not be freed after a successful call to this function.
- See also
- KSI_AsyncService_addRequest for adding asynchronous request to the output queue.
-
KSI_AsyncHandle_getExtendResp for retrieving extend response.
◆ KSI_AsyncExtendingHandle_new()
Constructor for the async handle object for extending provided KSI signature.
- Parameters
-
| [in] | ctx | KSI context. |
| [in] | sig | KSI signature to be extended. |
| [in] | pubRec | Publication record (optional). |
| [out] | o | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The handle
o will make copies of the resources, thus it is users responsibility to clean up input resources after a successful call to this function.
- See also
- KSI_AsyncService_addRequest for adding asynchronous request to the output queue.
-
KSI_AsyncHandle_getExtendResp for retrieving extend response.
-
KSI_AsyncHandle_getSignature for retrieving an extended KSI KSI Signature.
◆ KSI_AsyncHandle_free()
Async handle object resource cleanup method.
- Parameters
-
| [in] | o | Instance to be freed. |
◆ KSI_AsyncHandle_getAggregationReq()
Getter for the aggregation request.
- Parameters
-
| [in] | h | Async handle. |
| [out] | req | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncHandle_getAggregationResp()
◆ KSI_AsyncHandle_getConfig()
Server push configuration getter.
- Parameters
-
| [in] | h | Async handle. |
| [out] | config | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- A valid configuration will only be returned if the handle state is KSI_ASYNC_STATE_PUSH_CONFIG_RECEIVED.
- See also
- KSI_AsyncHandle_getState for getting the state of the request.
-
KSI_Config_free for cleaning up returned resources.
◆ KSI_AsyncHandle_getError()
◆ KSI_AsyncHandle_getErrorMessage()
◆ KSI_AsyncHandle_getExtendReq()
Getter for the extend request.
- Parameters
-
| [in] | h | Async handle. |
| [out] | req | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncHandle_getExtendResp()
Getter for the extend response.
- Parameters
-
| [in] | h | Async handle. |
| [out] | resp | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncHandle_getSignature for getting a verified KSI Signature.
◆ KSI_AsyncHandle_getExtError()
Get the external error code for the request which state is KSI_ASYNC_STATE_ERROR.
- Parameters
-
| [in] | h | Async handle. |
| [out] | ext | Handle error message. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncHandle_getState for getting the state of the request.
◆ KSI_AsyncHandle_getRequestCtx()
| int KSI_AsyncHandle_getRequestCtx |
( |
const KSI_AsyncHandle * |
o, |
|
|
const void ** |
reqCtx |
|
) |
| |
Getter for the request specific context.
- Parameters
-
| [in] | o | Async handle object. |
| [out] | reqCtx | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncHandle_getRequestId()
Get the request ID.
- Parameters
-
| [in] | h | Async handle. |
| [out] | id | Request ID. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The value is only valid after a successful call to KSI_AsyncService_addRequest.
- See also
- KSI_AsyncService_addRequest for adding asynchronous request to the output queue.
◆ KSI_AsyncHandle_getSignature()
KSI signature getter. The returned signature is verified internally.
- Parameters
-
| [in] | h | Async handle. |
| [out] | signature | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The returned resources must be freed by the caller.
-
The signature will only be returned if the handle state is KSI_ASYNC_STATE_RESPONSE_RECEIVED.
- See also
- KSI_AsyncHandle_getState for getting the state of the request.
-
KSI_Signature_free for cleaning up returned resources.
◆ KSI_AsyncHandle_getState()
◆ KSI_AsyncHandle_ref()
- Increases the inner reference count of that object. *
- Parameters
-
- Returns
- Returns the input pointer on success or
NULL on error. *
- See also
- KSI_AsyncHandle_free
◆ KSI_AsyncHandle_setRequestCtx()
| int KSI_AsyncHandle_setRequestCtx |
( |
KSI_AsyncHandle * |
o, |
|
|
void * |
reqCtx, |
|
|
void(*)(void *) |
reqCtx_free |
|
) |
| |
Setter for the request user private context.
- Parameters
-
| [in] | o | Async handle object. |
| [in] | reqCtx | Request context. |
| [in] | reqCtx_free | Pointer to the context cleanup method. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncService_addEndpoint()
| int KSI_AsyncService_addEndpoint |
( |
KSI_AsyncService * |
service, |
|
|
const char * |
uri, |
|
|
const char * |
loginId, |
|
|
const char * |
key |
|
) |
| |
◆ KSI_AsyncService_addRequest()
Non-blocking aggregation request setter. All request are put into output queue untill, they are sent during KSI_AsyncService_run call.
- Parameters
-
| [in] | service | Async service instance. |
| [out] | handle | Async handle associated with the request. |
- Returns
- KSI_OK, when operation succeeded;
-
KSI_ASYNC_REQUEST_CACHE_FULL, if the internal cache is full. In this case the caller should wait for responses, or process received responses;
-
otherwise an error code.
- Note
- The async service
s takes ownership of req request on a successful call to this function, thus the caller may not clear the memory.
- See also
- KSI_SigningAsyncService_new for creating a new signing async service instance.
-
KSI_AsyncAggregationHandle_new for creating a new async request instance.
-
KSI_AsyncHandle_free for cleaning up resources in case of a failure.
-
KSI_AsyncService_run for handling communication towards service endpoint.
-
KSI_ASYNC_OPT_REQUEST_CACHE_SIZE for increasing the cache size.
◆ KSI_AsyncService_free()
Free async service object.
- Parameters
-
| [in] | service | Async serivce object. |
◆ KSI_AsyncService_getOption()
| int KSI_AsyncService_getOption |
( |
const KSI_AsyncService * |
s, |
|
|
const int |
option, |
|
|
void * |
value |
|
) |
| |
Async service option getter.
- Parameters
-
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncOption defines supported options and parameter types.
-
KSI_AsyncService_setOption for applying option values.
◆ KSI_AsyncService_getPendingCount()
Get the number of requests that have been sent or are still in send queue.
- Parameters
-
| [in] | s | Async service instance. |
| [out] | count | Pointer to the value. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
◆ KSI_AsyncService_getReceivedCount()
Get the number of request that have received a response and are ready to be extracted from async service s.
- Parameters
-
| [in] | s | Async service instance. |
| [out] | count | Pointer to the value. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncService_run for extracting received responses.
◆ KSI_AsyncService_run()
Non-blocking send/receive worker. The method will open a connection to remote service, dispatch cached requests and map the received responses. The method has to be called multiple times in order for all request to be processed.
- Parameters
-
| [in] | service | Async service instance. |
| [out] | handle | Async handle associated with a request. |
| [out] | waiting | Total number of requests in process. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- The
waiting count can be ignored by setting it to NULL.
-
The returned
handle will be set to NULL if there is no response in queue.
- See also
- KSI_AsyncService_addRequest for adding asynchronous request to the output queue.
-
KSI_AsyncHandle_getState for getting the state of the request.
-
KSI_AsyncService_getPendingCount for requests in process.
-
KSI_AsyncService_getReceivedCount for received responses.
◆ KSI_AsyncService_setEndpoint()
| int KSI_AsyncService_setEndpoint |
( |
KSI_AsyncService * |
service, |
|
|
const char * |
uri, |
|
|
const char * |
loginId, |
|
|
const char * |
key |
|
) |
| |
◆ KSI_AsyncService_setOption()
| int KSI_AsyncService_setOption |
( |
KSI_AsyncService * |
s, |
|
|
const int |
option, |
|
|
void * |
value |
|
) |
| |
Async service option setter.
- Parameters
-
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncOption defines supported options and parameter types.
-
KSI_AsyncService_getOption for extracting option values.
- Note
- Before appling any options the service endpoint has to be configured.
◆ KSI_ExtendingAsyncService_new()
Creates and initalizes a concrete async service object to be used to interract with extender endpoint.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | service | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncService_free
-
KSI_AsyncService_setEndpoint for setting up an endpoint.
◆ KSI_ExtendingHighAvailabilityService_new()
Creates and initalizes a concrete HA async service object to be used to interract with extender endpoint.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | service | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncService_addEndpoint for adding subservices.
-
KSI_AsyncService_free
◆ KSI_SigningAsyncService_new()
Creates and initalizes a concrete async service object to be used to interract with aggregator endpoint.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | service | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncService_free
-
KSI_AsyncService_setEndpoint for setting up an endpoint.
◆ KSI_SigningHighAvailabilityService_new()
Creates and initalizes a concrete HA async service object to be used to interract with aggregator endpoint.
- Parameters
-
| [in] | ctx | KSI context. |
| [out] | service | Pointer to the receiving pointer. |
- Returns
- Status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_AsyncService_addEndpoint for adding subservices.
-
KSI_AsyncService_free