Page 1
A push notification server written in Go
1
Bo-Yi WuMopcon @ 2017.10.28
Page 2
Why I create the Gorush Project?
Detail implementation in Golang
Testing and deploy Go project.
Run Gorush in Kubernetes.
2
Page 3
Mediatek Engineer DevOps Golang, PHP, Node.js ..
Some open source Gitea Gin Drone
appleboy @GitHub appleboy @twitter appleboy @slideshare appleboy46 @facebook
3
Page 4
drone/drone go-gitea/gitea gin-gonic/gin appleboy/gorush
4
Page 5
drone/drone go-gitea/gitea gin-gonic/gin appleboy/gorush
5
Page 6
https://mcs.mediatek.com/6
Page 7
MediatekCloud
Sandbox
Trigger
Push
Email
hook
MQTT
TCP
HTTP
7
Page 8
MediatekCloud
Sandbox
Trigger
Push
Email
hook
MQTT
TCP
HTTP
8Forcus on Push notification
Page 9
https://github.com/appleboy/gorush
9
Page 10
A general push notification server
for smartphone application
10
Page 11
Written in GoPush requests to APNs and FCMSimple HTTP APIs (JSON)RPC Protocol (gRPC)
11
Page 12
Client
FCM
APNs
Gorush
POST /push
JSON Body
HTTPS
APNsProtocol
12
Page 13
System RequirementGood PerformanceHigh Concurrency
Simple net/http Package
Easy to Learn
13
Page 14
https://github.com/golang/go/wiki/FromXToGo
14
Page 15
https://github.com/golangtw/jobs
15
Page 17
FCM
APNs
API Server
API Server
API Server
PUSH
17
Page 18
FCM
APNs
Worker
Worker
Worker
PUSHQueue
API
API
API
de-queue
Asynchronous Notification
AWSen-queue
18
Page 19
NginxTraefik
FCM
APNs
Gorush
Gorush
Gorush
PUSH
API
API
API
HttpPost /push
Gorush = Queue + Worker19
Page 20
How to implement simple notification service
20
Page 21
Client
FCM
APNs
Gorush
POST /push
JSON Body
HTTPS
APNsProtocol
21
Page 22
Http Server gRPC ServerPush API Worker
22
Page 30
GET /api/stat/goGET /api/stat/appGET /sys/statsGET /metricsPOST /api/pushGET /healthz
30
Page 35
$ for i in {1..99999}; do bat -b.N=1000 -b.C=100 POST local:8088/api/push35
Page 37
https://github.com/appleboy/gorush/#post-apipush
37
Page 38
Push API Support Sync Mode
38
Page 39
Notification
Notification
Notification
Notification
worker
worker
worker
Client
Notificationworker
WaitGroup
39
Page 40
Notification Log
Wait response
Send to Work Queue
40
Page 43
$ gorush –c config.yml
43
Page 44
$ GORUSH_CORE_PORT=8089 gorush
44
Page 45
/etc/gorush/config.yml $HOME/.gorush/config.yml . (Current Folder)
45
Page 46
Server Confg
Route Config46
Page 47
Server Config
Route Config47
Page 48
48
Integrate Let's Encrypt
Page 50
https://goo.gl/pfeC5Q
50
Page 51
Android Config
iOS Config
Log Config51
Page 52
API Key From Request
52
Page 53
53
Supports new Apple Token Based Authentication (JWT)
Page 56
memory, blotdb, buntdb, leveldb, redis
56
Page 61
Docker Container
61
Page 63
$ gorush -android –m="message" -k="API Key" –t="token"
63
Page 64
$ gorush -ios -m="message" -i="certificate path"
-t="token" -topic="topic"
64
Page 65
write once run anywhere
65
Page 66
https://github.com/mitchellh/gox
66
Page 68
https://github.com/facebookgo/grace
68
Page 69
How to resolve this problem?
69
Page 70
// +build windows
https://golang.org/pkg/go/build/
70
Page 73
$ docker build -t appleboy/gorush .
https://goo.gl/zQbhmu
73
Page 76
Continuous Delivery system
built on container technology
76
Page 77
77
Using .drone.yml file
Page 78
Git Test Release Docker Notify
78
Page 79
Testing Code
Analytic Code
Code Quality
Build Binary
Deploy Binary
Build Docker Image
Deploy Docker Container
Send Notification
79
Page 80
Git Test Release Docker Notify
80
Page 82
Git Test Release Docker Notify
82
Page 83
Choose Image
Testing Process
83
Page 88
$ coverage all
https://github.com/appleboy/golang-testing
88
Page 89
Git Test Release Docker Notify
89
Page 90
Choose Image
Step Name
Run on for Git tag event
90
Page 93
Git Test Release Docker Notify
93
Page 94
Drone Envars
Drone Secrets
Plugin Image
94
Page 95
Git Test Release Docker Notify
95
Page 102
$ kubectl create -f k8s
$ kubectl get services
$ minikube service frontend
102
Page 103
http://bit.ly/devops-drone
103
Page 104
Thanks All coming.
104