Skip to content

Commit

Permalink
Fix of disabled domain notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-myles committed Jun 27, 2024
1 parent 5cd30a9 commit 5096553
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/goccy/go-json v0.10.3
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ice-blockchain/eskimo v1.339.0
github.com/ice-blockchain/freezer v1.470.0
github.com/ice-blockchain/eskimo v1.343.0
github.com/ice-blockchain/freezer v1.472.0
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb
github.com/ice-blockchain/wintr v1.142.0
github.com/imroc/req/v3 v3.43.7
Expand All @@ -25,8 +25,8 @@ require (
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/longrunning v0.5.7 // indirect
cloud.google.com/go/iam v1.1.9 // indirect
cloud.google.com/go/longrunning v0.5.8 // indirect
cloud.google.com/go/storage v1.42.0 // indirect
dario.cat/mergo v1.0.0 // indirect
firebase.google.com/go/v4 v4.14.1 // indirect
Expand All @@ -42,7 +42,7 @@ require (
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/bsm/redislock v0.9.4 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/bytedance/sonic v1.11.8 // indirect
github.com/bytedance/sonic v1.11.9 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -64,7 +64,7 @@ require (
github.com/distribution/reference v0.6.0 // indirect
github.com/dmarkham/enumer v1.5.10 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v27.0.1+incompatible // indirect
github.com/docker/docker v27.0.2+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.2 // indirect
Expand Down Expand Up @@ -98,7 +98,7 @@ require (
github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
Expand Down
30 changes: 16 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2Qx
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/firestore v1.15.0 h1:/k8ppuWOtNuDHt2tsRV42yI21uaGnKDEQnRFeBpbFF8=
cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk=
cloud.google.com/go/iam v1.1.8 h1:r7umDwhj+BQyz0ScZMp4QrGXjSTI3ZINnpgU2nlB/K0=
cloud.google.com/go/iam v1.1.8/go.mod h1:GvE6lyMmfxXauzNq8NbgJbeVQNspG+tcdL/W8QO1+zE=
cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuAKilhU=
cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng=
cloud.google.com/go/iam v1.1.9 h1:oSkYLVtVme29uGYrOcKcvJRht7cHJpYD09GM9JaR0TE=
cloud.google.com/go/iam v1.1.9/go.mod h1:Nt1eDWNYH9nGQg3d/mY7U1hvfGmsaG9o/kLGoLoLXjQ=
cloud.google.com/go/longrunning v0.5.8 h1:QThI5BFSlYlS7K0wnABCdmKsXbG/htLc3nTPzrfOgeU=
cloud.google.com/go/longrunning v0.5.8/go.mod h1:oJDErR/mm5h44gzsfjQlxd6jyjFvuBPOxR1TLy2+cQk=
cloud.google.com/go/storage v1.42.0 h1:4QtGpplCVt1wz6g5o1ifXd656P5z+yNgzdw1tVfp0cU=
cloud.google.com/go/storage v1.42.0/go.mod h1:HjMXRFq65pGKFn6hxj6x3HCyR41uSB72Z0SO/Vn6JFQ=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
Expand Down Expand Up @@ -56,8 +56,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ens
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/bytedance/sonic v1.11.8 h1:Zw/j1KfiS+OYTi9lyB3bb0CFxPJVkM17k1wyDG32LRA=
github.com/bytedance/sonic v1.11.8/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic v1.11.9 h1:LFHENlIY/SLzDWverzdOvgMztTxcfcF+cqNsz9pK5zg=
github.com/bytedance/sonic v1.11.9/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
Expand Down Expand Up @@ -257,8 +257,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg=
github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI=
github.com/googleapis/gax-go/v2 v2.12.5 h1:8gw9KZK8TiVKB6q3zHY3SBzLnrGp6HQjyfYBYGmXdxA=
github.com/googleapis/gax-go/v2 v2.12.5/go.mod h1:BUDKcWo+RaKq5SC9vVYL0wLADa3VcfswbOMMRmB9H3E=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
Expand All @@ -282,10 +282,10 @@ github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/ice-blockchain/eskimo v1.339.0 h1:X5BA4yf1sJD+gMCG95wMcW0aiRIM7fImuqhn+AmTV6A=
github.com/ice-blockchain/eskimo v1.339.0/go.mod h1:312jKeVpNmEdjaYb6OEANmUEAsCZkf4Ynm004S0UChM=
github.com/ice-blockchain/freezer v1.470.0 h1:c0VF1SQrh/JyddgmxkcMUsg7ar/OGDVys610hhyzt50=
github.com/ice-blockchain/freezer v1.470.0/go.mod h1:fAqBnHQTyKNa7mytPb149yOewLqM2iSqlM9XaKNeueo=
github.com/ice-blockchain/eskimo v1.343.0 h1:GMIPNwVO283vLT2BW5w/27MlR6nnVndx4bV/EtWQjik=
github.com/ice-blockchain/eskimo v1.343.0/go.mod h1:GgnXx4x78wpFt315Aj917+36aLU5g/94Ohpl+ft++6c=
github.com/ice-blockchain/freezer v1.472.0 h1:YCI7btQuYb5R+1VBQf70OIJYkpshm8mujiSvbnjt9pw=
github.com/ice-blockchain/freezer v1.472.0/go.mod h1:Ep+or4+G74x/r8XBG340v07ov1S+9BWnc2eHqOC+VIY=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8=
github.com/ice-blockchain/wintr v1.142.0 h1:pojlgGyNsbcMh3Hv8v0tD7ahsekneYyeU4UZs5tINnw=
Expand Down Expand Up @@ -363,6 +363,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
Expand Down Expand Up @@ -391,8 +393,8 @@ github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJL
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8=
github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ=
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
Expand Down
2 changes: 2 additions & 0 deletions notifications/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ type (
telemetryNotifications *telemetry
telemetryAnnouncements *telemetry
db *storage.DB
wg *sync.WaitGroup
cancel context.CancelFunc
}
)

Expand Down
4 changes: 2 additions & 2 deletions notifications/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ func MustStartScheduler(ctx context.Context, cancel context.CancelFunc) *Schedul
for workerNumber := range schedulerWorkersCount {
go func(wn int64) {
defer sh.wg.Done()
sh.runPushNotificationsProcessor(ctx, wn)
sh.runNotificationsProcessor(ctx, wn)
}(workerNumber)
go func(wn int64) {
defer sh.wg.Done()
sh.runPushAnnouncementsProcessor(ctx, wn)
sh.runAnnouncementsProcessor(ctx, wn)
}(workerNumber)
}

Expand Down
13 changes: 7 additions & 6 deletions notifications/scheduler_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *Scheduler) runNotificationsProcessor(ctx context.Context, workerNumber
now, lastIterationStartedAt = time.Now(), time.Now()
errs = make([]error, 0)
successedNotifications = make([]*pushNotification, 0, schedulerBatchSize)
emptyTokensNotifications = make([]*scheduledNotificationInfo, 0, schedulerBatchSize)
toDelete = make([]*scheduledNotificationInfo, 0, schedulerBatchSize)
invalidTokens = make([]*invalidToken, 0)
toSendPushNotifications = make([]*pushNotification, 0)
notifications = make([]*scheduledNotificationInfo, schedulerBatchSize)
Expand All @@ -41,7 +41,7 @@ func (s *Scheduler) runNotificationsProcessor(ctx context.Context, workerNumber
toSendPushNotifications = toSendPushNotifications[:0]
invalidTokens = invalidTokens[:0]
notifications = notifications[:0]
emptyTokensNotifications = emptyTokensNotifications[:0]
toDelete = toDelete[:0]
lastIterationStartedAt = now

stdlibtime.Sleep(1 * stdlibtime.Second)
Expand Down Expand Up @@ -81,14 +81,15 @@ func (s *Scheduler) runNotificationsProcessor(ctx context.Context, workerNumber
domain := getDomainByNotificationType(NotificationType(notification.NotificationType))
for _, disabledDomain := range *notification.DisabledPushNotificationDomains {
if disabledDomain == domain {
toDelete = append(toDelete, notification)
log.Warn(fmt.Sprintf("notification with disabled notification domain:%v with notification type:%v for notification:%#v", domain, notification.NotificationType, notification)) //nolint:lll // .

continue out
}
}
}
if notification.PushNotificationTokens == nil || len(*notification.PushNotificationTokens) == 0 {
emptyTokensNotifications = append(emptyTokensNotifications, notification)
toDelete = append(toDelete, notification)

continue
}
Expand Down Expand Up @@ -163,10 +164,10 @@ func (s *Scheduler) runNotificationsProcessor(ctx context.Context, workerNumber
if dErr := s.markScheduledNotificationAsSent(reqCtx, now, successedNotifications); dErr != nil {
errs = append(errs, errors.Wrapf(dErr, "can't insert sent scheduled notification"))
}
if dErr := s.deleteScheduledNotifications(reqCtx, emptyTokensNotifications); dErr != nil {
errs = append(errs, errors.Wrapf(dErr, "can't delete scheduled notifications for:%#v", emptyTokensNotifications))
if dErr := s.deleteScheduledNotifications(reqCtx, toDelete); dErr != nil {
errs = append(errs, errors.Wrapf(dErr, "can't delete scheduled notifications for:%#v", toDelete))
}
if len(successedNotifications)+len(emptyTokensNotifications) > 0 {
if len(successedNotifications)+len(toDelete) > 0 {
go s.telemetryNotifications.collectElapsed(4, *before.Time) //nolint:gomnd,mnd // .
}
if err = multierror.Append(nil, errs...).ErrorOrNil(); err != nil {
Expand Down

0 comments on commit 5096553

Please sign in to comment.