Documentation ¶
Overview ¶
*
- @author huqiuyun
- 数据Elasticsearch
*
- @author huqiuyun
- 数据服务
Index ¶
- Variables
- func AddDriver(driverName string, dial DialFunc)
- func UseServerPubKey(cnf *config.Database, opts ...option.Option) error
- func UseTls(cnf *config.Database, opts ...option.Option) error
- func WithDnsOption(f func(cnf *config.Database, tls, pubKey bool) string) option.Option
- func WithServerPubKeyOption(f func(cnf *config.Database) (*rsa.PublicKey, error)) option.Option
- func WithTlsOption(f func(cnf *config.Database) (*tls.Config, error)) option.Option
- type Adapter
- type ConditionCallback
- type DialFunc
- type EsDatabase
- type Logger
- func (l *Logger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, msg string, data ...interface{})
- type ScopesFunc
- type ServerPubKeyFunc
- type Sql
- type SqlDatabase
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultDnsFunc = func(cnf *config.Database, tls, serverPubKey bool) string { if cnf == nil { return "" } if cnf.DriverType == "mysql" { if cnf.Charset == "" { cnf.Charset = "utf8mb4" } dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=True&loc=Local", cnf.User, cnf.Pwd, cnf.Host, cnf.Port, cnf.Name, cnf.Charset) if tls { dsn += "&tls=" + url.QueryEscape(cnf.Tls.Key) } if serverPubKey { dsn += "&serverPubKey=" + url.QueryEscape(cnf.ServerPubKey.Key) } return dsn } else if cnf.DriverType == "postgres" { return fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s", cnf.Host, cnf.Port, cnf.User, cnf.Pwd, cnf.Name) } else if cnf.DriverType == "sqlite3" { return cnf.Name } else if cnf.DriverType == "sql" { return fmt.Sprintf("sqlserver://%s:%s@%s:%d?database=%s", cnf.User, cnf.Pwd, cnf.Host, cnf.Port, cnf.Name) } return "" }
View Source
var DefaultTlsFunc = func(cnf *config.Database) (*tls.Config, error) { if strings.EqualFold(cnf.Tls.Key, "true") || strings.EqualFold(cnf.Tls.Key, "false") || strings.EqualFold(cnf.Tls.Key, "skip-verify") || strings.EqualFold(cnf.Tls.Key, "preferred") { return nil, nil } cert, rootCertPool, err := commontls.GetCertificate(&cnf.Tls) if err != nil { return nil, err } return &tls.Config{ RootCAs: rootCertPool, Certificates: []tls.Certificate{cert}, }, nil }
Functions ¶
func UseServerPubKey ¶ added in v1.9.15
func WithDnsOption ¶ added in v1.9.15
func WithServerPubKeyOption ¶ added in v1.9.15
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter represents the Gorm adapter for policy storage.
func NewAdapter ¶
NewAdapter is the constructor for Adapter.
type ConditionCallback ¶
type EsDatabase ¶
type Logger ¶ added in v0.5.27
func (*Logger) LogMode ¶ added in v0.5.30
func (l *Logger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
LogMode log mode
type ServerPubKeyFunc ¶ added in v1.9.15
func (ServerPubKeyFunc) String ¶ added in v1.9.15
func (t ServerPubKeyFunc) String() string
func (ServerPubKeyFunc) Type ¶ added in v1.9.15
func (t ServerPubKeyFunc) Type() int
func (ServerPubKeyFunc) Value ¶ added in v1.9.15
func (t ServerPubKeyFunc) Value() interface{}
Click to show internal directories.
Click to hide internal directories.