GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - chensoft/lua-kafka

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
rockspec
rockspec
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

lua-kafka

Lua bindings for Apache Kafka librdkafka library

Prepare

Debian/Ubuntu

apt install librdkafka-dev

MacOS

brew install librdkafka

Other OS

see https://github.com/edenhill/librdkafka

Install

build with cmake or run luarocks install kafka

Kafka

  • producer(app_conf)
  • consumer(app_conf)

Producer

  • produce(topic, payload)
  • poll(timeout_ms)
  • flush(timeout_ms)
  • delivery_failures() -- count of delivery failures since the last call (resets to 0)
  • close()
local settings = {["bootstrap.servers"] = "localhost:9092"}
local producer = require("kafka").producer(settings)

for i = 1, 100 do
    print("send message " .. i)
    producer:produce("hello1", "Hello World! " .. i)
    producer:produce("hello2", i .. " Hello World!")
end

producer:poll(5000)
producer:close()

Consumer

  • subscribe(...) // topics
  • poll(timeout_ms)
  • close()
local settings = {["bootstrap.servers"] = "localhost:9092", ["group.id"] = "1", ["auto.offset.reset"] = "earliest"}
local consumer = require("kafka").consumer(settings)

consumer:subscribe("hello1", "hello2")

while true do
    local message = consumer:poll(1000)
    if message then
        print(string.format("recv message topic %s, partition %d, payload %s, key %s, offset %d", message.topic, message.partition, message.payload, message.key, message.offset))
    end
end

License

lua-kafka is released under the MIT License. See the LICENSE file for more information.

Contact

You can contact me by email: [email protected].

About

No description, website, or topics provided.

Resources

Readme
MIT license
Activity

Stars

6 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.