github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/server/option.go (about)

     1  package server
     2  
     3  import (
     4  	"github.com/hellofresh/janus/pkg/api"
     5  	"github.com/hellofresh/janus/pkg/config"
     6  	"github.com/hellofresh/stats-go/client"
     7  )
     8  
     9  // Option represents the available options
    10  type Option func(*Server)
    11  
    12  // WithGlobalConfig sets the global configuration
    13  func WithGlobalConfig(globalConfig *config.Specification) Option {
    14  	return func(s *Server) {
    15  		s.globalConfig = globalConfig
    16  	}
    17  }
    18  
    19  // WithMetricsClient sets the metric provider
    20  func WithMetricsClient(client client.Client) Option {
    21  	return func(s *Server) {
    22  		s.statsClient = client
    23  	}
    24  }
    25  
    26  // WithProvider sets the configuration provider
    27  func WithProvider(provider api.Repository) Option {
    28  	return func(s *Server) {
    29  		s.provider = provider
    30  	}
    31  }
    32  
    33  // WithProfiler enables or disables profiler
    34  func WithProfiler(enabled, public bool) Option {
    35  	return func(s *Server) {
    36  		s.profilingEnabled = enabled
    37  		s.profilingPublic = public
    38  	}
    39  }