• Stars
    star
    701
  • Rank 64,589 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created about 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kafka, Beanstalkd Pub/Sub framework.

go-queue

dq

High available beanstalkd.

consumer example

consumer := dq.NewConsumer(dq.DqConf{
	Beanstalks: []dq.Beanstalk{
		{
			Endpoint: "localhost:11300",
			Tube:     "tube",
		},
		{
			Endpoint: "localhost:11300",
			Tube:     "tube",
		},
	},
	Redis: redis.RedisConf{
		Host: "localhost:6379",
		Type: redis.NodeType,
	},
})
consumer.Consume(func(body []byte) {
	fmt.Println(string(body))
})

producer example

producer := dq.NewProducer([]dq.Beanstalk{
	{
		Endpoint: "localhost:11300",
		Tube:     "tube",
	},
	{
		Endpoint: "localhost:11300",
		Tube:     "tube",
	},
})	

for i := 1000; i < 1005; i++ {
	_, err := producer.Delay([]byte(strconv.Itoa(i)), time.Second*5)
	if err != nil {
		fmt.Println(err)
	}
}

kq

Kafka Pub/Sub framework

consumer example

config.json

Name: kq
Brokers:
- 127.0.0.1:19092
- 127.0.0.1:19092
- 127.0.0.1:19092
Group: adhoc
Topic: kq
Offset: first
Consumers: 1

example code

var c kq.KqConf
conf.MustLoad("config.json", &c)

q := kq.MustNewQueue(c, kq.WithHandle(func(k, v string) error {
	fmt.Printf("=> %s\n", v)
	return nil
}))
defer q.Stop()
q.Start()

producer example

type message struct {
	Key     string `json:"key"`
	Value   string `json:"value"`
	Payload string `json:"message"`
}


pusher := kq.NewPusher([]string{
	"127.0.0.1:19092",
	"127.0.0.1:19092",
	"127.0.0.1:19092",
}, "kq")

ticker := time.NewTicker(time.Millisecond)
for round := 0; round < 3; round++ {
	select {
	case <-ticker.C:
		count := rand.Intn(100)
		m := message{
			Key:     strconv.FormatInt(time.Now().UnixNano(), 10),
			Value:   fmt.Sprintf("%d,%d", round, count),
			Payload: fmt.Sprintf("%d,%d", round, count),
		}
		body, err := json.Marshal(m)
		if err != nil {
			log.Fatal(err)
		}

		fmt.Println(string(body))
		if err := pusher.Push(string(body)); err != nil {
			log.Fatal(err)
		}
	}
}
cmdline.EnterToContinue()

More Repositories

1

go-zero

A cloud-native Go microservices framework with cli tool for productivity.
Go
29,105
star
2

cds

Data syncing in golang for ClickHouse.
Go
967
star
3

zero-examples

go-zero examples
Go
903
star
4

zero-doc

The docs for go-zero
JavaScript
552
star
5

zeromall

The mall/eshop system based on go-zero.
Go
301
star
6

awesome-zero

A curated list of awesome projects that powered by go-zero.
249
star
7

goctl-swagger

PHP
207
star
8

zero-contrib

A collection of extensions and tools for go-zero.
Go
179
star
9

go-zero-demo

the source code of the go-zero-doc
Go
70
star
10

goctl-go-compact

Go
33
star
11

portal

go-zero official documentation
TypeScript
28
star
12

goctl-intellij

A intellij plugin of goctl
Java
26
star
13

goctl-php

goctl php plugin
Go
22
star
14

x

This repository is part of the go-zero project but outside the main tree. It's developed under looser compatibility requirements than the go-zero project.
Go
20
star
15

go-zero-pages

go-zero-pages is the gitbook document of go-zero. This repository is a managed repository on github pages. Please do not try to add or update files in this repository, because this repository is hosted by https://github.com/zeromicro/go-zero-pages -Docโ€™s github action is automatically built, if you need to submit or update the document, please fork go-zero-doc to modify and submit pr
HTML
20
star
16

goctl-vscode

goctl extension for Visual Studio Code
TypeScript
18
star
17

ddl-parser

A tool to parse mysql ddl.
ANTLR
14
star
18

zero-api

zero-api is a RESTful API description language.
12
star
19

go-zero-doc

The gitbook source for go-zero document
JavaScript
12
star
20

goctl-android

goctl android plugin demo
Go
12
star
21

go-zero-template

A golang template repo for go-zero, Do not accept pr!
Smarty
7
star
22

api-generator

The API file generator.
JavaScript
6
star
23

zero-test

The repo for integration test of go-zero project.
5
star
24

protoc-gen-zrpc-gateway

5
star
25

goctl-plugins

goctl plugins for languages and platforms.
4
star
26

zero-legacy

The legacy mongo/mongoc packages from go-zero.
Go
4
star
27

antlr

forked from antlr/antlr4 and remove another useless code, in order to solve the antlr official module conflict bug
Go
4
star
28

grpc-mock

A gRPC mocking tool.
Go
4
star
29

zero-ci

go-zero continuous integration.
Go
3
star
30

goctl-restclient

Generate Visual Studio Code REST Client plugin files for zero-api
Go
3
star
31

go-zero.dev

go-zero.dev
JavaScript
1
star
32

goctl-vue-element-admin

็”Ÿๆˆvue-element-admin,api/viewsๆ–‡ไปถ
1
star
33

goctl-tool

goctl toolchain plugins
Go
1
star