Skip to content

Commit

Permalink
Setting apps config as variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Souza committed Sep 27, 2017
1 parent 350eb2b commit 8fedff6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
14 changes: 8 additions & 6 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ gracefulShutdownTimeout: 30
apns:
concurrentWorkers: 100
logStatsInterval: 10000
# games:
# game: /certs/cert.pem
apps: "game"
certs:
game: /certs/cert.pem
gcm:
pingInterval: 30
pingTimeout: 10
maxPendingMessages: 100
logStatsInterval: 10000
# games:
# game:
# apiKey: game-api-key
# senderID: "1233456789"
apps: "game"
certs:
game:
apiKey: game-api-key
senderID: "1233456789"
queue:
topics:
- "^push-[^-_]+_(apns|gcm)[_-](single|massive)"
Expand Down
6 changes: 4 additions & 2 deletions config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ gracefulShutdownTimeout: 10
apns:
concurrentWorkers: 100
logStatsInterval: 750
games:
apps: "game"
certs:
game: ../tls/self_signed_cert.pem
gcm:
pingInterval: 30
pingTimeout: 10
maxPendingMessages: 3
logStatsInterval: 750
games:
apps: "game"
certs:
game:
apiKey: game-api-key
senderID: "1233456789"
Expand Down
10 changes: 6 additions & 4 deletions pusher/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -107,14 +108,15 @@ func (a *APNSPusher) configure(queue interfaces.APNSPushQueue, db interfaces.DB,
}
a.MessageHandler = make(map[string]interfaces.MessageHandler)
a.Queue = q

for k, v := range a.Config.GetStringMap("apns.games") {
l.Info("Configuring messageHandler")
for _, k := range strings.Split(a.Config.GetString("apns.apps"), ",") {
cert := a.Config.GetString("apns.certs." + k)
l.Infof(
"Configuring messageHandler for game %s with certificate: %s",
k, v,
k, cert,
)
handler, err := extensions.NewAPNSMessageHandler(
v.(string),
cert,
a.IsProduction,
a.Config,
a.Logger,
Expand Down
3 changes: 2 additions & 1 deletion pusher/gcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -113,7 +114,7 @@ func (g *GCMPusher) configure(client interfaces.GCMClient, db interfaces.DB, sta
}
g.Queue = q
g.MessageHandler = make(map[string]interfaces.MessageHandler)
for k := range g.Config.GetStringMap("gcm.games") {
for _, k := range strings.Split(g.Config.GetString("gcm.apps"), ",") {
senderID := g.Config.GetString("gcm.certs." + k + ".senderID")
apiKey := g.Config.GetString("gcm.certs." + k + ".apiKey")
l.Infof(
Expand Down

0 comments on commit 8fedff6

Please sign in to comment.