Skip to content

Commit

Permalink
fix typo (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
180909 committed Oct 10, 2022
1 parent ed012d2 commit 37a53fd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
10 changes: 5 additions & 5 deletions circuitbreaker/sre/sre.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const (
// then state reset to closed, if not continue the step.
StateOpen int32 = iota
// StateClosed when circuit breaker closed, request allowed, the breaker
// calc the succeed ratio, if request num greater request setting and
// calc to succeed ratio, if request num greater request setting and
// ratio lower than the setting ratio, then reset state to open.
StateClosed
)

var (
_ circuitbreaker.CircuitBreaker = &Breaker{}
_ circuitbreaker.CircuitBreaker = (*Breaker)(nil)
)

// options is a breaker options.
Expand Down Expand Up @@ -82,7 +82,7 @@ type Breaker struct {
state int32
}

// NewBreaker return a sreBresker with options
// NewBreaker return a sreBreaker with options
func NewBreaker(opts ...Option) circuitbreaker.CircuitBreaker {
opt := options{
success: 0.6,
Expand Down Expand Up @@ -141,14 +141,14 @@ func (b *Breaker) Allow() error {
return nil
}

// MarkSuccess mark requeest is success.
// MarkSuccess mark request is success.
func (b *Breaker) MarkSuccess() {
b.stat.Add(1)
}

// MarkFailed mark request is failed.
func (b *Breaker) MarkFailed() {
// NOTE: when client reject requets locally, continue add counter let the
// NOTE: when client reject request locally, continue to add counter let the
// drop ratio higher.
b.stat.Add(0)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cpu/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *cgroup) CPUSetCPUs() ([]uint64, error) {
return sets, nil
}

// CurrentcGroup get current process cgroup
// currentcGroup get current process cgroup
func currentcGroup() (*cgroup, error) {
pid := os.Getpid()
cgroupFile := fmt.Sprintf("/proc/%d/cgroup", pid)
Expand Down
4 changes: 3 additions & 1 deletion pkg/cpu/cgroup_cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
pscpu "github.com/shirou/gopsutil/v3/cpu"
)

var _ CPU = (*cgroupCPU)(nil)

type cgroupCPU struct {
frequency uint64
quota float64
Expand Down Expand Up @@ -226,7 +228,7 @@ func cpuMaxFreq() uint64 {
return feq
}

//GetClockTicks get the OS's ticks per second
// getClockTicks get the OS's ticks per second
func getClockTicks() int {
// TODO figure out a better alternative for platforms where we're missing cgo
//
Expand Down
2 changes: 2 additions & 0 deletions pkg/cpu/psutil_cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/shirou/gopsutil/v3/cpu"
)

var _ CPU = (*psutilCPU)(nil)

type psutilCPU struct {
interval time.Duration
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/cpu/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,18 @@ func ParseUintList(val string) (map[int]bool, error) {
return availableInts, nil
}

// ReadLines reads contents from a file and splits them by new lines.
// readLines reads contents from a file and splits them by new lines.
// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func readLines(filename string) ([]string, error) {
return readLinesOffsetN(filename, 0, -1)
}

// ReadLinesOffsetN reads contents from file and splits them by new line.
// readLinesOffsetN reads contents from file and splits them by new line.
// The offset tells at which line number to start.
// The count determines the number of lines to read (starting from offset):
// n >= 0: at most n lines
// n < 0: whole file
//
// n >= 0: at most n lines
// n < 0: whole file
func readLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
f, err := os.Open(filename)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ratelimit/bbr/bbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
gCPU int64
decay = 0.95

_ ratelimit.Limiter = &BBR{}
_ ratelimit.Limiter = (*BBR)(nil)
)

type (
Expand Down

0 comments on commit 37a53fd

Please sign in to comment.