github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/debug/profile/profile.go (about) 1 // Licensed under the Apache License, Version 2.0 (the "License"); 2 // you may not use this file except in compliance with the License. 3 // You may obtain a copy of the License at 4 // 5 // https://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, 9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 // See the License for the specific language governing permissions and 11 // limitations under the License. 12 // 13 // Original source: github.com/micro/go-micro/v3/debug/profile/profile.go 14 15 // Package profile is for profilers 16 package profile 17 18 type Profile interface { 19 // Start the profiler 20 Start() error 21 // Stop the profiler 22 Stop() error 23 // Name of the profiler 24 String() string 25 } 26 27 var ( 28 DefaultProfile Profile = new(noop) 29 ) 30 31 type noop struct{} 32 33 func (p *noop) Start() error { 34 return nil 35 } 36 37 func (p *noop) Stop() error { 38 return nil 39 } 40 41 func (p *noop) String() string { 42 return "noop" 43 } 44 45 type Options struct { 46 // Name to use for the profile 47 Name string 48 } 49 50 type Option func(o *Options) 51 52 // Name of the profile 53 func Name(n string) Option { 54 return func(o *Options) { 55 o.Name = n 56 } 57 }