Files

85 lines
1.8 KiB
Go
Raw Permalink Normal View History

2019-12-04 17:15:11 +01:00
package http
import (
"context"
2022-05-04 14:49:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/log"
2022-06-20 16:49:06 +02:00
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
"github.com/owncloud/ocis/v2/services/graph/pkg/metrics"
"github.com/urfave/cli/v2"
2023-07-03 12:38:10 +02:00
"go.opentelemetry.io/otel/trace"
2019-12-04 17:15:11 +01:00
)
2019-12-06 13:14:21 +01:00
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
2023-07-03 12:38:10 +02:00
Logger log.Logger
Context context.Context
Config *config.Config
Metrics *metrics.Metrics
Flags []cli.Flag
Namespace string
TraceProvider trace.TracerProvider
2019-12-06 13:14:21 +01:00
}
// newOptions initializes the available default options.
2019-12-04 17:15:11 +01:00
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
2019-12-06 13:14:21 +01:00
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
2019-12-04 17:15:11 +01:00
}
2019-12-06 13:14:21 +01:00
// Context provides a function to set the context option.
2019-12-04 17:15:11 +01:00
func Context(val context.Context) Option {
return func(o *Options) {
o.Context = val
}
}
2019-12-06 13:14:21 +01:00
// Config provides a function to set the config option.
2019-12-04 17:15:11 +01:00
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}
2019-12-06 13:14:21 +01:00
// Metrics provides a function to set the metrics option.
func Metrics(val *metrics.Metrics) Option {
return func(o *Options) {
o.Metrics = val
}
}
2019-12-11 16:08:24 +01:00
// Flags provides a function to set the flags option.
func Flags(val []cli.Flag) Option {
return func(o *Options) {
o.Flags = append(o.Flags, val...)
}
}
2019-12-27 13:09:27 +01:00
// Namespace provides a function to set the Namespace option.
func Namespace(val string) Option {
return func(o *Options) {
o.Namespace = val
}
}
2023-07-03 12:38:10 +02:00
// TraceProvider provides a function to set the TraceProvider option.
func TraceProvider(val trace.TracerProvider) Option {
return func(o *Options) {
o.TraceProvider = val
}
}