openfaas / nats-queue-worker

Queue-worker for OpenFaaS with NATS Streaming
https://docs.openfaas.com/reference/async/
MIT License
128 stars 59 forks source link

Add timeout wrapper for function handler #27

Closed lybroman closed 6 years ago

lybroman commented 6 years ago

Description

  1. Add a global timeout configuration using environment variable "func_timeout" for function handler call in POST
  2. Populate more necessary information when errors occur

    Motivation and Context

  3. Since the call to handler is blocking, there is possibility that the function handler has some conditions that it will run for a longer time than expected or even forever (if any bug) and the ackWait could not solve this issue; thus we want to add a timeout wrapper and populate the information in the callback.
  4. Also when err occurs, the functionResult is always empty, the callback api handler has no way to know the error details. What's more if several functions share the same X-Callback-Url, the callback api handler has no way to know which function failed since no information was populated. So we want to add error details and url information to the response.

How Has This Been Tested?

Set the func_timeout to a very small value and check the received response from callback api handler's log.

Types of changes

Checklist:

alexellis commented 6 years ago

Hi did you find another solution for this or was there another reason for closing it?