From 983aeeb33d41716b11d3aaca175f2cc13a1e48d5 Mon Sep 17 00:00:00 2001 From: Romanenko Alexey Date: Fri, 13 Mar 2020 23:06:44 +0700 Subject: [PATCH] #446 fix context (#484) --- gorush/notification.go | 2 +- gorush/worker.go | 4 ++-- rpc/server.go | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gorush/notification.go b/gorush/notification.go index 61a5516..ff2fe7f 100644 --- a/gorush/notification.go +++ b/gorush/notification.go @@ -52,7 +52,7 @@ type RequestPush struct { // PushNotification is single notification request type PushNotification struct { - ctx context.Context + Ctx context.Context wg *sync.WaitGroup log *[]LogPushEntry diff --git a/gorush/worker.go b/gorush/worker.go index 4ebf4c1..5e0183d 100644 --- a/gorush/worker.go +++ b/gorush/worker.go @@ -22,7 +22,7 @@ func SendNotification(req PushNotification) { } select { - case <-req.ctx.Done(): + case <-req.Ctx.Done(): default: switch req.Platform { case PlatFormIos: @@ -72,7 +72,7 @@ func queueNotification(ctx context.Context, req RequestPush) (int, []LogPushEntr log := make([]LogPushEntry, 0, count) for _, notification := range newNotification { - notification.ctx = ctx + notification.Ctx = ctx if PushConf.Core.Sync { notification.wg = &wg notification.log = &log diff --git a/rpc/server.go b/rpc/server.go index a206634..3c02289 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -50,6 +50,8 @@ func (s *Server) Check(ctx context.Context, in *proto.HealthCheckRequest) (*prot func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) { var badge = int(in.Badge) notification := gorush.PushNotification{ + Ctx: ctx, + Platform: int(in.Platform), Tokens: in.Tokens, Message: in.Message,