#446 fix context (#484)

This commit is contained in:
Romanenko Alexey 2020-03-13 23:06:44 +07:00 committed by GitHub
parent 44bf37941b
commit 983aeeb33d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -52,7 +52,7 @@ type RequestPush struct {
// PushNotification is single notification request // PushNotification is single notification request
type PushNotification struct { type PushNotification struct {
ctx context.Context Ctx context.Context
wg *sync.WaitGroup wg *sync.WaitGroup
log *[]LogPushEntry log *[]LogPushEntry

View File

@ -22,7 +22,7 @@ func SendNotification(req PushNotification) {
} }
select { select {
case <-req.ctx.Done(): case <-req.Ctx.Done():
default: default:
switch req.Platform { switch req.Platform {
case PlatFormIos: case PlatFormIos:
@ -72,7 +72,7 @@ func queueNotification(ctx context.Context, req RequestPush) (int, []LogPushEntr
log := make([]LogPushEntry, 0, count) log := make([]LogPushEntry, 0, count)
for _, notification := range newNotification { for _, notification := range newNotification {
notification.ctx = ctx notification.Ctx = ctx
if PushConf.Core.Sync { if PushConf.Core.Sync {
notification.wg = &wg notification.wg = &wg
notification.log = &log notification.log = &log

View File

@ -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) { func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) {
var badge = int(in.Badge) var badge = int(in.Badge)
notification := gorush.PushNotification{ notification := gorush.PushNotification{
Ctx: ctx,
Platform: int(in.Platform), Platform: int(in.Platform),
Tokens: in.Tokens, Tokens: in.Tokens,
Message: in.Message, Message: in.Message,