gorm

package
v1.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogAdapter

func NewLogAdapter(l kitlog.Logger, slowThreshold time.Duration, tracer trace.Tracer) logger.Interface

func WithConnContext

func WithConnContext[T ConnType](ctx context.Context, conn T) context.Context

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewGormSQLiteClient

func NewGormSQLiteClient(ctx context.Context, options *SQLiteOptions) (clt *Client, err error)

func NewMySQLClient

func NewMySQLClient(ctx context.Context, options MySQLOptions) (clt *Client, err error)

func (*Client) Session

func (c *Client) Session(ctx context.Context) *gorm.DB

type ConnType

type ConnType interface {
	*gorm.DB
}

type DBOptions added in v1.1.12

type DBOptions interface {
	GetConnectionString() string
	GetPeer() (string, int)
	GetDBName() string
	GetUsername() string
	GetType() string
}

type MySQLClient

type MySQLClient struct {
	*Client
	// contains filtered or unexported fields
}

func (MySQLClient) MarshalJSON

func (c MySQLClient) MarshalJSON() ([]byte, error)

func (MySQLClient) Options

func (c MySQLClient) Options() MySQLOptions

func (*MySQLClient) SetOptions

func (c *MySQLClient) SetOptions(o *MySQLOptions)

func (*MySQLClient) UnmarshalJSON

func (c *MySQLClient) UnmarshalJSON(data []byte) (err error)

type MySQLOptions

type MySQLOptions struct {
	Host                  string          `json:"host,omitempty"`
	Username              string          `json:"username,omitempty"`
	Password              safe.String     `json:"password,omitempty"`
	Schema                string          `json:"schema,omitempty"`
	MaxIdle               int32           `json:"max_idle,omitempty"`
	MaxIdleConnections    int32           `json:"max_idle_connections,omitempty"`
	MaxOpenConnections    int32           `json:"max_open_connections,omitempty"`
	MaxConnectionLifeTime *model.Duration `json:"max_connection_life_time,omitempty"`
	Charset               string          `json:"charset,omitempty"`
	Collation             string          `json:"collation,omitempty"`
	TablePrefix           string          `json:"table_prefix,omitempty"`
	SlowThreshold         *model.Duration `json:"slow_threshold,omitempty"`
	TLSConfig             *TLSOptions     `json:"tls_config" yaml:"tls_config" mapstructure:"tls_config"`
}

func NewMySQLOptions

func NewMySQLOptions() *MySQLOptions

func (*MySQLOptions) GetConnectionString added in v1.1.12

func (x *MySQLOptions) GetConnectionString() string

func (*MySQLOptions) GetDBName added in v1.1.12

func (x *MySQLOptions) GetDBName() string

func (*MySQLOptions) GetPeer added in v1.1.12

func (x *MySQLOptions) GetPeer() (string, int)

func (*MySQLOptions) GetStdMaxConnectionLifeTime

func (x *MySQLOptions) GetStdMaxConnectionLifeTime() time.Duration

func (*MySQLOptions) GetType added in v1.1.12

func (x *MySQLOptions) GetType() string

func (*MySQLOptions) GetUsername added in v1.1.12

func (x *MySQLOptions) GetUsername() string

type MySQLStatsCollector added in v1.2.0

type MySQLStatsCollector struct {
	// contains filtered or unexported fields
}

func (*MySQLStatsCollector) Collect added in v1.2.0

func (m *MySQLStatsCollector) Collect(metrics chan<- prometheus.Metric)

func (*MySQLStatsCollector) Describe added in v1.2.0

func (m *MySQLStatsCollector) Describe(descs chan<- *prometheus.Desc)

type Processor

type Processor interface {
	Get(name string) func(*gorm.DB)
	Replace(name string, handler func(*gorm.DB)) error
}

type SQLiteClient

type SQLiteClient struct {
	*Client
	// contains filtered or unexported fields
}

func NewSQLiteClient

func NewSQLiteClient(ctx context.Context, options *SQLiteOptions) (clt *SQLiteClient, err error)

func (SQLiteClient) MarshalJSON

func (c SQLiteClient) MarshalJSON() ([]byte, error)

func (*SQLiteClient) UnmarshalJSON

func (c *SQLiteClient) UnmarshalJSON(data []byte) (err error)

type SQLiteOptions

type SQLiteOptions struct {
	Path                 string          `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	TablePrefix          string          `protobuf:"bytes,2,opt,name=table_prefix,json=tablePrefix,proto3" json:"table_prefix,omitempty"`
	SlowThreshold        *types.Duration `protobuf:"bytes,12,opt,name=slow_threshold,json=slowThreshold,proto3" json:"slow_threshold,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"` //nolint:revive
	XXX_unrecognized     []byte          `json:"-"` //nolint:revive
	XXX_sizecache        int32           `json:"-"` //nolint:revive
}

func NewSQLiteOptions

func NewSQLiteOptions() *SQLiteOptions

func (SQLiteOptions) GetConnectionString added in v1.1.12

func (o SQLiteOptions) GetConnectionString() string

func (SQLiteOptions) GetDBName added in v1.1.12

func (o SQLiteOptions) GetDBName() string

func (SQLiteOptions) GetPeer added in v1.1.12

func (o SQLiteOptions) GetPeer() (string, int)

func (SQLiteOptions) GetType added in v1.1.12

func (o SQLiteOptions) GetType() string

func (SQLiteOptions) GetUsername added in v1.1.12

func (o SQLiteOptions) GetUsername() string

type SessionClient added in v1.2.3

type SessionClient interface {
	Session(ctx context.Context) *gorm.DB
}

type TLSOptions added in v1.2.4

type TLSOptions struct {
	// contains filtered or unexported fields
}

func (TLSOptions) MarshalJSON added in v1.2.4

func (o TLSOptions) MarshalJSON() ([]byte, error)

func (*TLSOptions) UnmarshalJSON added in v1.2.4

func (o *TLSOptions) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL