Total Pageviews

Monday, 11 July 2016

基于go的push服务器程序-pusher


pusher is a push server written by golang.

Features

  • Light weight
  • High performance
  • Pure Golang
  • Embeddable
  • Supports single push and pushall
  • Supports push or pushall with a schedule time
  • Scalable architecture (Unlimited dynamic message and sender modules)
  • Asynchronous push notification based on Periodic task system

Install

go get -v github.com/Lupino/pusher
cd $GOPATH/src/github.com/Lupino/pusher
go install ./...

Getting start with pusher command

First start the needed server

Second start pusher api server

  • Start pusher api server with the command pusher
  • The pusher api server default run on http://localhost:6000

Third start pusher worker

  • Go to https://sendgrid.com/ register an account and get the key and user
  • Go to http://www.alidayu.com/ register an account and build an app, then get the app key and app secret
  • Start pusher worker with the command
pusher_worker -sendgrid_key=sgKey \
              -sendgrid_user=sgUser \
              -from=example@example.com \
              -from_name=example \
              -alidayu_key=alidayuAppKey \
              -alidayu_secret=alidayuAppSecret

Fourth push the message with curl

  • Create a pusher
curl -i http://localhost:6000/pusher/pushers/ \
     -d pusher=lupino \
     -d email=example@example.com \
     -d phoneNumber=12345678901 \
     -d nickname=xxxxx \
     -d createdAt=1456403493
  • Add sender to pusher
curl -i http://localhost:6000/pusher/sendmail/add -d pusher=lupinno
curl -i http://localhost:6000/pusher/sendsms/add -d pusher=lupinno
  • Push a message
curl -i http://localhost:6000/pusher/sendmail/push \
     -d pusher=lupino \
     -d data='{"subject": "subject", "text": "text"}'
from  https://github.com/Lupino/pusher