Skip to content

Commit

Permalink
add edge case support for response and heartbeat interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Conor Flynn committed Apr 19, 2023
1 parent 7d152db commit b58063e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions R-Code-Samples/DataEnginePrimaryFunctions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
else if (grepl("<<<response>>>", temp, fixed=TRUE))
{
temp <- readLines(socket, 1)
while(grepl("<<<heartbeat>>>", temp, fixed=TRUE)) {
temp <- readLines(socket, 1)
}
response <- fromJSON(temp)
break
}
Expand All @@ -122,8 +125,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
print(paste("Processed", counter, "lines for", protocol))
# add data point line to data frame
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
tryCatch(expr={
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
},
error=function(e){
message("Heartbeat execption caught and not parsed.")
})
}
output <- list("response"=response, "df"=df)
Expand Down
12 changes: 10 additions & 2 deletions R-Code-Samples/ExampleUserClusteringStarter.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
else if (grepl("<<<response>>>", temp, fixed=TRUE))
{
temp <- readLines(socket, 1)
while(grepl("<<<heartbeat>>>", temp, fixed=TRUE)) {
temp <- readLines(socket, 1)
}
response <- fromJSON(temp)
break
}
Expand All @@ -140,8 +143,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
print(paste("Processed", counter, "lines for", protocol))
# add data point line to data frame
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
tryCatch(expr={
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
},
error=function(e){
message("Heartbeat execption caught and not parsed.")
})
}
output <- list("response"=response, "df"=df)
Expand Down
12 changes: 10 additions & 2 deletions R-Code-Samples/GetTransactions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
else if (grepl("<<<response>>>", temp, fixed=TRUE))
{
temp <- readLines(socket, 1)
while(grepl("<<<heartbeat>>>", temp, fixed=TRUE)) {
temp <- readLines(socket, 1)
}
response <- fromJSON(temp)
break
}
Expand All @@ -124,8 +127,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end
print(paste("Processed", counter, "lines for", protocol))
# add data point line to data frame
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
tryCatch(expr={
temp.df <- as.data.frame(fromJSON(temp))
df <- rbind.fill(df, temp.df)
},
error=function(e){
message("Heartbeat execption caught and not parsed.")
})
}
output <- list("response"=response, "df"=df)
Expand Down

0 comments on commit b58063e

Please sign in to comment.