2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-05-13 16:42:58 +08:00

[RFC] Adds Ping() to client/scheduler/server (#585)

* [RFC] Adds Ping() to client/scheduler/server

* Checks for scheduler state closed
This commit is contained in:
Patrick Barnum
2024-10-18 23:44:06 -07:00
committed by GitHub
parent 0dc670d7d8
commit b1e13893ff
3 changed files with 30 additions and 1 deletions

View File

@@ -759,7 +759,7 @@ func (srv *Server) Shutdown() {
func (srv *Server) Stop() {
srv.state.mu.Lock()
if srv.state.value != srvStateActive {
// Invalid calll to Stop, server can only go from Active state to Stopped state.
// Invalid call to Stop, server can only go from Active state to Stopped state.
srv.state.mu.Unlock()
return
}
@@ -770,3 +770,16 @@ func (srv *Server) Stop() {
srv.processor.stop()
srv.logger.Info("Processor stopped")
}
// Ping performs a ping against the redis connection.
//
// This is an alternative to the HealthCheckFunc available in the Config object.
func (srv *Server) Ping() error {
srv.state.mu.Lock()
defer srv.state.mu.Unlock()
if srv.state.value == srvStateClosed {
return nil
}
return srv.broker.Ping()
}