gorm

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 29 Imported by: 5

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, client 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) *Database

type ConnType

type ConnType interface {
	*Database | *gorm.DB
}

type DBOptions added in v1.1.12

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

type Database

type Database struct {
	*gorm.DB
}

type Handler

type Handler func(*gorm.DB)

type Interceptor

type Interceptor func(name string, next Handler) Handler

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              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"`
}

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 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:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

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

Jump to

Keyboard shortcuts

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