Documentation ¶
Overview ¶
Package clientx is ent client extension
Index ¶
- Variables
- func BuildEntCacheDriver(cnf *conf.Configuration, preDriver dialect.Driver) (dialect.Driver, *entcache.ChangeSet)
- func WithTx(ctx context.Context, initTxFn Tx, fn func(itx Transactor) error) error
- type RouteDriver
- func (r *RouteDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error)
- func (r *RouteDriver) Close() error
- func (r *RouteDriver) Dialect() string
- func (r *RouteDriver) Exec(ctx context.Context, query string, args, v any) error
- func (r *RouteDriver) Query(ctx context.Context, query string, args, v any) error
- func (r *RouteDriver) Tx(ctx context.Context) (dialect.Tx, error)
- type RouteDriverOption
- type Transactor
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ChangeSet *entcache.ChangeSet
)
Functions ¶
func BuildEntCacheDriver ¶
func BuildEntCacheDriver(cnf *conf.Configuration, preDriver dialect.Driver) (dialect.Driver, *entcache.ChangeSet)
BuildEntCacheDriver 构建ent缓存驱动.这里保证ChangeSet为第一次初始的单例值.
func WithTx ¶
WithTx runs the given function in a transaction.If the function returns an error, the transaction is rolled back.
Example:
WithTx(ctx, func(ctx context.Context) (clientx.Transactor, error) { return db.Tx(ctx) // db is *ent.Client }, func(itx clientx.Transactor) error { tx := itx.(*ent.Tx) // do something with tx })
Types ¶
type RouteDriver ¶
type RouteDriver struct {
// contains filtered or unexported fields
}
RouteDriver is a dialect.Driver that routes to different database instances based on the domain name.
func NewRouteDriver ¶
func NewRouteDriver(cfg *conf.Configuration, opts ...RouteDriverOption) *RouteDriver
NewRouteDriver return a router driver from woocoo configuration
Example:
``` yaml store:
portal: driverName: mysql dsn: root:@tcp(localhost:3306)/portal?parseTime=true&loc=Local multiInstances: test.com: dsn: root:@tcp(localhost:3307)/portal?parseTime=true&loc=Local test.cn: driverName: mysql dsn: root:@tcp(localhost:3308)/portal?parseTime=true&loc=Local
```
func (*RouteDriver) Close ¶
func (r *RouteDriver) Close() error
func (*RouteDriver) Dialect ¶
func (r *RouteDriver) Dialect() string
type RouteDriverOption ¶
type RouteDriverOption func(*RouteDriver)
type Transactor ¶
Transactor is the interface that wraps the Commit and Rollback methods.
Click to show internal directories.
Click to hide internal directories.