wwdb

package
v0.15.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MB = 1 << 20

Variables

This section is empty.

Functions

func FloodCommand added in v0.5.1

func FloodCommand(dbConn func() *sqlx.DB) *cli.Command

func FloodGC added in v0.5.1

func FloodGC(ctx context.Context, dbConn *sqlx.DB) (int64, error)

func FloodUnban added in v0.5.1

func FloodUnban(ctx context.Context, dbConn *sqlx.DB, identifier string) (int64, error)

func Lock added in v0.1.1

func Lock(ctx context.Context, db *sqlx.DB, name string) error

func MigrateCommand

func MigrateCommand(migrator func() *migrate.Migrate) *cli.Command

func MysqlDbMigrate

func MysqlDbMigrate(db *sqlx.DB, migrations *bindata.AssetSource) (*migrate.Migrate, error)

func OpenDb

func OpenDb(log zerolog.Logger, driverName string, dsn string, maxOpenConns int) (*sqlx.DB, error)

func OpenDbFromWhaleblazer

func OpenDbFromWhaleblazer(log zerolog.Logger, maxOpenConns int) (*sqlx.DB, error)

func Unlock added in v0.1.1

func Unlock(ctx context.Context, name string) error

func WhaleblazerMysqlConfig

func WhaleblazerMysqlConfig() (*mysql2.Config, error)

Types

type Flood added in v0.5.1

type Flood struct {
	Db        *sqlx.DB
	Name      string
	Window    time.Duration
	Threshold int
}

func (*Flood) Clear added in v0.5.1

func (f *Flood) Clear(ctx context.Context, identifier string) error

func (*Flood) Empty added in v0.5.1

func (f *Flood) Empty(ctx context.Context) error

func (*Flood) IsAllowed added in v0.5.1

func (f *Flood) IsAllowed(ctx context.Context, identifier string) bool

func (*Flood) Register added in v0.5.1

func (f *Flood) Register(ctx context.Context, identifier string)

type FloodHit added in v0.5.1

type FloodHit struct {
	Event      string    `db:"event"`
	Identifier string    `db:"identifier"`
	Timestamp  time.Time `db:"timestamp"`
	Expiration time.Time `db:"expiration"`
}

type FloodSummaryItem added in v0.5.1

type FloodSummaryItem struct {
	Event      string    `db:"event"`
	Identifier string    `db:"identifier"`
	Count      int       `db:"count"`
	LastHit    time.Time `db:"lastHit"`
}

func FloodGetSummary added in v0.5.1

func FloodGetSummary(ctx context.Context, dbConn *sqlx.DB) ([]*FloodSummaryItem, error)

Jump to

Keyboard shortcuts

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