MCPcopy
hub / github.com/crowdsecurity/crowdsec / getEntDriver

Function getEntDriver

pkg/database/database.go:27–41  ·  view source on GitHub ↗
(dbtype string, dbdialect string, dsn string, config *csconfig.DatabaseCfg)

Source from the content-addressed store, hash-verified

25}
26
27func getEntDriver(dbtype string, dbdialect string, dsn string, config *csconfig.DatabaseCfg) (*entsql.Driver, error) {
28 db, err := sql.Open(dbtype, dsn)
29 if err != nil {
30 return nil, err
31 }
32
33 if config.MaxOpenConns == 0 {
34 config.MaxOpenConns = csconfig.DEFAULT_MAX_OPEN_CONNS
35 }
36
37 db.SetMaxOpenConns(config.MaxOpenConns)
38 drv := entsql.OpenDB(dbdialect, db)
39
40 return drv, nil
41}
42
43func NewClient(ctx context.Context, config *csconfig.DatabaseCfg, logger *log.Entry) (*Client, error) {
44 var client *ent.Client

Callers 1

NewClientFunction · 0.85

Calls 1

OpenMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…