def with_http( self, workers=8, port=0, host=None, paths=None, canary=None, secret=None ): self.add_trigger( "http", nuclio.HttpTrigger( workers, port=port, host=host, paths=paths, canary=canary, secret=secret ), ) return self
def with_http(self, workers=8, port=0, host=None, paths=None, canary=None): self.add_trigger('http', nuclio.HttpTrigger( workers, port=port, host=host, paths=paths, canary=canary)) return self
def with_http( self, workers=8, port=0, host=None, paths=None, canary=None, secret=None, worker_timeout: int = None, gateway_timeout: int = None, trigger_name=None, annotations=None, extra_attributes=None, ): """update/add nuclio HTTP trigger settings Note: gateway timeout is the maximum request time before an error is returned, while the worker timeout if the max time a request will wait for until it will start processing, gateway_timeout must be greater than the worker_timeout. :param workers: number of worker processes (default=8) :param port: TCP port :param host: hostname :param paths: list of sub paths :param canary: k8s ingress canary (% traffic value between 0 to 100) :param secret: k8s secret name for SSL certificate :param worker_timeout: worker wait timeout in sec (how long a message should wait in the worker queue before an error is returned) :param gateway_timeout: nginx ingress timeout in sec (request timeout, when will the gateway return an error) :param trigger_name: alternative nuclio trigger name :param annotations: key/value dict of ingress annotations :param extra_attributes: key/value dict of extra nuclio trigger attributes :return: function object (self) """ annotations = annotations or {} if worker_timeout: gateway_timeout = gateway_timeout or (worker_timeout + 60) if gateway_timeout: if worker_timeout and worker_timeout >= gateway_timeout: raise ValueError( "gateway timeout must be greater than the worker timeout") annotations[ "nginx.ingress.kubernetes.io/proxy-connect-timeout"] = f"{gateway_timeout}" annotations[ "nginx.ingress.kubernetes.io/proxy-read-timeout"] = f"{gateway_timeout}" annotations[ "nginx.ingress.kubernetes.io/proxy-send-timeout"] = f"{gateway_timeout}" trigger = nuclio.HttpTrigger( workers, port=port, host=host, paths=paths, canary=canary, secret=secret, annotations=annotations, extra_attributes=extra_attributes, ) if worker_timeout: trigger._struct["workerAvailabilityTimeoutMilliseconds"] = ( worker_timeout) * 1000 self.add_trigger(trigger_name or "http", trigger) return self