MCPcopy Index your code
hub / github.com/coder/coder / fetch

Method fetch

coderd/notifications/notifier.go:208–222  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
208func (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

Callers 1

processMethod · 0.95

Calls 3

ValueMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected