summaryrefslogtreecommitdiff
path: root/internal/clients/connectors/serverless.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-06 09:50:41 +0300
committerPaul Buetow <paul@buetow.org>2021-10-06 09:50:41 +0300
commitfab5dc3e70434ea0abc7a0976487a1973b662331 (patch)
tree61a06e166f225b69f09966e81ae725f960fd80be /internal/clients/connectors/serverless.go
parent9f395a03f25941d8ed98ec43035688daa1e8877f (diff)
enable faster shutdown - useful for dgrep/dmap and dcat commands
Diffstat (limited to 'internal/clients/connectors/serverless.go')
-rw-r--r--internal/clients/connectors/serverless.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/clients/connectors/serverless.go b/internal/clients/connectors/serverless.go
index 2a1cec4..768a5ce 100644
--- a/internal/clients/connectors/serverless.go
+++ b/internal/clients/connectors/serverless.go
@@ -37,6 +37,7 @@ func (s *Serverless) Handler() handlers.Handler {
}
func (s *Serverless) Start(ctx context.Context, cancel context.CancelFunc, throttleCh, statsCh chan struct{}) {
+ dlog.Client.Debug("Starting serverless connector")
go func() {
defer cancel()
@@ -44,7 +45,6 @@ func (s *Serverless) Start(ctx context.Context, cancel context.CancelFunc, throt
dlog.Client.Warn(err)
}
}()
-
<-ctx.Done()
}
@@ -58,9 +58,11 @@ func (s *Serverless) handle(ctx context.Context, cancel context.CancelFunc) erro
var serverHandler serverHandlers.Handler
switch s.userName {
- case config.ControlUser:
- serverHandler = serverHandlers.NewControlHandler(user)
+ case config.HealthUser:
+ dlog.Client.Debug("Creating serverless health handler")
+ serverHandler = serverHandlers.NewHealthHandler(user)
default:
+ dlog.Client.Debug("Creating serverless server handler")
serverHandler = serverHandlers.NewServerHandler(
user,
make(chan struct{}, config.Server.MaxConcurrentCats),
@@ -76,29 +78,34 @@ func (s *Serverless) handle(ctx context.Context, cancel context.CancelFunc) erro
go func() {
io.Copy(serverHandler, s.handler)
+ dlog.Client.Trace("io.Copy(serverHandler, s.handler) => done")
terminate()
}()
go func() {
io.Copy(s.handler, serverHandler)
+ dlog.Client.Trace("io.Copy(s.handler, serverHandler) => done")
terminate()
}()
go func() {
select {
case <-s.handler.Done():
+ dlog.Client.Trace("<-s.handler.Done()")
case <-ctx.Done():
+ dlog.Client.Trace("<-ctx.Done()")
}
terminate()
}()
// Send all commands to client.
for _, command := range s.commands {
- dlog.Client.Debug(command)
+ dlog.Client.Debug("Sending command to serverless server", command)
s.handler.SendMessage(command)
}
<-ctx.Done()
+ dlog.Client.Trace("s.handler.Shutdown()")
s.handler.Shutdown()
return nil