Skip to content

Commit 7b8def6

Browse files
authored
Merge pull request #23 from askuy/feature/option20250331
add options
2 parents dd2bac6 + 7099650 commit 7b8def6

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

option.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package egorm
22

33
import (
4+
"time"
5+
46
"gorm.io/gorm/schema"
57

68
"github.com/ego-component/egorm/manager"
@@ -45,3 +47,51 @@ func WithInterceptor(is ...Interceptor) Option {
4547
c.config.interceptors = append(c.config.interceptors, is...)
4648
}
4749
}
50+
51+
func WithEnableAccessInterceptor(enableAccessInterceptor bool) Option {
52+
return func(c *Container) {
53+
c.config.EnableAccessInterceptor = enableAccessInterceptor
54+
}
55+
}
56+
57+
func WithEnableAccessInterceptorReq(enableAccessInterceptorReq bool) Option {
58+
return func(c *Container) {
59+
c.config.EnableAccessInterceptorReq = enableAccessInterceptorReq
60+
}
61+
}
62+
63+
func WithEnableAccessInterceptorRes(enableAccessInterceptorRes bool) Option {
64+
return func(c *Container) {
65+
c.config.EnableAccessInterceptorRes = enableAccessInterceptorRes
66+
}
67+
}
68+
69+
func WithMaxIdleConns(maxIdleConns int) Option {
70+
return func(c *Container) {
71+
c.config.MaxIdleConns = maxIdleConns
72+
}
73+
}
74+
75+
func WithMaxOpenConns(maxOpenConns int) Option {
76+
return func(c *Container) {
77+
c.config.MaxOpenConns = maxOpenConns
78+
}
79+
}
80+
81+
func WithConnMaxLifetime(connMaxLifetime time.Duration) Option {
82+
return func(c *Container) {
83+
c.config.ConnMaxLifetime = connMaxLifetime
84+
}
85+
}
86+
87+
func WithOnFail(onFail string) Option {
88+
return func(c *Container) {
89+
c.config.OnFail = onFail
90+
}
91+
}
92+
93+
func WithSlowLogThreshold(slowLogThreshold time.Duration) Option {
94+
return func(c *Container) {
95+
c.config.SlowLogThreshold = slowLogThreshold
96+
}
97+
}

0 commit comments

Comments
 (0)