From 474cffd4571eb785c25662bb9f484d440cfe1d45 Mon Sep 17 00:00:00 2001 From: Simon Shanks Date: Fri, 3 Apr 2020 09:51:41 +0100 Subject: [PATCH] Function to get solace api info. Ref: #35 --- README.md | 6 ++++++ examples/sol_capabilities.q | 3 +++ source/deltasolace.c | 32 +++++++++++++++++++++----------- source/deltasolace.h | 5 +++++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1c226e3..5909f69 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,12 @@ Destroys the previously created session. ### Utility Functions +``` +K version_solace(K unused); +``` +Returns a dictionary of Solace API version info. Useful for checking current deployment/build versions. + + ``` K iscapable_solace(K capabilityName); ``` diff --git a/examples/sol_capabilities.q b/examples/sol_capabilities.q index c70b050..a3c3f0a 100644 --- a/examples/sol_capabilities.q +++ b/examples/sol_capabilities.q @@ -8,6 +8,7 @@ soloptions:`SESSION_HOST`SESSION_VPN_NAME`SESSION_USERNAME`SESSION_PASSWORD!(`$f .solace.setsessioncallback_solace:`libdeltasolace 2:(`setsessioncallback_solace;1) .solace.setflowcallback_solace:`libdeltasolace 2:(`setflowcallback_solace;1) .solace.init_solace:`libdeltasolace 2:(`init_solace;1) +.solace.version_solace:`libdeltasolace 2:(`version_solace;1) .solace.getcapability_solace:`libdeltasolace 2:(`getcapability_solace;1) .solace.destroy_solace:`libdeltasolace 2:(`destroy_solace;1) @@ -19,6 +20,8 @@ sessionUpdate:{[eventType;responseCode;eventInfo]r:enlist each (`int$eventType;r flowUpdate:{[eventType;responseCode;eventInfo;destType;destName]r:enlist each (`int$eventType;responseCode;eventInfo;destType;destName);0N!("FLOW EVENT: ####";r);r}; .solace.setflowcallback_solace[`flowUpdate]; +("API Version Info: ";.solace.version_solace[1i]) + .solace.init_solace[soloptions] c:`$first params`opt diff --git a/source/deltasolace.c b/source/deltasolace.c index 9fe9348..630d529 100644 --- a/source/deltasolace.c +++ b/source/deltasolace.c @@ -234,7 +234,7 @@ K kdbCallback(I d) solClient_msg_getSenderTimestamp(msg,&sendTime); if (sendTime>0) sendTime=(sendTime*1000000l)-(946684800l*1000000000l); - + K keys = ktn(KS,4); kS(keys)[0]=ss((char*)"isRedeliv"); kS(keys)[1]=ss((char*)"isDiscard"); @@ -286,16 +286,6 @@ K kdbCallback(I d) return (K)0; } -K sendack_solace(K flow, K msgid) -{ - CHECK_PARAM_TYPE(flow,-KJ,"sendack_solace"); - CHECK_PARAM_TYPE(msgid,-KJ,"sendack_solace"); - solClient_opaqueFlow_pt solFlow = (solClient_opaqueFlow_pt)flow->j; - solClient_msgId_t solMsgId = msgid->j; - solClient_returnCode_t retCode = solClient_flow_sendAck (solFlow, solMsgId); - return ki(retCode); -} - /* The message receive callback function is mandatory for session creation. Gets called with msgs from direct subscriptions. */ solClient_rxMsgCallback_returnCode_t defaultSubCallback ( solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p ) { @@ -632,6 +622,16 @@ K destroy_solace(K a) return ki(SOLCLIENT_OK); } +K version_solace(K unused) +{ + solClient_version_info_pt version = NULL; + solClient_version_get (&version); + K keys = knk(3,ks((char*)"solVersion"),ks((char*)"solDate"),ks((char*)"solVariant")); + K vals = knk(3,ks((char*)version->version_p),ks((char*)version->dateTime_p),ks((char*)version->variant_p)); + K dict = xD(keys,vals); + return dict; +} + K setsessioncallback_solace(K callbackFunction) { CHECK_PARAM_TYPE(callbackFunction,-KS,"setsessioncallback_solace"); @@ -1061,6 +1061,16 @@ K subscribepersistent_solace(K type, K endpointname, K topicname, K callbackFunc return ki(SOLCLIENT_OK); } +K sendack_solace(K flow, K msgid) +{ + CHECK_PARAM_TYPE(flow,-KJ,"sendack_solace"); + CHECK_PARAM_TYPE(msgid,-KJ,"sendack_solace"); + solClient_opaqueFlow_pt solFlow = (solClient_opaqueFlow_pt)flow->j; + solClient_msgId_t solMsgId = msgid->j; + solClient_returnCode_t retCode = solClient_flow_sendAck (solFlow, solMsgId); + return ki(retCode); +} + K unsubscribepersistent_solace(K type, K endpointname, K topicname) { CHECK_PARAM_TYPE(endpointname,-KS,"unsubscribepersistent_solace"); diff --git a/source/deltasolace.h b/source/deltasolace.h index fb9286e..2809c17 100644 --- a/source/deltasolace.h +++ b/source/deltasolace.h @@ -22,6 +22,11 @@ extern "C" { */ K init_solace(K options); +/** + * Provides a dictionary of solace API version details. + */ +K version_solace(K unused); + /** * Should be called prior to init_solace. Provides notifications on session events * @param callbackFunction The kdb function to call for session events. The callback function will use 3 params - eventtype, responsecode, eventinfo.