debug/profile: move to profiler interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-14 14:02:51 +03:00
parent e5bf1448f4
commit cc7ebedf22
6 changed files with 0 additions and 123 deletions

43
profiler/profile.go Normal file
View File

@@ -0,0 +1,43 @@
// Package profile is for profilers
package profile
type Profile interface {
// Start the profiler
Start() error
// Stop the profiler
Stop() error
// Name of the profiler
String() string
}
var (
DefaultProfile Profile = &NoopProfile{}
)
type NoopProfile struct{}
func (p *NoopProfile) Start() error {
return nil
}
func (p *NoopProfile) Stop() error {
return nil
}
func (p *NoopProfile) String() string {
return "noop"
}
type Options struct {
// Name to use for the profile
Name string
}
type Option func(o *Options)
// Name of the profile
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}