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

Gorush: A push notification server written in Go

Editor's Notes

  • #5 上述這些專案都已經有導入上市公司或新創團隊 簡單介紹 coscup 我會講 gitea + drone DevOps Day 我會深入講 drone
  • #6 上述這些專案都已經有導入上市公司或新創團隊 簡單介紹 coscup 我會講 gitea + drone DevOps Day 我會深入講 drone
  • #18 Response time 非常久 …
  • #49  大家都知道藍新系統 昨天還前天做捯好事吧 missing https