Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
perfect document for use
Browse files Browse the repository at this point in the history
Signed-off-by: chentanjun <[email protected]>
  • Loading branch information
tanjunchen committed Sep 12, 2019
1 parent ccc7ba7 commit 4e08341
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/dflog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func WithMaxSizeMB(max uint) Option {
}
}

// WithConsole add a hook to output logs to stdout
// WithConsole adds a hook to output logs to stdout
func WithConsole() Option {
return func(l *logrus.Logger) error {
consoleLog := &logrus.Logger{
Expand Down
10 changes: 5 additions & 5 deletions pkg/limitreader/limit_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
"github.com/dragonflyoss/Dragonfly/pkg/ratelimiter"
)

// NewLimitReader create LimitReader
// NewLimitReader creates LimitReader
// src: reader
// rate: bytes/second
func NewLimitReader(src io.Reader, rate int, calculateMd5 bool) *LimitReader {
return NewLimitReaderWithLimiter(newRateLimiterWithDefaultWindow(rate), src, calculateMd5)
}

// NewLimitReaderWithLimiter create LimitReader with a rateLimiter.
// NewLimitReaderWithLimiter creates LimitReader with a rateLimiter.
// src: reader
// rate: bytes/second
func NewLimitReaderWithLimiter(rl *ratelimiter.RateLimiter, src io.Reader, calculateMd5 bool) *LimitReader {
Expand All @@ -47,14 +47,14 @@ func NewLimitReaderWithLimiter(rl *ratelimiter.RateLimiter, src io.Reader, calcu
}
}

// NewLimitReaderWithMD5Sum create LimitReader with a md5 sum.
// NewLimitReaderWithMD5Sum creates LimitReader with a md5 sum.
// src: reader
// rate: bytes/second
func NewLimitReaderWithMD5Sum(src io.Reader, rate int, md5sum hash.Hash) *LimitReader {
return NewLimitReaderWithLimiterAndMD5Sum(src, newRateLimiterWithDefaultWindow(rate), md5sum)
}

// NewLimitReaderWithLimiterAndMD5Sum create LimitReader with rateLimiter and md5 sum.
// NewLimitReaderWithLimiterAndMD5Sum creates LimitReader with rateLimiter and md5 sum.
// src: reader
// rate: bytes/second
func NewLimitReaderWithLimiterAndMD5Sum(src io.Reader, rl *ratelimiter.RateLimiter, md5sum hash.Hash) *LimitReader {
Expand Down Expand Up @@ -90,7 +90,7 @@ func (lr *LimitReader) Read(p []byte) (n int, err error) {
return n, e
}

// Md5 calculate the md5 of all contents read
// Md5 calculates the md5 of all contents read
func (lr *LimitReader) Md5() string {
if lr.md5sum != nil {
return fmt.Sprintf("%x", lr.md5sum.Sum(nil))
Expand Down
6 changes: 3 additions & 3 deletions pkg/netutils/netutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func ExtractHost(hostAndPort string) string {
return fields[0]
}

// GetIPAndPortFromNode return ip and port by parsing the node value.
// GetIPAndPortFromNode returns ip and port by parsing the node value.
// It will return defaultPort as the value of port
// when the node is a string without port or with an illegal port.
func GetIPAndPortFromNode(node string, defaultPort int) (string, int) {
Expand Down Expand Up @@ -260,7 +260,7 @@ func ConvertTimeIntToString(timestamp int64) (string, error) {
return fmt.Sprintf("%s%s", timeString[:len(timeString)-3], layoutGMT), nil
}

// slice2Map translate a slice to a map with
// slice2Map translates a slice to a map with
// the value in slice as the key and true as the value.
func slice2Map(value []string) map[string]bool {
mmap := make(map[string]bool)
Expand All @@ -278,7 +278,7 @@ func isExist(mmap map[string]bool, key string) bool {
return false
}

// CalculateTimeout calculate the timeout(in seconds) according to the fileLength and the min rate of network.
// CalculateTimeout calculates the timeout(in seconds) according to the fileLength and the min rate of network.
//
// The 0 will be returned when both minRate and defaultMinRate both are <=0.
func CalculateTimeout(fileLength int64, minRate int, defaultMinRate int, reservedTime time.Duration) time.Duration {
Expand Down
2 changes: 1 addition & 1 deletion test/command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (s *Starter) kill(cmd *exec.Cmd) {
}
}

// execCmd execute a command.
// execCmd executes a command.
// param running indicates that how much time the process can run at most,
// after the running duration, the process will be killed automatically.
// When the value of running is less than 0, it will not be killed automatically,
Expand Down
2 changes: 1 addition & 1 deletion test/util_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func CheckRespStatus(c *check.C, resp *http.Response, status int) {
}
}

// CheckMetric find the specific metric from /metrics endpoint and it will compare the metric
// CheckMetric finds the specific metric from /metrics endpoint and it will compare the metric
// value with expected value.
func CheckMetric(c *check.C, metric string, value float64) {
var val float64
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func Print(program string) string {
return strings.TrimSpace(buf.String())
}

// NewBuildInfo register a collector which exports metrics about version and build information.
// NewBuildInfo registers a collector which exports metrics about version and build information.
func NewBuildInfo(program string, registerer prometheus.Registerer) {
buildInfo := metricsutils.NewGauge(program, "build_info",
fmt.Sprintf("A metric with a constant '1' value labeled by version, revision, os, "+
Expand Down

0 comments on commit 4e08341

Please sign in to comment.