Skip to content

Commit

Permalink
feat: add node api health
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Apr 8, 2024
1 parent 8c9856a commit 853d04a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions operator/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package operator

const (
ServiceOperator string = "ServiceOperator"
ServiceOperatorAggregator string = "ServiceOperatorAggregator"
ServiceOperatorVerifier string = "ServiceOperatorVerifier"
)
43 changes: 42 additions & 1 deletion operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,32 @@ func (o *Operator) Start(ctx context.Context) error {

o.logger.Infof("Starting operator.")

if o.config.EnableNodeApi {
o.nodeApi.RegisterNewService(
ServiceOperator,
ServiceOperator,
"operator to commit alert to aggregator",
nodeapi.ServiceStatusInitializing,
)

o.nodeApi.RegisterNewService(
ServiceOperatorAggregator,
ServiceOperatorAggregator,
"operator aggregator work",
nodeapi.ServiceStatusInitializing,
)

o.nodeApi.RegisterNewService(
ServiceOperatorVerifier,
ServiceOperatorVerifier,
"operator verifier work",
nodeapi.ServiceStatusInitializing,
)

o.nodeApi.UpdateHealth(nodeapi.Healthy)
o.nodeApi.Start()
}

o.logger.Infof("Init operator to aggregator.")
err = o.aggregatorRpcClient.InitOperatorToAggregator()
if err != nil {
Expand All @@ -442,8 +468,23 @@ func (o *Operator) Start(ctx context.Context) error {
o.logger.Infof("Init operator to aggregator succeeded.")

if o.config.EnableNodeApi {
o.nodeApi.Start()
o.nodeApi.UpdateServiceStatus(
ServiceOperator,
nodeapi.ServiceStatusUp,
)

o.nodeApi.UpdateServiceStatus(
ServiceOperatorAggregator,
nodeapi.ServiceStatusUp,
)

// TODO: check the verifier working
o.nodeApi.UpdateServiceStatus(
ServiceOperatorVerifier,
nodeapi.ServiceStatusUp,
)
}

var metricsErrChan <-chan error
if o.config.EnableMetrics {
metricsErrChan = o.metrics.Start(ctx, o.metricsReg)
Expand Down

0 comments on commit 853d04a

Please sign in to comment.