Skip to content

Commit

Permalink
add Option notes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Aug 24, 2022
1 parent 5ab9d45 commit 3e946a0
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gin/middleware/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type options struct {
requestIDName string
}

// Option logger middleware options
// Option set the gin logger options.
type Option func(*options)

func (o *options) apply(opts ...Option) {
Expand Down
4 changes: 2 additions & 2 deletions gin/middleware/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func initPrometheus() {
go recordUptime()
}

// recordUptime increases service uptime per second.
// recordUptime increases service uptime per 30 second.
func recordUptime() {
for range time.Tick(time.Second) {
for range time.Tick(time.Second * 30) {
uptime.WithLabelValues().Inc()
}
}
Expand Down
2 changes: 1 addition & 1 deletion gin/middleware/metrics/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
)

// Option set fields
// Option set the metrics options.
type Option func(*options)

type options struct {
Expand Down
6 changes: 3 additions & 3 deletions gin/middleware/ratelimiter/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
defaultIsIP = false
)

// Option logger middleware options
// Option set the rate limits options.
type Option func(*options)

func defaultOptions() *options {
Expand All @@ -39,9 +39,9 @@ func (o *options) apply(opts ...Option) {
}

// WithQPS set the qps value
func WithQPS(qps rate.Limit) Option {
func WithQPS(qps int) Option {
return func(o *options) {
o.qps = qps
o.qps = rate.Limit(qps)
}
}

Expand Down
1 change: 1 addition & 0 deletions gocron/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (o *options) apply(opts ...Option) {
}
}

// Option set the cron options.
type Option func(*options)

// WithLog 设置日志
Expand Down
1 change: 1 addition & 0 deletions gofile/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func defaultOptions() *options {
}
}

// Option set the file options.
type Option func(*options)

func (o *options) apply(opts ...Option) {
Expand Down
2 changes: 1 addition & 1 deletion goredis/option.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goredis

// Option set fields
// Option set the redis options.
type Option func(*options)

type options struct {
Expand Down
2 changes: 1 addition & 1 deletion grpc/middleware/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (o *options) apply(opts ...Option) {
}
}

// Option retry option function
// Option set the retry options.
type Option func(*options)

// WithRetryTimes 设置重试次数,最大10次
Expand Down
1 change: 1 addition & 0 deletions jwt/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func defaultOptions() *options {
}
}

// Option set the jwt options.
type Option func(*options)

func (o *options) apply(opts ...Option) {
Expand Down
1 change: 1 addition & 0 deletions logger/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (o *options) apply(opts ...Option) {
}
}

// Option set the logger options.
type Option func(*options)

// WithLevel 输出日志级别
Expand Down
2 changes: 1 addition & 1 deletion mysql/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"
)

// Option set fields
// Option set the mysql options.
type Option func(*options)

type options struct {
Expand Down

0 comments on commit 3e946a0

Please sign in to comment.