mirror of
https://github.com/openfaas/faas.git
synced 2025-06-23 15:23:29 +00:00
Updates for NATS Streaming support
NATS Streaming is deprecated and will be removed from OpenFaaS CE in a future release for security reasons. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
7
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/handler.go
generated
vendored
7
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/handler.go
generated
vendored
@ -6,7 +6,10 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// CreateNATSQueue ready for asynchronous processing
|
||||
const sharedQueue = "faas-request"
|
||||
|
||||
// CreateNATSQueue ready for asynchronous message processing of paylods of
|
||||
// up to a maximum of 256KB in size.
|
||||
func CreateNATSQueue(address string, port int, clusterName, channel string, clientConfig NATSConfig) (*NATSQueue, error) {
|
||||
var err error
|
||||
natsURL := fmt.Sprintf("nats://%s:%d", address, port)
|
||||
@ -16,7 +19,7 @@ func CreateNATSQueue(address string, port int, clusterName, channel string, clie
|
||||
|
||||
// If 'channel' is empty, use the previous default.
|
||||
if channel == "" {
|
||||
channel = "faas-request"
|
||||
channel = sharedQueue
|
||||
}
|
||||
|
||||
queue1 := NATSQueue{
|
||||
|
5
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/nats_queue.go
generated
vendored
5
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/nats_queue.go
generated
vendored
@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
@ -37,6 +38,10 @@ func (q *NATSQueue) Queue(req *ftypes.QueueRequest) error {
|
||||
if v := req.Header.Get("X-Call-Id"); len(v) > 0 {
|
||||
callId = v
|
||||
}
|
||||
max := 256 * 1000
|
||||
if len(req.Body) > max {
|
||||
return fmt.Errorf("request body too large for OpenFaaS CE (%d bytes), maximum: %d bytes", len(req.Body), 256*1000)
|
||||
}
|
||||
|
||||
log.Printf("[%s] Queueing (%d) bytes for: %s.\n", callId, len(req.Body), req.Function)
|
||||
|
||||
|
Reference in New Issue
Block a user