Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
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(v int) Option { |
||
39 | return func(c *Postgres) { |
||
40 | c.maxDataPerWrite = v |
||
41 | } |
||
42 | } |
||
43 | |||
44 | func WatchBufferSize(v int) Option { |
||
45 | return func(c *Postgres) { |
||
46 | c.watchBufferSize = v |
||
47 | } |
||
48 | } |
||
49 | |||
50 | func MaxRetries(v int) Option { |
||
51 | return func(c *Postgres) { |
||
52 | c.maxRetries = v |
||
53 | } |
||
54 | } |
||
55 | |||
56 | func SimpleMode(v bool) Option { |
||
57 | return func(c *Postgres) { |
||
58 | c.simpleMode = v |
||
59 | } |
||
61 |