Skip to content

Commit

Permalink
Function to get solace api info. Ref: #35
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanks-kx committed Apr 3, 2020
1 parent ab4f89c commit 474cffd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand Down
3 changes: 3 additions & 0 deletions examples/sol_capabilities.q
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
32 changes: 21 additions & 11 deletions source/deltasolace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions source/deltasolace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 474cffd

Please sign in to comment.