mysqlrepository

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package mysqlrepository provides XMPP functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN             string        `fig:"dsn"`
	MaxOpenConns    int           `fig:"max_open_conns"`
	MaxIdleConns    int           `fig:"max_idle_conns"`
	ConnMaxLifetime time.Duration `fig:"conn_max_lifetime"`
	ConnMaxIdleTime time.Duration `fig:"conn_max_idle_time"`
}

Config contains MySQL configuration value.

type Repository

Repository represents a MySQL repository implementation.

func New

func New(cfg Config, logger kitlog.Logger) *Repository

New creates and returns an initialized MySQL Repository instance.

func (*Repository) InTransaction

func (r *Repository) InTransaction(ctx context.Context, f func(ctx context.Context, tx repository.Transaction) error) error

InTransaction generates a MySQL transaction and completes it after it's being used by f function.

InnoDB may roll back a transaction as the victim of a deadlock or after a lock-wait timeout (errors 1213/1205). This is expected under concurrency — e.g. two parallel MAM archive-trim transactions (InsertArchiveMessage + DeleteArchiveOldestMessages) racing on the i_archives_archive_id index. The server aborts the whole transaction, so replaying the entire f function is the correct recovery, not retrying a single statement. Without this, the 1213 propagates up to the C2S layer and surfaces as "failed to process incoming C2S session element", i.e. the client not sending/reconnecting.

Replay safety: f is expected to be side-effect-free outside the DB. All current callers are pure repository operations; the two roster callers also emit an XMPP roster push inside f, which is idempotent per RFC 6121 (same item + version) and, being a non-archive path, is not observed to deadlock.

func (*Repository) Start

func (r *Repository) Start(ctx context.Context) error

Start implements Start interface method.

func (*Repository) Stop

func (r *Repository) Stop(_ context.Context) error

Stop closes MySQL database and prevents new queries from starting.

Jump to

Keyboard shortcuts

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