Skip to content

Commit

Permalink
fix some comments
Browse files Browse the repository at this point in the history
Signed-off-by: cui fliter <[email protected]>
  • Loading branch information
cuishuang committed Apr 21, 2023
1 parent 7b454db commit a2e7b21
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func WithAttachment(key interface{}, value interface{}) EntryOption {
}
}

// WithAttachment set the resource entry with the given k-v pairs
// WithAttachments set the resource entry with the given k-v pairs
func WithAttachments(data map[interface{}]interface{}) EntryOption {
return func(opts *EntryOptions) {
if opts.attachments == nil {
Expand Down
2 changes: 1 addition & 1 deletion core/base/slot_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func NewSlotChain() *SlotChain {
}
}

// Get a EntryContext from EntryContext ctxPool, if ctxPool doesn't have enough EntryContext then new one.
// Get an EntryContext from EntryContext ctxPool, if ctxPool doesn't have enough EntryContext then new one.
func (sc *SlotChain) GetPooledContext() *EntryContext {
ctx := sc.ctxPool.Get().(*EntryContext)
ctx.startTime = util.CurrentTimeMillis()
Expand Down
35 changes: 17 additions & 18 deletions core/circuitbreaker/circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ import (
"github.com/pkg/errors"
)

// Circuit Breaker State Machine:
//
// Circuit Breaker State Machine:
//
// switch to open based on rule
// +-----------------------------------------------------------------------+
// | |
// | v
// +----------------+ +----------------+ Probe +----------------+
// | | | |<----------------| |
// | | Probe succeed | | | |
// | Closed |<------------------| HalfOpen | | Open |
// | | | | Probe failed | |
// | | | +---------------->| |
// +----------------+ +----------------+ +----------------+
// switch to open based on rule
// +-----------------------------------------------------------------------+
// | |
// | v
// +----------------+ +----------------+ Probe +----------------+
// | | | |<----------------| |
// | | Probe succeed | | | |
// | Closed |<------------------| HalfOpen | | Open |
// | | | | Probe failed | |
// | | | +---------------->| |
// +----------------+ +----------------+ +----------------+
type State int32

const (
Expand Down Expand Up @@ -126,7 +125,7 @@ type CircuitBreaker interface {
OnRequestComplete(rtt uint64, err error)
}

//================================= circuitBreakerBase ====================================
// ================================= circuitBreakerBase ====================================
// circuitBreakerBase encompasses the common fields of circuit breaker.
type circuitBreakerBase struct {
rule *Rule
Expand Down Expand Up @@ -230,7 +229,7 @@ func (b *circuitBreakerBase) fromHalfOpenToOpen(snapshot interface{}) bool {
return false
}

// fromHalfOpenToOpen updates circuit breaker state machine from half-open to closed
// fromHalfOpenToClosed updates circuit breaker state machine from half-open to closed
// Return true only if current goroutine successfully accomplished the transformation.
func (b *circuitBreakerBase) fromHalfOpenToClosed() bool {
if b.state.cas(HalfOpen, Closed) {
Expand All @@ -245,7 +244,7 @@ func (b *circuitBreakerBase) fromHalfOpenToClosed() bool {
return false
}

//================================= slowRtCircuitBreaker ====================================
// ================================= slowRtCircuitBreaker ====================================
type slowRtCircuitBreaker struct {
circuitBreakerBase
stat *slowRequestLeapArray
Expand Down Expand Up @@ -437,7 +436,7 @@ func (s *slowRequestLeapArray) allCounter() []*slowRequestCounter {
return ret
}

//================================= errorRatioCircuitBreaker ====================================
// ================================= errorRatioCircuitBreaker ====================================
type errorRatioCircuitBreaker struct {
circuitBreakerBase
minRequestAmount uint64
Expand Down Expand Up @@ -622,7 +621,7 @@ func (s *errorCounterLeapArray) allCounter() []*errorCounter {
return ret
}

//================================= errorCountCircuitBreaker ====================================
// ================================= errorCountCircuitBreaker ====================================
type errorCountCircuitBreaker struct {
circuitBreakerBase
minRequestAmount uint64
Expand Down
2 changes: 1 addition & 1 deletion core/system_metric/sys_metric_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func init() {
metric_exporter.Register(processMemoryGauge)
}

// getMemoryStat returns the current machine's memory statistic
// getTotalMemorySize returns the current machine's memory statistic
func getTotalMemorySize() (total uint64) {
stat, err := mem.VirtualMemory()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ext/datasource/hotspot_rule_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *SpecificValue) String() string {
return fmt.Sprintf("SpecificValue: [ValKind: %+v, ValStr: %s]", s.ValKind, s.ValStr)
}

// arseSpecificItems parses the SpecificValue as real value.
// parseSpecificItems parses the SpecificValue as real value.
func parseSpecificItems(source []SpecificValue) map[interface{}]int64 {
ret := make(map[interface{}]int64, len(source))
if len(source) == 0 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/adapters/micro/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type (
}
)

// WithUnaryClientResourceExtractor sets the resource extractor of unary client request.
// WithClientResourceExtractor sets the resource extractor of unary client request.
// The second string parameter is the full method name of current invocation.
func WithClientResourceExtractor(fn func(context.Context, client.Request) string) Option {
return func(opts *options) {
opts.clientResourceExtract = fn
}
}

// WithUnaryServerResourceExtractor sets the resource extractor of unary server request.
// WithServerResourceExtractor sets the resource extractor of unary server request.
func WithServerResourceExtractor(fn func(context.Context, server.Request) string) Option {
return func(opts *options) {
opts.serverResourceExtract = fn
Expand All @@ -55,15 +55,15 @@ func WithStreamServerResourceExtractor(fn func(server.Stream) string) Option {
}
}

// WithUnaryClientBlockFallback sets the block fallback handler of unary client request.
// WithClientBlockFallback sets the block fallback handler of unary client request.
// The second string parameter is the full method name of current invocation.
func WithClientBlockFallback(fn func(context.Context, client.Request, *base.BlockError) error) Option {
return func(opts *options) {
opts.clientBlockFallback = fn
}
}

// WithUnaryServerBlockFallback sets the block fallback handler of unary server request.
// WithServerBlockFallback sets the block fallback handler of unary server request.
func WithServerBlockFallback(fn func(context.Context, server.Request, *base.BlockError) error) Option {
return func(opts *options) {
opts.serverBlockFallback = fn
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasource/k8s/controllers/hotspotrules_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (r *HotspotRulesReconciler) assembleHotspotRules(rs *datasourcev1.HotspotRu
return ret
}

// arseSpecificItems parses the SpecificValue as real value.
// parseSpecificItems parses the SpecificValue as real value.
func parseSpecificItems(source []datasourcev1.SpecificValue) map[interface{}]int64 {
ret := make(map[interface{}]int64)
if len(source) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion util/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func CurrentClock() Clock {
return currentClock.Load().(*clockWrapper).clock
}

// SetClock sets the ticker creator used by util package.
// SetTickerCreator sets the ticker creator used by util package.
// In general, no need to set it. It is usually used for testing.
func SetTickerCreator(tc TickerCreator) {
currentTickerCreator.Store(&tickerCreatorWrapper{tc})
Expand Down

0 comments on commit a2e7b21

Please sign in to comment.