github.com/lastbackend/toolkit@v0.0.0-20241020043710-cafa37b95aad/pkg/runtime/controller/tools.go (about)

     1  package controller
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/lastbackend/toolkit/pkg/runtime"
     7  	"github.com/lastbackend/toolkit/pkg/tools/metrics"
     8  	"github.com/lastbackend/toolkit/pkg/tools/probes"
     9  	"github.com/lastbackend/toolkit/pkg/tools/probes/server"
    10  	"github.com/lastbackend/toolkit/pkg/tools/traces"
    11  )
    12  
    13  type Tools struct {
    14  	runtime.Tools
    15  
    16  	runtime runtime.Runtime
    17  	metrics metrics.Metrics
    18  	probes  probes.Probes
    19  	traces  traces.Traces
    20  }
    21  
    22  func (t *Tools) Probes() probes.Probes {
    23  	return t.probes
    24  }
    25  
    26  func (t *Tools) Traces() traces.Traces {
    27  	return t.traces
    28  }
    29  
    30  func (t *Tools) Metrics() metrics.Metrics {
    31  	return t.metrics
    32  }
    33  
    34  func (t *Tools) OnStart(ctx context.Context) error {
    35  	return t.probes.Start(ctx)
    36  }
    37  
    38  func newToolsRegistration(runtime runtime.Runtime) (runtime.Tools, error) {
    39  	var (
    40  		tools = new(Tools)
    41  		err   error
    42  	)
    43  	tools.runtime = runtime
    44  
    45  	if tools.probes, err = server.NewProbesServer(runtime); err != nil {
    46  		return nil, err
    47  	}
    48  
    49  	return tools, nil
    50  }