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:
Alex Ellis (OpenFaaS Ltd)
2023-01-17 21:55:48 +00:00
parent 8e1c34e222
commit c26ec5221e
188 changed files with 22639 additions and 3717 deletions

View File

@ -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{

View File

@ -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)