All Projects → felinx → nsqworker

felinx / nsqworker

Licence: Apache-2.0 license
A skeletal guide of one way to implement a nsq consumer

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Labels

Projects that are alternatives of or similar to nsqworker

funboost
pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和全球一切知名消息队列中间件,python函数加速器,框架包罗万象,一统编程思维,兼容50% python编程业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数。旧名字是function_scheduling_distributed_framework
Stars: ✭ 351 (+716.28%)
Mutual labels:  nsq
gobroker
golang wrapper for all (to-be) kinds of message brokers
Stars: ✭ 15 (-65.12%)
Mutual labels:  nsq
go-starter
Go 服务框架脚手架. 整合 echo、swag、viper、nsq、logrus、fx、xorm、cobra 等第三方库
Stars: ✭ 145 (+237.21%)
Mutual labels:  nsq
go-graphql-subscription-example
☝️ go-graphql subscription over Kafka/Redis/NSQ example
Stars: ✭ 34 (-20.93%)
Mutual labels:  nsq
Go Nsq
The official Go package for NSQ
Stars: ✭ 2,045 (+4655.81%)
Mutual labels:  nsq
Nsq
A realtime distributed messaging platform
Stars: ✭ 20,663 (+47953.49%)
Mutual labels:  nsq
lua-resty-nsq
lua-resty-nsq - Lua nsq client driver for the ngx_lua based on the cosocket API
Stars: ✭ 18 (-58.14%)
Mutual labels:  nsq
triton
Triton is a high-performance mq consumer, support kafka,rabbit-mq,rocketmq,nsq and other mq
Stars: ✭ 19 (-55.81%)
Mutual labels:  nsq
go-nsq
No description or website provided.
Stars: ✭ 57 (+32.56%)
Mutual labels:  nsq
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (+213.95%)
Mutual labels:  nsq
verticegateway
REST API server with built in auth, interface to ScyllaDB/Cassandra
Stars: ✭ 25 (-41.86%)
Mutual labels:  nsq
nsqproxy
NSQProxy是NSQ和Worker之间的中间件,根据配置负责消息转发。然后通过HTTP/FastCGI/CBNSQ等协议转发给Worker机执行。
Stars: ✭ 79 (+83.72%)
Mutual labels:  nsq
nsq-0.3.7
nsq注释版基于0.3.7版本
Stars: ✭ 45 (+4.65%)
Mutual labels:  nsq
pan
Pan is a high performance mq proxy,support kafka,rabbit-mq,rocketmq,nsq and other mq
Stars: ✭ 27 (-37.21%)
Mutual labels:  nsq
nsqclient-php
Yet another PHP client for NSQ
Stars: ✭ 19 (-55.81%)
Mutual labels:  nsq

Overview

nsqworker is a skeletal code of one way to implement nsq consumer(worker) in Python base on pynsq.

Installation

pip install nsqworker

Demo

Go to nsqworker root folder and run:

python bootstrap.py

Publish a message to topic demo:

curl -d '{"clicks": 10}' 'http://127.0.0.1:4151/put?topic=demo'

then the demo worker will output:

demo: demo/pageview, clicks 10

If run bootstrap.py in command like below:

python bootstrap.py --topic=newtopic --channel=newchannel

It will try to run NewtopicNewchannelWorker from workers/newtopic/newtopic_newchannel_worker.py which subscribes messages of newtopic/newchannel, of course, you need implement this worker.

Conventions

  1. Keep all of nsq workers of a topic in a sub-folder named the same as the topic name, eg. nsqworker/workers/demo/
  2. Create a channel's worker in a file named {topic}/{topic}_{channel}_worker.py, eg. workers/demo/demo_pageview_worker.py
  3. Implement the channel worker class, it should inherit from nsqworker.Worker, eg. DemoPageviewWorker(Worker)
  4. Add a functional endswith "_handler"(eg. demo_handler) in the worker to handle messages, this functional will be treated as a message_handler in pynsq automatically, you can add more than one handlers.

It is easy to implement a customize consumer follow this conventions.

Customize your bootstrap.py

from nsqworker.bootstrap import run
# Customize workers_module which default value is nsqworker.workers(The root module of demo workers)
# You should set it to yourpackage.workers.
run("yourpackage.workers")

Then it will load and run workers under yourpackage.workers like nsqworker.bootstrap.py

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].