mirror of
https://github.com/openfaas/faas.git
synced 2025-06-22 06:43:23 +00:00
Remove Docker client from NATS
Signed-off-by: Alex <alexellis2@gmail.com>
This commit is contained in:
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/alexellis/faas/gateway/metrics"
|
"github.com/alexellis/faas/gateway/metrics"
|
||||||
"github.com/alexellis/faas/gateway/queue"
|
"github.com/alexellis/faas/gateway/queue"
|
||||||
"github.com/docker/docker/client"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeQueuedProxy accepts work onto a queue
|
// MakeQueuedProxy accepts work onto a queue
|
||||||
func MakeQueuedProxy(metrics metrics.MetricOptions, wildcard bool, client *client.Client, logger *logrus.Logger, canQueueRequests queue.CanQueueRequests) http.HandlerFunc {
|
func MakeQueuedProxy(metrics metrics.MetricOptions, wildcard bool, logger *logrus.Logger, canQueueRequests queue.CanQueueRequests) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
@ -98,25 +98,22 @@ func main() {
|
|||||||
faasHandlers.ListFunctions = internalHandlers.MakeFunctionReader(metricsOptions, dockerClient)
|
faasHandlers.ListFunctions = internalHandlers.MakeFunctionReader(metricsOptions, dockerClient)
|
||||||
faasHandlers.DeployFunction = internalHandlers.MakeNewFunctionHandler(metricsOptions, dockerClient, maxRestarts)
|
faasHandlers.DeployFunction = internalHandlers.MakeNewFunctionHandler(metricsOptions, dockerClient, maxRestarts)
|
||||||
faasHandlers.DeleteFunction = internalHandlers.MakeDeleteFunctionHandler(metricsOptions, dockerClient)
|
faasHandlers.DeleteFunction = internalHandlers.MakeDeleteFunctionHandler(metricsOptions, dockerClient)
|
||||||
|
|
||||||
if config.UseNATS() {
|
|
||||||
log.Println("Async enabled: Using NATS Streaming.")
|
|
||||||
natsQueue, queueErr := natsHandler.CreateNatsQueue(*config.NATSAddress, *config.NATSPort)
|
|
||||||
if queueErr != nil {
|
|
||||||
log.Fatalln(queueErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
faasHandlers.QueuedProxy = internalHandlers.MakeQueuedProxy(metricsOptions, true, dockerClient, &logger, natsQueue)
|
|
||||||
faasHandlers.AsyncReport = internalHandlers.MakeAsyncReport(metricsOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// faasHandlers.AsyncFunction = internalHandlers.
|
|
||||||
|
|
||||||
// This could exist in a separate process - records the replicas of each swarm service.
|
// This could exist in a separate process - records the replicas of each swarm service.
|
||||||
functionLabel := "function"
|
functionLabel := "function"
|
||||||
metrics.AttachSwarmWatcher(dockerClient, metricsOptions, functionLabel)
|
metrics.AttachSwarmWatcher(dockerClient, metricsOptions, functionLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.UseNATS() {
|
||||||
|
log.Println("Async enabled: Using NATS Streaming.")
|
||||||
|
natsQueue, queueErr := natsHandler.CreateNatsQueue(*config.NATSAddress, *config.NATSPort)
|
||||||
|
if queueErr != nil {
|
||||||
|
log.Fatalln(queueErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
faasHandlers.QueuedProxy = internalHandlers.MakeQueuedProxy(metricsOptions, true, &logger, natsQueue)
|
||||||
|
faasHandlers.AsyncReport = internalHandlers.MakeAsyncReport(metricsOptions)
|
||||||
|
}
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
// r.StrictSlash(false) // This didn't work, so register routes twice.
|
// r.StrictSlash(false) // This didn't work, so register routes twice.
|
||||||
|
Reference in New Issue
Block a user