Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
iyangsj committed Aug 1, 2019
1 parent f1d9986 commit 489aca4
Show file tree
Hide file tree
Showing 51 changed files with 314 additions and 365 deletions.
2 changes: 1 addition & 1 deletion bfe_balance/backend/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func checkHTTPConnect(backend *BfeBackend, checkConf *cluster_conf.BackendCheck)
return cluster_conf.MatchStatusCode(statusCode, *checkConf.StatusCode)
}

// CheckRedirect check whether backend server become available.
// CheckConnect checks whether backend server become available.
func CheckConnect(backend *BfeBackend, checkConf *cluster_conf.BackendCheck) (bool, error) {
switch *checkConf.Schem {
case "http":
Expand Down
15 changes: 6 additions & 9 deletions bfe_balance/bal_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ func (t *BalTable) gslbInit(gslbConfs gslb_conf.GslbConf) error {
t.versions.GslbConfTimeStamp = *gslbConfs.Ts
t.versions.GslbConfSrc = *gslbConfs.Hostname

if len(fails) == 0 {
return nil
} else {
if len(fails) != 0 {
return fmt.Errorf("error in ClusterTable.gslbInit() for [%s]",
strings.Join(fails, ","))
}
return nil
}

func (t *BalTable) backendInit(backendConfs cluster_table_conf.ClusterTableConf) error {
Expand Down Expand Up @@ -159,12 +158,11 @@ func (t *BalTable) backendInit(backendConfs cluster_table_conf.ClusterTableConf)
// update versions
t.versions.ClusterTableConfVer = *backendConfs.Version

if len(fails) == 0 {
return nil
} else {
if len(fails) != 0 {
return fmt.Errorf("error in ClusterTable.backendInit() for [%s]",
strings.Join(fails, ","))
}
return nil
}

// SetGslbBasic sets gslb basic conf (from server data conf) for BalTable.
Expand Down Expand Up @@ -244,11 +242,10 @@ func (t *BalTable) BalTableReload(gslbConfs gslb_conf.GslbConf,

t.lock.Unlock()

if len(fails) == 0 {
return nil
} else {
if len(fails) != 0 {
return fmt.Errorf("error in BalTableReload() for [%s]", strings.Join(fails, ","))
}
return nil
}

func (t *BalTable) lookup(clusterName string) (*bal_gslb.BalanceGslb, error) {
Expand Down
2 changes: 1 addition & 1 deletion bfe_basic/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Action struct {
Params []string // params of action
}

// UnmarshalJson decodes given data in json format
// UnmarshalJSON decodes given data in json format
func (ac *Action) UnmarshalJSON(data []byte) error {
var actionFile ActionFile

Expand Down
2 changes: 1 addition & 1 deletion bfe_basic/action/action_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func ReqQueryRename(req *bfe_basic.Request, oldName string, newName string) {
req.HttpRequest.URL.RawQuery = rawQuery[1:]
}

// ReqQueryRename deletes some keys from query
// ReqQueryDel deletes some keys from query
func ReqQueryDel(req *bfe_basic.Request, keys []string) {
// add "&" prefix and suffix to simplify process
rawQuery := "&" + req.HttpRequest.URL.RawQuery + "&"
Expand Down
2 changes: 1 addition & 1 deletion bfe_basic/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func CreateInternalSrvErrResp(request *Request) *bfe_http.Response {
return CreateInternalResp(request, bfe_http.StatusInternalServerError)
}

// CreateInternalSrvErrResp returns a HTTP 403 response
// CreateForbiddenResp returns a HTTP 403 response
func CreateForbiddenResp(request *Request) *bfe_http.Response {
return CreateInternalResp(request, bfe_http.StatusForbidden)
}
Expand Down
2 changes: 1 addition & 1 deletion bfe_basic/condition/parser/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package parser

// A Visitor's Visit method is invoked for each node encountered by Walk.
// Visitor wraps the Visit method which is invoked for each node encountered by Walk.
// If the result visitor w is not nil, Walk visits each of the children
// of node with the visitor w, followed by a call of w.Visit(nil).
type Visitor interface {
Expand Down
3 changes: 1 addition & 2 deletions bfe_basic/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ func (req *Request) SetRequestTransport(backend *backend.BfeBackend,
func (req *Request) Protocol() string {
if req.Session.IsSecure {
return req.Session.Proto
} else {
return req.HttpRequest.Proto
}
return req.HttpRequest.Proto
}

func (r *Request) AddTags(name string, ntags []string) {
Expand Down
10 changes: 5 additions & 5 deletions bfe_config/bfe_cluster_conf/cluster_conf/cluster_conf_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type HashConf struct {
SessionSticky *bool
}

// Cluster conf for Gslb
// GslbBasicConf is basic conf for Gslb
type GslbBasicConf struct {
CrossRetry *int // retry cross sub clusters
RetryMax *int // inner cluster retry
Expand All @@ -111,7 +111,7 @@ type ClusterBasicConf struct {
CancelOnClientClose *bool // cancel blocking operation on server if client connection disconnected
}

// ClusterBasicConf is conf of cluster.
// ClusterConf is conf of cluster.
type ClusterConf struct {
BackendConf *BackendBasic // backend's basic conf
CheckConf *BackendCheck // how to check backend
Expand Down Expand Up @@ -222,7 +222,7 @@ func MatchStatusCode(statusCodeGet int, statusCodeExpect int) (bool, error) {
statusCodeGet, convertStatusCode(statusCodeExpect))
}

// BackendBasicCheck check BackendCheck config.
// BackendCheckCheck check BackendCheck config.
func BackendCheckCheck(conf *BackendCheck) error {
if conf.Schem == nil {
// set default schem to http
Expand Down Expand Up @@ -337,7 +337,7 @@ func HashConfCheck(conf *HashConf) error {
return nil
}

// ClusterToConf check ClusterBasicConf.
// ClusterBasicConfCheck check ClusterBasicConf.
func ClusterBasicConfCheck(conf *ClusterBasicConf) error {
if conf.TimeoutReadClientAgain == nil ||
conf.TimeoutReadClient == nil ||
Expand Down Expand Up @@ -365,7 +365,7 @@ func ClusterBasicConfCheck(conf *ClusterBasicConf) error {
return nil
}

// ClusterBasicConfCheck check ClusterConf.
// ClusterConfCheck check ClusterConf.
func ClusterConfCheck(conf *ClusterConf) error {
var err error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type RouteRuleFile struct {
type RouteRules []RouteRule
type RouteRuleFiles []RouteRuleFile

// ProductRule holds mapping from product to rules.
// ProductRouteRule holds mapping from product to rules.
type ProductRouteRule map[string]RouteRules
type ProductRouteRuleFile map[string]RouteRuleFiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
RAW_SESSION_TICKET_KEY_SIZE = 48 // bytes
)

// config for session ticket key
// SessionTicketKeyConf is session ticket key config.
type SessionTicketKeyConf struct {
Version string // version of config
SessionTicketKey string // session ticket key (hex encode)
Expand Down
2 changes: 1 addition & 1 deletion bfe_http/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Cookie struct {

type CookieMap map[string]*Cookie

// parse cookies(slice) to req.Route.CookieMap(map)
// CookieMapGet parse cookies(slice) to req.Route.CookieMap(map)
func CookieMapGet(cookies []*Cookie) CookieMap {
cookieMap := make(CookieMap, len(cookies))

Expand Down
2 changes: 1 addition & 1 deletion bfe_http/eof_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"strings"
)

// eofReader is a non-nil io.ReadCloser that always returns EOF.
// EofReader is a non-nil io.ReadCloser that always returns EOF.
// It embeds a *strings.Reader so it still has a WriteTo method
// and io.Copy won't need a buffer.
var EofReader = &struct {
Expand Down
5 changes: 3 additions & 2 deletions bfe_http/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (h Header) Get(key string) string {
return textproto.MIMEHeader(h).Get(key)
}

// get is like Get, but key must already be in CanonicalHeaderKey form.
// GetDirect gets the value associated with the given key
// in CanonicalHeaderKey form.
func (h Header) GetDirect(key string) string {
if v := h[key]; len(v) > 0 {
return v[0]
Expand Down Expand Up @@ -233,7 +234,7 @@ func (h Header) writeSubsetWithoutSort(w io.Writer, exclude map[string]bool) err
// canonical key for "accept-encoding" is "Accept-Encoding".
func CanonicalHeaderKey(s string) string { return textproto.CanonicalMIMEHeaderKey(s) }

// hasToken reports whether token appears with v, ASCII
// HasToken reports whether token appears with v, ASCII
// case-insensitive, with space or comma boundaries.
// token must be all lowercase.
// v may contain mixed cased.
Expand Down
5 changes: 2 additions & 3 deletions bfe_http/httputil/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ func (sc *ServerConn) Read() (req *http.Request, err error) {
// data before the close.
sc.re = ErrPersistEOF
return nil, sc.re
} else {
sc.re = err
return req, err
}
sc.re = err
return req, err
}
sc.lastbody = req.Body
sc.nread++
Expand Down
2 changes: 1 addition & 1 deletion bfe_http/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var StatusText = map[int]string{
statusNetworkAuthenticationRequired: "Network Authentication Required",
}

// StatusText returns a text for the HTTP status code. It returns the empty
// StatusTextGet returns a text for the HTTP status code. It returns the empty
// string if the code is unknown.
func StatusTextGet(code int) string {
return StatusText[code]
Expand Down
3 changes: 1 addition & 2 deletions bfe_http2/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,8 @@ func TestMetaFrameHeader(t *testing.T) {
str := func(v interface{}) string {
if _, ok := v.(error); ok {
return fmt.Sprintf("error %v", v)
} else {
return fmt.Sprintf("value %#v", v)
}
return fmt.Sprintf("value %#v", v)
}
t.Errorf("%s:\n got: %v\nwant: %s", name, str(got), str(tt.want))
}
Expand Down
6 changes: 3 additions & 3 deletions bfe_http2/http2.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func httpCodeString(code int) string {
return strconv.Itoa(code)
}

// connection-specific header fields which should be removed
// HopHeaders are connection-specific header fields which should be removed
// when endpoint generates an http/2 message
var HopHeaders = map[string]bool{
"Connection": true,
Expand Down Expand Up @@ -522,7 +522,7 @@ func strSliceContains(ss []string, s string) bool {
return false
}

// close underlying connection for request
// CloseConn closes underlying connection for request
func CloseConn(body io.ReadCloser) {
if b, ok := body.(*RequestBody); ok {
if b.conn != nil {
Expand All @@ -533,7 +533,7 @@ func CloseConn(body io.ReadCloser) {

var http2Limiter http.FlowLimiter

// init flow limiter for http2
// SetFlowLimiter init flow limiter for http2
func SetFlowLimiter(limiter http.FlowLimiter) {
http2Limiter = limiter
}
Expand Down
3 changes: 1 addition & 2 deletions bfe_http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2501,9 +2501,8 @@ func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int,

if dataB != nil {
return rws.bw.Write(dataB)
} else {
return rws.bw.WriteString(dataS)
}
return rws.bw.WriteString(dataS)
}

func (w *responseWriter) handlerDone() {
Expand Down
10 changes: 5 additions & 5 deletions bfe_module/bfe_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ import (
"github.com/baidu/bfe/bfe_http"
)

// ResponseFilter filters incomming requests and return a response or nil.
// RequestFilter filters incomming requests and return a response or nil.
// Filters are chained together into a HandlerList.
type RequestFilter interface {
FilterRequest(request *bfe_basic.Request) (int, *bfe_http.Response)
}

// NewResponseFilter create a Filter by passed func.
// NewRequestFilter create a Filter by passed func.
func NewRequestFilter(f func(request *bfe_basic.Request) (int, *bfe_http.Response)) RequestFilter {
rf := new(genericRequestFilter)
rf.f = f
Expand All @@ -75,7 +75,7 @@ type ResponseFilter interface {
FilterResponse(req *bfe_basic.Request, res *bfe_http.Response) int
}

// NewRequestFilter creates a Filter by passed func
// NewResponseFilter creates a Filter by passed func
func NewResponseFilter(f func(req *bfe_basic.Request, res *bfe_http.Response) int) ResponseFilter {
rf := new(genericResponseFilter)
rf.f = f
Expand All @@ -95,7 +95,7 @@ type AcceptFilter interface {
FilterAccept(*bfe_basic.Session) int
}

// NewResponseFilter creates a Filter by passed func
// NewAcceptFilter creates a Filter by passed func
func NewAcceptFilter(f func(session *bfe_basic.Session) int) AcceptFilter {
rf := new(genericAcceptFilter)
rf.f = f
Expand All @@ -115,7 +115,7 @@ type ForwardFilter interface {
FilterForward(*bfe_basic.Request) int
}

// NewFinishFilter create a Filter by passed func
// NewForwardFilter create a Filter by passed func
func NewForwardFilter(f func(req *bfe_basic.Request) int) ForwardFilter {
rf := new(genericForwardFilter)
rf.f = f
Expand Down
4 changes: 2 additions & 2 deletions bfe_module/bfe_handler_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type HandlerList struct {
handlers *list.List /* list of handlers */
}

// NewFinishFilter creates a HandlerList.
// NewHandlerList creates a HandlerList.
func NewHandlerList(h_type int) *HandlerList {
handlers := new(HandlerList)

Expand All @@ -63,7 +63,7 @@ func NewHandlerList(h_type int) *HandlerList {
return handlers
}

// FinishFilter filters accept with HandlerList.
// FilterAccept filters accept with HandlerList.
func (hl *HandlerList) FilterAccept(session *bfe_basic.Session) int {
retVal := BFE_HANDLER_GOON

Expand Down
6 changes: 3 additions & 3 deletions bfe_modules/mod_trust_clientip/trustip_conf_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ func TrustIPConfCheck(conf *TrustIPConfFile) error {
return nil
}

// load config of trust-ip from file
// TrustIPConfLoad loads config of trust-ip from file
func TrustIPConfLoad(filename string) (TrustIPConf, error) {
var conf TrustIPConf

/* open the file */
// open the file
file, err1 := os.Open(filename)

if err1 != nil {
return conf, err1
}

/* decode the file */
// decode the file
decoder := json.NewDecoder(file)

config := TrustIPConfFile{}
Expand Down
4 changes: 2 additions & 2 deletions bfe_net/textproto/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

package textproto

// A MIMEHeader represents a MIME-style header mapping
// MIMEHeader represents a MIME-style header mapping
// keys to sets of values.
type MIMEHeader map[string][]string

// A MIMEKyes represents keys of header in original order
// MIMEKyes represents keys of header in original order
type MIMEKeys []string

// Add adds the key, value pair to the header.
Expand Down
2 changes: 1 addition & 1 deletion bfe_route/host_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (t *HostTable) updateRouteTable(conf *route_rule_conf.RouteTableConf) {
t.productRouteTable = conf.RuleMap
}

// update all
// Update updates host table
func (t *HostTable) Update(hostConf host_rule_conf.HostConf,
vipConf vip_rule_conf.VipConf, routeConf *route_rule_conf.RouteTableConf) {

Expand Down
2 changes: 1 addition & 1 deletion bfe_server/bfe_confdata_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (srv *BfeServer) enableTLSNextProto(proto string) {
}
}

// NameConfLoad reloads name conf data.
// NameConfReload reloads name conf data.
func (srv *BfeServer) NameConfReload(query url.Values) error {
nameConfFile := query.Get("path")
if nameConfFile == "" {
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/find_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (srv *BfeServer) FindLocation(request *bfe_basic.Request) (string, error) {
return clusterName, nil
}

// FindProEnd finds product for proxied conn (under tls proxy mode).
// FindProduct finds product for proxied conn (under tls proxy mode).
func (srv *BfeServer) FindProduct(conn net.Conn) string {
sc := srv.GetServerConf()

Expand Down
Loading

0 comments on commit 489aca4

Please sign in to comment.