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 ¶
type Repository struct {
repository.User
repository.Last
repository.Capabilities
repository.Offline
repository.BlockList
repository.Private
repository.Roster
repository.VCard
repository.Archive
repository.Locker
repository.PubSub
repository.MUC
repository.MIX
repository.MUCRTBL
repository.Push
repository.Fast
repository.SpamReporting
repository.InviteToken
repository.MUCInviteToken
repository.Privacy
repository.OAuth
repository.Tombstone
// contains filtered or unexported fields
}
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.