示例#1
0
///连接nsq
func ConMsqHandler(w http.ResponseWriter, r *http.Request) {

	r.ParseForm()
	param1, found1 := r.Form["topic"]
	param2, found2 := r.Form["channel"]
	param3, found3 := r.Form["userid"]

	if !found1 || !found2 || !found3 {
		io.WriteString(w, "请勿非法访问")
		return
	}

	topic := param1[0]
	channel := param2[0]
	userid := param3[0]

	nci := models.Messages{
		Topic:   topic,
		Channel: channel,
		UserID:  userid,
	}

	go lib.Connect_Nsq(conadd1, nci)

}
示例#2
0
文件: main.go 项目: aimicm/nsqclient
///nsq客户端服务
func StartNsq() {
	nci := models.Messages{
		Topic:   "test",
		Channel: "Eason",
		UserID:  "00001",
	}
	constr := "nsq-ttthzygi35.tenxcloud.net:40255"
	lib.Connect_Nsq(constr, nci)
}