Pan is a high performance and stable production side agent of messager-oriented middleware written in pure Go language. It supports mainstream message queues in the market, such as Kafka, RabbitMQ, RocketMQ, NSQ, etc. Moreover, it is easy to be extended and can meet different business requirements in the production environment.
The framework of Pan is shown as below.
./bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
./bin/kafka-server-start /usr/local/etc/kafka/server.properties
./bin/kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
[KafkaProxy]
enable=true
KafkaWaitAll=true
KafkaCompression=true
KafkaPartitioner=round
KafkaProducerTimeout=10
brokers=localhost:9092
sasl=false
user=
password=
valid= //topic whitelist,if empty, all topic can be sended
failMode=retry/save/discard
tar -zxvf pan.tar.gz
cd pan/
make
./bin/pan -c ../conf/conf.ini
package main
import (
"fmt"
"time"
"github.com/tal-tech/xtools/kafkautil"
"github.com/spf13/cast"
)
func main() {
t := time.Tick(5 * time.Second)
count := 0
for {
select {
case <-t:
count++
err := kafkautil.Send2Proxy("test", []byte("kafka "+cast.ToString(count)))
if err != nil {
fmt.Println(err)
}
continue
}
}
}
[KafkaProxy]
unix=/home/www/pan/pan.sock //sock in pan
host=localhost:9999 //ip and post pan listen
replace in go.mod
replace github.com/henrylee2cn/teleport v5.0.0+incompatible => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0
或
replace github.com/henrylee2cn/teleport v0.0.0 => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0
(微信扫一扫,申请加入开发讨论微信群)