nsg-0.3.0 API Changes

Source: Internet
Author: User

NSQ is a real-time message processing system developed by the well-known short-link service provider bitly with the Go language, which has the advantages of high performance, high reliability, ignoring single point of failure, and is a very good emerging Message Queuing solution.

Nsgs are easy to configure and deploy, all references are specified through the command line, compiled binaries, and no other dependencies. It also supports multiple message formats.

Introduction to NSQ See here: http://www.oschina.net/translate/day-22-a-journey-into-nsq

Official website: http://nsq.io/overview/quick_start.html

The API is better than before.

directly on the code.

 PackageMainImport (    "GITHUB.COM/BITLY/GO-NSQ" "FMT" "Time") type Handle struct{Msgchan Chan*nsq. Message Stop Bool}func (H*handle) handlemsg (M *nsq. Message) Error {if!stop{H.msgchan<-m}returnNil}func (H*Handle) Process () {h.stop=false     for{select{ CaseM: = <-h.msgchan:fmt.            Println (String (m.body));  Case<-Time . After (time. Second):ifh.stop{Close (H.msgchan)return}}}}func (H*Handle) Stop () {h.stop=true}func Main () {config:=nsq. Newconfig () Consumer, err:= nsq. Newconsumer ("Test", "my", config)ifErr! =nil{Panic (Err)} h:=New(Handle) consumer. AddHandler (NSQ. Handlerfunc (h.handlemsg)) H.msgchan= Make (Chan *nsq. Message, 1024) Err= consumer. CONNECTTONSQD ("127.0.0.1:4150")    ifErr! =nil{Panic (Err)} h.process ()}

nsg-0.3.0 API Changes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.