Skip to content

Commit

Permalink
[typo] fix typo in comments & const value(SignalUsr2) (#181)
Browse files Browse the repository at this point in the history
* [typo] fix typo in comments & const value(SignalUsr2)

* [typo] improve comment & fix typo

* [typo] fix outdated comment for OnFlushBody func

* [typo] simplify comment & fix parameter misspelled

* [typo] fix misspelled

Co-authored-by: jxd134 <[email protected]>
  • Loading branch information
jxd134 and jxd1990 committed Aug 10, 2021
1 parent eb2250a commit ef15ab7
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
os.Exit(1)
}

if err := common.RaiseSignal(pid, common.SingalUsr2); err != nil {
if err := common.RaiseSignal(pid, common.SignalUsr2); err != nil {
logger.Errorf("failed to send signal: %v", err)
os.Exit(1)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package common

// Signal is cross platform abstract type of os.Signal
// Signal is cross-platform abstract type of os.Signal
type Signal string

const (
Expand All @@ -26,6 +26,6 @@ const (
// SignalTerm represents force quit in Easegress
SignalTerm Signal = "term"

// SingalUsr2 represents reload signal in Easegress
SingalUsr2 Signal = "usr2"
// SignalUsr2 represents reload signal in Easegress
SignalUsr2 Signal = "usr2"
)
4 changes: 2 additions & 2 deletions pkg/common/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
var signalToOsMap = map[Signal]syscall.Signal{
SignalInt: syscall.SIGINT,
SignalTerm: syscall.SIGTERM,
SingalUsr2: syscall.SIGUSR2,
SignalUsr2: syscall.SIGUSR2,
}

var signalFromOsMap = map[os.Signal]Signal{
syscall.SIGINT: SignalInt,
syscall.SIGTERM: SignalTerm,
syscall.SIGUSR2: SingalUsr2,
syscall.SIGUSR2: SignalUsr2,
}

// NotifySignal is identical to os/signal.Notify on Linux
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/signal_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func TestNotifySignalAndRaiseSignal(t *testing.T) {
c := make(chan Signal, 5)
var currSig Signal
sigs := []Signal{SignalInt, SignalTerm, SingalUsr2}
sigs := []Signal{SignalInt, SignalTerm, SignalUsr2}

// NotifySignal
if err := NotifySignal(nil); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/httpcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (ctx *httpContext) Log() string {
strings.Join(ctx.tags, " | "))
}

// Template returns HTTPTemplate rely interface
// Template returns the template engine
func (ctx *httpContext) Template() texttemplate.TemplateEngine {
return ctx.ht.Engine
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/httprequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func newHTTPRequest(stdr *http.Request) *httpRequest {
realIP: realip.FromRequest(stdr),
}

// NOTE: Always count orinal body, even the body could be changed
// NOTE: Always count original body, even the body could be changed
// by SetBody().
hq.body.OnAfter(func(num int, p []byte, n int, err error) ([]byte, int, error) {
hq.bodyCount += n
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/httpresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (w *httpResponse) SetBody(body io.Reader) {
w.body = body
}

// None uses it currently, keep it for future maybe.
// OnFlushBody adds an HTTP body flushing handler function
func (w *httpResponse) OnFlushBody(fn BodyFlushFunc) {
w.bodyFlushFuncs = append(w.bodyFlushFuncs, fn)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/context/httptemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func NewHTTPTemplate(filterBuffs []FilterBuff) (*HTTPTemplate, error) {
filterFuncTags := map[string][]string{}
// validates the filter's YAML spec for dependency checking
// and template format,e.g., if filter1 has a template said '[[filter.filter2.rsp.data]],
// but it appears before filter2, then it's an invalidate dependency cause we can't get
// but it appears before filter2, then it's an invalidated dependency cause we can't get
// the rsp form filter2 in the execution period of filter1. At last it will build up
// executing function arrays for every filters.
// executing function arrays for every filter.
for _, filterBuff := range filterBuffs {
e.filtersOrder = append(e.filtersOrder, filterBuff.Name)
templatesMap := e.Engine.ExtractRawTemplateRuleMap(string(filterBuff.Buff))
Expand Down
4 changes: 2 additions & 2 deletions pkg/filter/proxy/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (p *pool) status() *PoolStatus {
}

func (p *pool) handle(ctx context.HTTPContext, reqBody io.Reader) string {
addTag := func(subPerfix, msg string) {
tag := stringtool.Cat(p.tagPrefix, "#", subPerfix, ": ", msg)
addTag := func(subPrefix, msg string) {
tag := stringtool.Cat(p.tagPrefix, "#", subPrefix, ": ", msg)
ctx.Lock()
ctx.AddTag(tag)
ctx.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion pkg/filter/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
}

const (
// PolicyRoundRobin is the policy of round robin.
// PolicyRoundRobin is the policy of round-robin.
PolicyRoundRobin = "roundRobin"
// PolicyRandom is the policy of random.
PolicyRandom = "random"
Expand Down
2 changes: 1 addition & 1 deletion pkg/graceupdate/graceupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func CallOriProcessTerm(done chan struct{}) bool {
// NotifySigUsr2 handles signal SIGUSR2 to gracefully update.
func NotifySigUsr2(closeCls func(), restartCls func()) error {
sigUsr2 := make(chan common.Signal, 1)
if err := common.NotifySignal(sigUsr2, common.SingalUsr2); err != nil {
if err := common.NotifySignal(sigUsr2, common.SignalUsr2); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/object/httpserver/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ type (
func newIPFilterChain(parentIPFilters *ipfilter.IPFilters, childSpec *ipfilter.Spec) *ipfilter.IPFilters {
var ipFilters *ipfilter.IPFilters
if parentIPFilters != nil {
ipFilters = ipfilter.NewIPfilters(parentIPFilters.Filters()...)
ipFilters = ipfilter.NewIPFilters(parentIPFilters.Filters()...)
} else {
ipFilters = ipfilter.NewIPfilters()
ipFilters = ipfilter.NewIPFilters()
}

if childSpec != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/supervisor/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *Supervisor) NewSpec(yamlConfig string) (spec *Spec, err error) {
return
}

// Super returns super
// Super returns supervisor
func (s *Spec) Super() *Supervisor {
return s.super
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/circuitbreaker/circuitbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (tbw *TimeBasedWindow) evict(now time.Time) {
// evicts is how many buckets need to be evicted
evicts := seconds - len(tbw.bucket) + 1

// the begin time of the window need to be adjusted according to evicts
// the beginning time of the window need to be adjusted according to evicts
tbw.beginAt = tbw.beginAt.Add(time.Duration(evicts) * time.Second)

// evicts may be very large, but at most len(tbw.bucket) buckets need to
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/httpheader/httpheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (h *HTTPHeader) AddFrom(src *HTTPHeader) {
}

// AddFromStd wraps AddFrom by replacing
// the paramenter type *HTTPHeader with standard http.Header.
// the parameter type *HTTPHeader with standard http.Header.
func (h *HTTPHeader) AddFromStd(src http.Header) {
h.AddFrom(New(src))
}
Expand All @@ -146,7 +146,7 @@ func (h *HTTPHeader) SetFrom(src *HTTPHeader) {
}

// SetFromStd wraps Setfrom by replacing
// the paramenter type *HTTPHeader with standard http.Header.
// the parameter type *HTTPHeader with standard http.Header.
func (h *HTTPHeader) SetFromStd(src http.Header) {
h.SetFrom(New(src))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/ipfilter/ipfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func (f *IPFilter) Allow(ipstr string) bool {
}
}

// NewIPfilters creates an IPFilters
func NewIPfilters(filters ...*IPFilter) *IPFilters {
// NewIPFilters creates an IPFilters
func NewIPFilters(filters ...*IPFilter) *IPFilters {
return &IPFilters{filters: filters}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/util/jmxtool/agent_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func TestAgentClientFail(t *testing.T) {

err = agent.UpdateService(&service, 1)
if err == nil {
t.Errorf("agent shoudl fail\n")
t.Errorf("agent should fail\n")
}
err = agent.UpdateCanary(header, 1)
if err == nil {
t.Errorf("agent shoudl fail\n")
t.Errorf("agent should fail\n")
}
// shutdown
var client = &http.Client{
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/sem/semaphore.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const maxCapacity int64 = 20_000_000

//Semaphore supports to change the max sema amount at runtime.
// Semaphore employs golang.org/x/sync/semaphore.Weighted with a maxCapacity.
// And tuning the realCapacity by a Acquire and Release in the background.
// the realCapacity can not exceeds the maxCapacity.
// And tuning the realCapacity by an Acquire and Release in the background.
// the realCapacity can not exceed the maxCapacity.
type Semaphore struct {
sem *semaphore.Weighted
lock sync.Mutex
Expand Down
10 changes: 5 additions & 5 deletions pkg/util/texttemplate/texttemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type node struct {

// TemplateEngine is the basic API collection for a template usage
type TemplateEngine interface {
// Rendering e.g., [[xxx.xx.dd.xx]]'s value is 'value0', [[yyy.www.zzz]]'s value is 'value1'
// Render Rendering e.g., [[xxx.xx.dd.xx]]'s value is 'value0', [[yyy.www.zzz]]'s value is 'value1'
// "aaa-[[xxx.xx.dd.xx]]-bbb 10101-[[yyy.wwww.zzz]]-9292" will be rendered to "aaa-value0-bbb 10101-value1-9292"
// Also support GJSON syntax at last tag
Render(input string) (string, error)
Expand All @@ -65,11 +65,11 @@ type TemplateEngine interface {
// return map's key is the template, the value is the matched and rendered metaTemplate
ExtractTemplateRuleMap(input string) map[string]string

// ExtractTemplateRuleMap extracts templates from input string
// ExtractRawTemplateRuleMap extracts templates from input string
// return map's key is the template, the value is the matched and rendered metaTemplate or empty
ExtractRawTemplateRuleMap(input string) map[string]string

// HasTemplates checks whether has templates in input string or not
// HasTemplates checks whether it has templates in input string or not
HasTemplates(input string) bool

// MatchMetaTemplate return original template or replace with {gjson} at last tag, "" if not metaTemplate matched
Expand All @@ -78,7 +78,7 @@ type TemplateEngine interface {
// SetDict adds a temaplateRule and its value for later rendering
SetDict(template string, value interface{}) error

// GetDict returns the template rely dictionary
// GetDict returns the template's dictionary
GetDict() map[string]interface{}
}

Expand Down Expand Up @@ -300,7 +300,7 @@ func (t TextTemplate) MatchMetaTemplate(template string) string {
hasGJSON := false

for ; index < len(tags); index++ {
// no tag remain to match, or its a empty tag
// no tag remain to match, or it's an empty tag
if len(root.Children) == 0 || len(tags[index]) == 0 {
return ""
}
Expand Down

0 comments on commit ef15ab7

Please sign in to comment.