common

package
v0.0.0-...-8d187f3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResourcePrometheusMetricName           = "metric_name"
	ResourcePrometheusLabelName            = "label_name"
	ResourcePrometheusLabelValue           = "label_value"
	ResourcePrometheusMetricAPPLabelLayout = "metric_app_label_layout"
	ResourcePrometheusLabel                = "label"
	ResourcePrometheusMetricLabelName      = "metric_label_name"
)
View Source
var (
	TargetLabelInstance = "instance"
	TargetLabelJob      = "job"
)

Functions

func AppendErrGroup

func AppendErrGroup(eg *errgroup.Group, f ErrFunc, args ...interface{})

func AppendErrGroupWithContext

func AppendErrGroupWithContext(ctx context.Context, eg *errgroup.Group, f ErrFunc, args ...interface{})

func FindPtr

func FindPtr[T any](db *mysql.DB) ([]*T, error)

func ShardingInt

func ShardingInt(i int) uint32

现在使用此方法的地方,传参实际在 uint32 范围内,使用此方法是为了方便调用 concurrent 库

func WhereFind

func WhereFind[T any](db *mysql.DB, query interface{}, args ...interface{}) ([]T, error)

func WhereFindPtr

func WhereFindPtr[T any](db *mysql.DB, query interface{}, args ...interface{}) ([]*T, error)

Types

type ErrFunc

type ErrFunc func(...interface{}) error

type ORG

type ORG struct {
	ID        int       // org id
	DB        *mysql.DB // org database connection
	LogPrefix logger.Prefix
}

func NewORG

func NewORG(id int) (*ORG, error)

func (*ORG) GetDB

func (o *ORG) GetDB() *mysql.DB

func (*ORG) GetID

func (o *ORG) GetID() int

func (*ORG) Log

func (o *ORG) Log(format string) string

func (*ORG) Logf

func (o *ORG) Logf(format string, a ...any) string

Jump to

Keyboard shortcuts

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