Skip to content

Commit

Permalink
Merge pull request #17 from DataINCITE/flynnc3-temp
Browse files Browse the repository at this point in the history
add edge case support for response and heartbeat interaction
  • Loading branch information
flynnc3 authored Apr 19, 2023
2 parents 62a92c7 + c9b6287 commit c921f44
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 c921f44

Please sign in to comment.