~bigbes/core-go

core-go/webhooks/legacy.go -rw-r--r-- 7.0 KiB
20be483e — Conrad Hoffmann 9 months ago
Don't uppercase error messages
e22c3e1c — Conrad Hoffmann 9 months ago
Fix a bunch of linter complaints
20bcc757 — Conrad Hoffmann 9 months ago
webhooks: improve usage of slices.Contains

This was (rightfully) suggested by modernize [1], but the result can be
easily improved even further.

[1] https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
39c3fd1e — Conrad Hoffmann 9 months ago
Run modernize

See https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize

It's mostly interface{} -> any, but also two quite useful applications
of slices.Contains.
fea51c61 — Drew DeVault 1 year, 6 months ago
webhooks: add User-Agent to outgoing requests
17315205 — Robin Jarry 1 year, 8 months ago
config: factorize integer parsing

Add a new GetInt() function to parse an integer value from a parsed
ini.File. Use that function instead of duplicated code.

Signed-off-by: Robin Jarry <robin@jarry.cc>
7457c44b — Robin Jarry 1 year, 8 months ago
treewide: update to new multi worker dowork api

The work.Queue() implementation has changed and now allows scheduling
tasks from multiple goroutines in parallel. Also, it requires a new
argument for limiting the queue buffer size in order to apply back
pressure.

Define new configuration variables to allow tuning the queue sizes and
number of workers per service:

  [mail]
  # Maximum size of the outgoing email queue (default 512).
  egress-queue-size = 512

  [$service_name]
  # Number of parallel workers per queue (default 1).
  # There are multiple queues (for egress email, webhooks, etc.).
  # This setting is applied on a per-queue basis.
  queue-workers = 1

  [webhooks]
  # Maximum size of the webhooks queue (default 512).
  queue-size = 512

Use these new settings to configure the queues and workers accordingly.

Fix unit tests as well.

Link: https://git.sr.ht/~sircmpwn/dowork/commit/95719cfc0118
Signed-off-by: Robin Jarry <robin@jarry.cc>
46875256 — Drew DeVault 4 years ago
webhooks/legacy: fetch subscriptions upfront

This fixes a race condition when delivering webhooks for resource
deletion events, in which the subscriptions would be removed from the
delete cascade before the task to fetch them executes. This requires the
downstream code to call Queue before committing the delete transaction,
and updates the API to include a context argument for the connection
pool.
f44afb10 — Simon Ser 4 years ago
go fmt
48250772 — Simon Ser 4 years ago
Remove %e formatting verbs

%e is not valid for formatting error values:

> %e	scientific notation, e.g. -1.234456e+78

Instead, use %w when using fmt.Errorf (for error wrapping) and
%v when using log.Printf (%w is not valid in that context).
b98647b6 — Drew DeVault 5 years ago
Deduplicate webhook headers on subsequent attempts

This also updates the database with the final payload headers, including
the signature and nonce, which are generated afresh for each attempt.
70c7fe3b — Drew DeVault 5 years ago
webhooks/legacy: increase specificity of logging
d6bd006e — Drew DeVault 5 years ago
workers/legacy: correct Println with fmt directive
b7e39188 — Drew DeVault 5 years ago
Make worker logs less loud
da1a806e — Drew DeVault 5 years ago
webhooks/legacy: address Postgres-specific issues
03619ed2 — Drew DeVault 5 years ago
webhooks/legacy: update only affected delivery

Forgot to add this where clause, whoops!
af2afebd — Drew DeVault 5 years ago
Add legacy webhooks worker implementation