micro/tracer/options.go
Vasiliy Tolstov 8a2b122015
many fixes for lint and context.Context usage (#5)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-03 02:02:32 +03:00

43 lines
652 B
Go

package tracer
var (
// DefaultSize of the buffer
DefaultSize = 64
)
// Options struct
type Options struct {
// Size is the size of ring buffer
Size int
}
// Option func
type Option func(o *Options)
// ReadOptions struct
type ReadOptions struct {
// Trace id
Trace string
}
// ReadOption func
type ReadOption func(o *ReadOptions)
// ReadTracer read the given trace
func ReadTrace(t string) ReadOption {
return func(o *ReadOptions) {
o.Trace = t
}
}
// NewOptions returns default options
func NewOptions(opts ...Option) Options {
options := Options{
Size: DefaultSize,
}
for _, o := range opts {
o(&options)
}
return options
}