|
1 | 1 | package egorm |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "time" |
| 5 | + |
4 | 6 | "gorm.io/gorm/schema" |
5 | 7 |
|
6 | 8 | "github.com/ego-component/egorm/manager" |
@@ -45,3 +47,51 @@ func WithInterceptor(is ...Interceptor) Option { |
45 | 47 | c.config.interceptors = append(c.config.interceptors, is...) |
46 | 48 | } |
47 | 49 | } |
| 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