Skip to content

Commit

Permalink
fix golint issues in core/load (zeromicro#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Feb 20, 2021
1 parent 84d2b6f commit dac00d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/load/sheddergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ import (
"github.com/tal-tech/go-zero/core/syncx"
)

// A ShedderGroup is a manager to manage key based shedders.
type ShedderGroup struct {
options []ShedderOption
manager *syncx.ResourceManager
}

// NewShedderGroup returns a ShedderGroup.
func NewShedderGroup(opts ...ShedderOption) *ShedderGroup {
return &ShedderGroup{
options: opts,
manager: syncx.NewResourceManager(),
}
}

// GetShedder gets the Shedder for the given key.
func (g *ShedderGroup) GetShedder(key string) Shedder {
shedder, _ := g.manager.GetResource(key, func() (closer io.Closer, e error) {
return nopCloser{
Expand Down
5 changes: 5 additions & 0 deletions core/load/sheddingstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

type (
// A SheddingStat is used to store the statistics for load shedding.
SheddingStat struct {
name string
total int64
Expand All @@ -23,6 +24,7 @@ type (
}
)

// NewSheddingStat returns a SheddingStat.
func NewSheddingStat(name string) *SheddingStat {
st := &SheddingStat{
name: name,
Expand All @@ -31,14 +33,17 @@ func NewSheddingStat(name string) *SheddingStat {
return st
}

// IncrementTotal increments the total requests.
func (s *SheddingStat) IncrementTotal() {
atomic.AddInt64(&s.total, 1)
}

// IncrementPass increments the passed requests.
func (s *SheddingStat) IncrementPass() {
atomic.AddInt64(&s.pass, 1)
}

// IncrementDrop increments the dropped requests.
func (s *SheddingStat) IncrementDrop() {
atomic.AddInt64(&s.drop, 1)
}
Expand Down

0 comments on commit dac00d1

Please sign in to comment.