From: Frederik Vanrenterghem Date: Thu, 13 Sep 2018 13:32:56 +0000 (+0800) Subject: Break out DestroyKafkaConsumer function. X-Git-Url: http://git.vanrenterghem.biz/R/project-using-kafka-in-R.git/commitdiff_plain/9948b03c3477ca42cdff48813f6ed281ad00747a Break out DestroyKafkaConsumer function. --- 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)