Skip to content

AbrJA/fRanz

 
 

Repository files navigation

fRranz: An R Kafka Client

Lifecycle badge

THIS PROJECT IS STILL ALPHA CURRENTLY -- Check back often!!

What is fRanz

fRanz is an open source R kafka client that allows users to read and write messages from kafka. It leverages the stability and performance of librdkafka and implements ididiomatic R workflows ontop of it.

Installation

  • Clone the repository

  • Build the library locally devtools::install_local("./fRanz/")

Example of sending and reading a message

library(fRanz)

BROKER_HOST <- 'localhost'
BROKER_PORT <- 9092
TOPIC_NAME <- 'myTestTopic'

# KafkaBroker
broker <- KafkaBroker$new(host=BROKER_HOST, port=BROKER_PORT)

# KafkaProducer
producer <- KafkaProducer$new(brokers = list(broker))
producer$produce(topic = TOPIC_NAME,
                 key = "myKey",
                 value = "My First Message")
# Number of messages successfuly sent is returned
# [1] 1 


# KafkaConsumer
consumer <- KafkaConsumer$new(brokers = list(broker), groupId = "test", extraOptions=list(`auto.offset.reset`="earliest"))
consumer$subscribe(topics = c(TOPIC_NAME))
result <- consumer$consume(topic=TOPIC_NAME)

result
# Consumed messages are returned in a list(list(key,val)) format
# [[1]]
# [[1]]$key
# [1] "myKey"
#
# [[1]]$payload
# [1] "My First Message" 

About

R client for Apache Kafka

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 51.7%
  • C++ 42.6%
  • Makefile 5.1%
  • C 0.6%