Defines an API for knowing if the SERVICE is running (regardless of up and down state)

New() builds s.connecClient and is called when the gRPC service is started.
Up() is invoked only IF a gRPC service IS running which is possible only if the New() was
called.
This commit is contained in:
riccardom
2026-06-17 23:30:30 +02:00
parent 33e7b6a8f1
commit 9b179be324
2 changed files with 20 additions and 3 deletions
+12
View File
@@ -483,6 +483,18 @@ func (c *ConnectClient) IsRunning() bool {
return c.sup.isRunning()
}
// ServiceRunning reports whether the client's lifecycle supervisor is alive and
// able to accept start/stop commands — i.e. the daemon-lifetime client exists
// and its context has not been cancelled. It is independent of whether a run is
// currently up (that is IsRunning). Nil-safe, so callers can ask it on a
// not-yet-constructed client and treat false as "service not running".
func (c *ConnectClient) ServiceRunning() bool {
if c == nil || c.sup == nil {
return false
}
return c.sup.ctx.Err() == nil
}
func (c *ConnectClient) Engine() *Engine {
if c == nil {
return nil