mirror of
https://github.com/Netflix/dial-reference.git
synced 2026-06-08 10:59:59 +00:00
jira SDK-5322: DIAL client that supports 2.1 and higher SHOULD include a clientDialVer query parameter while querying application status
This commit is contained in:
@@ -68,6 +68,10 @@ int DialServer::sendCommand(
|
|||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
struct curl_slist *slist = NULL;
|
struct curl_slist *slist = NULL;
|
||||||
|
|
||||||
|
// since we are Dial Version 2.1, added query paramter to indicate Dial Version
|
||||||
|
url += "?clientDialVer=";
|
||||||
|
url += CLIENT_VERSION;
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
|
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "curl_global_init() failed\n");
|
fprintf(stderr, "curl_global_init() failed\n");
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#define CLIENT_VERSION "2.1"
|
||||||
|
|
||||||
class DialServer
|
class DialServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -183,6 +183,13 @@ static void handle_app_status(struct mg_connection *conn,
|
|||||||
int canStop = 0;
|
int canStop = 0;
|
||||||
DIALServer *ds = request_info->user_data;
|
DIALServer *ds = request_info->user_data;
|
||||||
|
|
||||||
|
// determin client version
|
||||||
|
char *clientVersionStr = parse_param(request_info->query_string, "clientDialVer");
|
||||||
|
double clientVersion = 0.0;
|
||||||
|
if (clientVersionStr){
|
||||||
|
clientVersion = atof(clientVersionStr);
|
||||||
|
}
|
||||||
|
|
||||||
ds_lock(ds);
|
ds_lock(ds);
|
||||||
app = *find_app(ds, app_name);
|
app = *find_app(ds, app_name);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
@@ -217,8 +224,16 @@ static void handle_app_status(struct mg_connection *conn,
|
|||||||
|
|
||||||
app->state = app->callbacks.status_cb(ds, app_name, app->run_id, &canStop,
|
app->state = app->callbacks.status_cb(ds, app_name, app->run_id, &canStop,
|
||||||
app->callback_data);
|
app->callback_data);
|
||||||
|
|
||||||
|
DIALStatus localState = app->state;
|
||||||
|
|
||||||
|
// overwrite app->state if cilent version < 2.1
|
||||||
|
if (clientVersion < 2.09 && localState==kDIALStatusHide){
|
||||||
|
localState=kDIALStatusStopped;
|
||||||
|
}
|
||||||
|
|
||||||
char dial_state_str[20];
|
char dial_state_str[20];
|
||||||
switch(app->state){
|
switch(localState){
|
||||||
case kDIALStatusHide:
|
case kDIALStatusHide:
|
||||||
strcpy (dial_state_str, "hidden");
|
strcpy (dial_state_str, "hidden");
|
||||||
break;
|
break;
|
||||||
@@ -250,7 +265,7 @@ static void handle_app_status(struct mg_connection *conn,
|
|||||||
app->name,
|
app->name,
|
||||||
canStop ? "true" : "false",
|
canStop ? "true" : "false",
|
||||||
dial_state_str,
|
dial_state_str,
|
||||||
app->state == kDIALStatusStopped ?
|
localState == kDIALStatusStopped ?
|
||||||
"" : " <link rel=\"run\" href=\"run\"/>\r\n",
|
"" : " <link rel=\"run\" href=\"run\"/>\r\n",
|
||||||
dial_data);
|
dial_data);
|
||||||
ds_unlock(ds);
|
ds_unlock(ds);
|
||||||
|
|||||||
Reference in New Issue
Block a user