oceanbase
59 строк · 1.1 Кб
1// Code generated by entc, DO NOT EDIT.
2
3package ent4
5import (6"entgo.io/ent"7"entgo.io/ent/dialect"8)
9
10// Option function to configure the client.
11type Option func(*config)12
13// Config is the configuration for the client and its builder.
14type config struct {15// driver used for executing database requests.16driver dialect.Driver17// debug enable a debug logging.18debug bool19// log used for logging on debug mode.20log func(...interface{})21// hooks to execute on mutations.22hooks *hooks23}
24
25// hooks per client, for fast access.
26type hooks struct {27ObCluster []ent.Hook28}
29
30// Options applies the options on the config object.
31func (c *config) options(opts ...Option) {32for _, opt := range opts {33opt(c)34}35if c.debug {36c.driver = dialect.Debug(c.driver, c.log)37}38}
39
40// Debug enables debug logging on the ent.Driver.
41func Debug() Option {42return func(c *config) {43c.debug = true44}45}
46
47// Log sets the logging function for debug mode.
48func Log(fn func(...interface{})) Option {49return func(c *config) {50c.log = fn51}52}
53
54// Driver configures the client driver.
55func Driver(driver dialect.Driver) Option {56return func(c *config) {57c.driver = driver58}59}
60