micro/tracer/options.go

43 lines
652 B
Go
Raw Normal View History

package tracer
2020-01-18 10:20:46 +00:00
var (
// DefaultSize of the buffer
DefaultSize = 64
)
// Options struct
2020-01-29 15:45:11 +00:00
type Options struct {
// Size is the size of ring buffer
Size int
}
2020-01-18 10:20:46 +00:00
// Option func
2020-01-18 10:20:46 +00:00
type Option func(o *Options)
// ReadOptions struct
2020-01-18 10:20:46 +00:00
type ReadOptions struct {
// Trace id
Trace string
}
// ReadOption func
2020-01-18 10:20:46 +00:00
type ReadOption func(o *ReadOptions)
2020-01-24 21:24:51 +00:00
// ReadTracer read the given trace
2020-01-24 21:24:51 +00:00
func ReadTrace(t string) ReadOption {
return func(o *ReadOptions) {
o.Trace = t
}
}
2020-01-29 15:45:11 +00:00
// NewOptions returns default options
func NewOptions(opts ...Option) Options {
options := Options{
2020-01-29 15:45:11 +00:00
Size: DefaultSize,
}
for _, o := range opts {
o(&options)
}
return options
2020-01-29 15:45:11 +00:00
}