Remove Docker client from NATS

Signed-off-by: Alex <alexellis2@gmail.com>
This commit is contained in:
Alex
2017-08-19 14:48:48 +01:00
committed by Alex Ellis
parent cfcb183bc7
commit fa069e412c
2 changed files with 12 additions and 16 deletions

View File

@ -8,12 +8,11 @@ import (
"github.com/Sirupsen/logrus"
"github.com/alexellis/faas/gateway/metrics"
"github.com/alexellis/faas/gateway/queue"
"github.com/docker/docker/client"
"github.com/gorilla/mux"
)
// 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) {
defer r.Body.Close()

View File

@ -98,25 +98,22 @@ func main() {
faasHandlers.ListFunctions = internalHandlers.MakeFunctionReader(metricsOptions, dockerClient)
faasHandlers.DeployFunction = internalHandlers.MakeNewFunctionHandler(metricsOptions, dockerClient, maxRestarts)
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.
functionLabel := "function"
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.StrictSlash(false) // This didn't work, so register routes twice.