bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/database/ent/config.go (about) 1 // Code generated by entc, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "entgo.io/ent" 7 "entgo.io/ent/dialect" 8 ) 9 10 // Option function to configure the client. 11 type Option func(*config) 12 13 // Config is the configuration for the client and its builder. 14 type config struct { 15 // driver used for executing database requests. 16 driver dialect.Driver 17 // debug enable a debug logging. 18 debug bool 19 // log used for logging on debug mode. 20 log func(...interface{}) 21 // hooks to execute on mutations. 22 hooks *hooks 23 } 24 25 // hooks per client, for fast access. 26 type hooks struct { 27 Alert []ent.Hook 28 Bouncer []ent.Hook 29 Decision []ent.Hook 30 Event []ent.Hook 31 Machine []ent.Hook 32 Meta []ent.Hook 33 } 34 35 // Options applies the options on the config object. 36 func (c *config) options(opts ...Option) { 37 for _, opt := range opts { 38 opt(c) 39 } 40 if c.debug { 41 c.driver = dialect.Debug(c.driver, c.log) 42 } 43 } 44 45 // Debug enables debug logging on the ent.Driver. 46 func Debug() Option { 47 return func(c *config) { 48 c.debug = true 49 } 50 } 51 52 // Log sets the logging function for debug mode. 53 func Log(fn func(...interface{})) Option { 54 return func(c *config) { 55 c.log = fn 56 } 57 } 58 59 // Driver configures the client driver. 60 func Driver(driver dialect.Driver) Option { 61 return func(c *config) { 62 c.driver = driver 63 } 64 }