Passed
Push — master ( 563bb3...17d3c0 )
by Tolga
01:15 queued 15s
created

pkg/database/postgres/options.go   A

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 14
eloc 25
dl 0
loc 52
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A postgres.MaxOpenConnections 0 3 2
A postgres.MaxIdleConnections 0 3 2
A postgres.MaxConnectionLifeTime 0 3 2
A postgres.MaxConnectionIdleTime 0 3 2
A postgres.MaxRetries 0 3 2
A postgres.WatchBufferSize 0 3 2
A postgres.MaxDataPerWrite 0 3 2
1
package postgres
2
3
import (
4
	"time"
5
)
6
7
// Option - Option type
8
type Option func(*Postgres)
9
10
// MaxOpenConnections - Defines maximum open connections for postgresql db
11
func MaxOpenConnections(size int) Option {
12
	return func(c *Postgres) {
13
		c.maxOpenConnections = size
14
	}
15
}
16
17
// MaxIdleConnections - Defines maximum idle connections for postgresql db
18
func MaxIdleConnections(c int) Option {
19
	return func(p *Postgres) {
20
		p.maxIdleConnections = c
21
	}
22
}
23
24
// MaxConnectionIdleTime - Defines maximum connection idle for postgresql db
25
func MaxConnectionIdleTime(d time.Duration) Option {
26
	return func(p *Postgres) {
27
		p.maxConnectionIdleTime = d
28
	}
29
}
30
31
// MaxConnectionLifeTime - Defines maximum connection lifetime for postgresql db
32
func MaxConnectionLifeTime(d time.Duration) Option {
33
	return func(p *Postgres) {
34
		p.maxConnectionLifeTime = d
35
	}
36
}
37
38
func MaxDataPerWrite(max int) Option {
39
	return func(c *Postgres) {
40
		c.maxDataPerWrite = max
41
	}
42
}
43
44
func WatchBufferSize(max int) Option {
45
	return func(c *Postgres) {
46
		c.watchBufferSize = max
47
	}
48
}
49
50
func MaxRetries(max int) Option {
51
	return func(c *Postgres) {
52
		c.maxRetries = max
53
	}
54
}
55