From 9948b03c3477ca42cdff48813f6ed281ad00747a Mon Sep 17 00:00:00 2001 From: Frederik Vanrenterghem Date: Thu, 13 Sep 2018 21:32:56 +0800 Subject: [PATCH] Break out DestroyKafkaConsumer function. --- R/DestroyKafkaConsumer.R | 7 +++++++ kafkaConsumer.R | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 R/DestroyKafkaConsumer.R diff --git a/R/DestroyKafkaConsumer.R b/R/DestroyKafkaConsumer.R new file mode 100644 index 0000000..940535a --- /dev/null +++ b/R/DestroyKafkaConsumer.R @@ -0,0 +1,7 @@ +DestroyKafkaConsumer <- function(consumer.base.uri) { + response <- DELETE(url = consumer.base.uri, + content_type("application/vnd.kafka.v2+json")) + if(response$status_code == 204) { + return(TRUE) + } else stop(response) +} \ No newline at end of file diff --git a/kafkaConsumer.R b/kafkaConsumer.R index 6e8fe0b..8b5e6c7 100644 --- a/kafkaConsumer.R +++ b/kafkaConsumer.R @@ -51,5 +51,5 @@ apachelog <- rbind(messages$value,messages2$value) createPlot(apachelog) # Remove the consumer -DELETE(url = consumerDetails$base_uri, - content_type("application/vnd.kafka.v2+json")) +source("R/DestroyKafkaConsumer.R") +response <- DestroyKafkaConsumer(consumer.base.uri = consumerDetails$base_uri) -- 2.39.5