fetch retrieves messages from the queue by "acquiring a lease" whereby this notifier is the exclusive handler of these messages until they are dispatched - or until the lease expires (in exceptional cases).
(ctx context.Context)
| 206 | // fetch retrieves messages from the queue by "acquiring a lease" whereby this notifier is the exclusive handler of these |
| 207 | // messages until they are dispatched - or until the lease expires (in exceptional cases). |
| 208 | func (n *notifier) fetch(ctx context.Context) ([]database.AcquireNotificationMessagesRow, error) { |
| 209 | msgs, err := n.store.AcquireNotificationMessages(ctx, database.AcquireNotificationMessagesParams{ |
| 210 | // #nosec G115 - Safe conversion for lease count which is expected to be within int32 range |
| 211 | Count: int32(n.cfg.LeaseCount), |
| 212 | // #nosec G115 - Safe conversion for max send attempts which is expected to be within int32 range |
| 213 | MaxAttemptCount: int32(n.cfg.MaxSendAttempts), |
| 214 | NotifierID: n.id, |
| 215 | LeaseSeconds: int32(n.cfg.LeasePeriod.Value().Seconds()), |
| 216 | }) |
| 217 | if err != nil { |
| 218 | return nil, xerrors.Errorf("acquire messages: %w", err) |
| 219 | } |
| 220 | |
| 221 | return msgs, nil |
| 222 | } |
| 223 | |
| 224 | // prepare has two roles: |
| 225 | // 1. render the title & body templates |
no test coverage detected