-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/services: health Checker cleanup #10670
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,7 +178,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) { | |
restrictedHTTPClient := opts.RestrictedHTTPClient | ||
unrestrictedHTTPClient := opts.UnrestrictedHTTPClient | ||
|
||
// LOOPs can be be created as options, in the case of LOOP relayers, or | ||
// LOOPs can be created as options, in the case of LOOP relayers, or | ||
// as OCR2 job implementations, in the case of Median today. | ||
// We will have a non-nil registry here in LOOP relayers are being used, otherwise | ||
// we need to initialize in case we serve OCR2 LOOPs | ||
|
@@ -217,8 +217,6 @@ func NewApplication(opts ApplicationOpts) (Application, error) { | |
globalLogger.Info("Nurse service (automatic pprof profiling) is disabled") | ||
} | ||
|
||
healthChecker := services.NewChecker() | ||
|
||
telemetryIngressClient := synchronization.TelemetryIngressClient(&synchronization.NoopTelemetryIngressClient{}) | ||
telemetryIngressBatchClient := synchronization.TelemetryIngressBatchClient(&synchronization.NoopTelemetryIngressBatchClient{}) | ||
monitoringEndpointGen := telemetry.MonitoringEndpointGenerator(&telemetry.NoopAgent{}) | ||
|
@@ -443,7 +441,14 @@ func NewApplication(opts ApplicationOpts) (Application, error) { | |
feedsService = &feeds.NullService{} | ||
} | ||
|
||
app := &ChainlinkApplication{ | ||
healthChecker := services.NewChecker() | ||
for _, s := range srvcs { | ||
if err := healthChecker.Register(s); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return &ChainlinkApplication{ | ||
relayers: opts.RelayerChainInteroperators, | ||
EventBroadcaster: eventBroadcaster, | ||
jobORM: jobORM, | ||
|
@@ -472,27 +477,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) { | |
|
||
// NOTE: Can keep things clean by putting more things in srvcs instead of manually start/closing | ||
srvcs: srvcs, | ||
} | ||
|
||
for _, service := range app.srvcs { | ||
checkable := service.(services.Checkable) | ||
if err := app.HealthChecker.Register(service.Name(), checkable); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
// To avoid subscribing chain services twice, we only subscribe them if OCR2 is not enabled. | ||
// If it's enabled, they are going to be registered with relayers by default. | ||
if !cfg.OCR2().Enabled() { | ||
for _, service := range app.relayers.Services() { | ||
checkable := service.(services.Checkable) | ||
if err := app.HealthChecker.Register(service.Name(), checkable); err != nil { | ||
return nil, err | ||
} | ||
} | ||
} | ||
Comment on lines
-484
to
-493
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exception is no longer required since the relayer services are now added unconditionally. |
||
|
||
return app, nil | ||
}, nil | ||
} | ||
|
||
func (app *ChainlinkApplication) SetLogLevel(lvl zapcore.Level) error { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ type ( | |
// Checker provides a service which can be probed for system health. | ||
Checker interface { | ||
// Register a service for health checks. | ||
Register(name string, service Checkable) error | ||
Register(service Checkable) error | ||
// Unregister a service. | ||
Unregister(name string) error | ||
// IsReady returns the current readiness of the system. | ||
|
@@ -176,8 +176,9 @@ func (c *checker) update() { | |
uptimeSeconds.Add(interval.Seconds()) | ||
} | ||
|
||
func (c *checker) Register(name string, service Checkable) error { | ||
if service == nil || name == "" { | ||
func (c *checker) Register(service Checkable) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outside of tests, we only check |
||
name := service.Name() | ||
if name == "" { | ||
return errors.Errorf("misconfigured check %#v for %v", name, service) | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relocated and simplified - no need to cast.