Skip to content

Commit

Permalink
fix: statement timeout, uniform naming
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors committed Aug 28, 2020
1 parent 71c1c04 commit 37c806a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *Cache) Init(deleteHandler DeleteHandler, opts ...Option) {
go c.janitor.Run(c)
}

// Options returns a copy of options struct.
// Config returns a copy of config struct.
func (c *Cache) Config() Config {
return c.cfg
}
Expand Down
21 changes: 9 additions & 12 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ type Options struct {
Port string
}

// DefaultDBOptions returns
func DefaultDBOptions() *Options {
return &Options{
Options: pg.Options{
PoolSize: 10,
IdleTimeout: 5 * time.Minute,
PoolTimeout: 30 * time.Second,
MaxConnAge: 15 * time.Minute,
MaxRetries: 1,
},
}
var DefaultOptions = Options{
Options: pg.Options{
PoolSize: 10,
IdleTimeout: 5 * time.Minute,
PoolTimeout: 30 * time.Second,
MaxConnAge: 15 * time.Minute,
MaxRetries: 1,
},
}

func (o *Options) PGOptions() *pg.Options {
Expand Down Expand Up @@ -91,7 +88,7 @@ func (o *Options) PGOptions() *pg.Options {

if opts.OnConnect == nil && o.StatementTimeout != 0 {
opts.OnConnect = func(conn *pg.Conn) error {
_, err := conn.Exec("SET statement_timeout = {}", o.StatementTimeout/time.Microsecond)
_, err := conn.Exec("SET statement_timeout = ?", o.StatementTimeout/time.Microsecond)
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion limiter/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Limiter struct {
cfg Config
}

// Options holds settable options for limiter.
// Config holds settable config for limiter.
type Config struct {
Queue int
TTL time.Duration
Expand Down
4 changes: 2 additions & 2 deletions util/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (res *DownloadResult) String() string {
return fmt.Sprintf("{URL:%s, Error:%s}", res.URL, res.Error)
}

// DownloaderOptions holds information about downloader settable options.
// DownloaderConfig holds information about downloader settable options.
type DownloaderConfig struct {
Concurrency uint
Timeout time.Duration
Expand Down Expand Up @@ -91,7 +91,7 @@ func NewDownloader(opts ...func(*DownloaderConfig)) *HTTPDownloader {
}
}

// Options returns a copy of downloader options struct.
// Config returns a copy of downloader config struct.
func (d *HTTPDownloader) Config() DownloaderConfig {
return d.cfg
}
Expand Down

0 comments on commit 37c806a

Please sign in to comment.