mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Migrate from alexellis org to openfaas
Note, not all `alexellis/github` references should be changed, there are a number of repos which are not part of the openfaas org, this commit excludes those. Signed-off-by: John McCabe <john@johnmccabe.net>
This commit is contained in:
48
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/handler.go
generated
vendored
Normal file
48
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/handler.go
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/openfaas/faas/gateway/queue"
|
||||
"github.com/nats-io/go-nats-streaming"
|
||||
)
|
||||
|
||||
// NatsQueue queue for work
|
||||
type NatsQueue struct {
|
||||
nc stan.Conn
|
||||
}
|
||||
|
||||
// CreateNatsQueue ready for asynchronous processing
|
||||
func CreateNatsQueue(address string, port int) (*NatsQueue, error) {
|
||||
queue1 := NatsQueue{}
|
||||
var err error
|
||||
natsURL := fmt.Sprintf("nats://%s:%d", address, port)
|
||||
log.Printf("Opening connection to %s\n", natsURL)
|
||||
|
||||
clientID := "faas-publisher"
|
||||
clusterID := "faas-cluster"
|
||||
|
||||
nc, err := stan.Connect(clusterID, clientID, stan.NatsURL(natsURL))
|
||||
queue1.nc = nc
|
||||
|
||||
return &queue1, err
|
||||
}
|
||||
|
||||
// Queue request for processing
|
||||
func (q *NatsQueue) Queue(req *queue.Request) error {
|
||||
var err error
|
||||
|
||||
fmt.Printf("NatsQueue - submitting request: %s.\n", req.Function)
|
||||
|
||||
out, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
err = q.nc.Publish("faas-request", out)
|
||||
|
||||
return err
|
||||
}
|
5
gateway/vendor/github.com/openfaas/nats-queue-worker/queue-worker/vendor.conf
generated
vendored
Normal file
5
gateway/vendor/github.com/openfaas/nats-queue-worker/queue-worker/vendor.conf
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
github.com/openfaas/faas 4cc299d4c84e7ce10c6a5117e918c5a5b4aeb2ae
|
||||
github.com/nats-io/go-nats-streaming bf8654e90f5296da96eab1e85808eb5c4b7b5541
|
||||
github.com/nats-io/go-nats 34c8842105ac0b69c838a9998a239d482936c466
|
||||
github.com/nats-io/nuid 3cf34f9fca4e88afa9da8eabd75e3326c9941b44
|
||||
github.com/gogo/protobuf dda3e8acadcc9affc16faf33fbb229db78399245
|
Reference in New Issue
Block a user