yagwr.webhooks: Webhooks

class yagwr.webhooks.WebhookHandler(request, client_address, server)

Bases: http.server.BaseHTTPRequestHandler

The request handler for Gitlab webhooks

The Gitlab documentation states:

Your endpoint should send its HTTP response as fast as possible. If the response takes longer than the configured timeout, GitLab assumes the hook failed and retries it.

For this reason this request handler pushes the request information (headers, payload) onto a asyncio.Queue queue and responds as fast as possible. This approach is fine because the documentation also says:

GitLab ignores the HTTP status code returned by your endpoint.

Hence it doesn’t matter whether the processing takes a long time or even fails.

The processing itself is executed in a asyncio task.

finish_request()

Helper that finished the request

do_POST()

Handles the HTTP request from gitlab

log_message(fmt, *args)

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

async yagwr.webhooks.process_gitlab_request_task(controller)

Main asyncio tasks that reads the requests from the queue and launches the processing of the queue

async yagwr.webhooks.execute_action(request, action, log)

Helper function that executes arbitrary commands