Skip to content

A pure ruby client for Apache Pulsar

License

Notifications You must be signed in to change notification settings

archfish/pulsar_sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A pure ruby client for Apache Pulsar

Respecting Pulsar binary protocol specification

Example

See examples.

Dev

I am using Ruby 2.4 develop this gem, if not work with other Ruby version, PR is welcome.

#!/bin/sh

PB_PATH="./lib/protobuf/"
PB_IN='pulsar_api.proto'
PB_OUT_F='pulsar_api.pb.rb'

mkdir -p ${PB_PATH}

wget -O ${PB_PATH}${PB_IN} https://raw.githubusercontent.com/apache/pulsar/master/pulsar-common/src/main/proto/PulsarApi.proto

# protoc -I ${PULSAR_GIT}/pulsar-common/src/main/proto/ --ruby_out ${PB_PATH} PulsarApi.proto
protoc -I ${PB_PATH} --ruby_out ${PB_PATH} ${PB_IN}
mv ${PB_PATH}pulsar_api_pb.rb ${PB_PATH}${PB_OUT_F}

# fix pulsar.proto.ProtocolVersion error: invalid name `v0' for constant
if [ $(uname) = 'Darwin' ]
then
    suffix='.pbbak'
fi

for i in $(seq 0 15)
do
    sed -i ${suffix} "s;value :v$i, $i;value :V$i, $i;g" ${PB_PATH}${PB_OUT_F}
done

rm -f ${PB_PATH}${PB_OUT_F}.pbbak

protoc -I ${PULSAR_GIT}/pulsar-common/src/main/proto/ --ruby_out ${PB_PATH} PulsarMarkers.proto
mv ${PB_PATH}PulsarMarkers_pb.rb ${PB_PATH}pulsar_markers.pb.rb

Dependency

When macOS user install google-protobuf, there maybe a suffix with universal-darwin save to Gemfile.lock. Please use google-protobuf without universal-darwin suffix. See issuse #6 for detail. Thanks for wppurking's report!

Features

  • Connection
    • Establishment
    • TLS connection
    • Authentication
  • Producer
  • Consumer
    • Flow control
    • Ack
    • Message Redelivery
    • Listen
    • Partitioned topics
    • Topic with regexp (in same namespace)
    • Topic compaction
    • Reader
    • Dead Letter Topic
    • Key Shared
  • Keep alive
    • handle ping command
    • send ping command
  • Service discovery
    • Topic lookup
  • Log Optimization
  • Connection pool
  • Unit Test
  • Thread safe
  • Schema
    • Get
    • Create
  • Admin API
    • Create Namespace
    • List namespaces in current tenant
    • Destroy Namespace
    • List Namespace Topics
    • Create Topic
    • Delete Topic
    • Peek Messages

WIP

Catch up Pulsar client feature matrix, current working on:

  • Dead Letter Topic