mautrix-go/bridgev2/bridgeconfig/backfill.go
Tulir Asokan 4efa4bdac5
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
bridgev2/config: allow multiple prioritized backfill limit override keys
2025-12-06 12:51:12 +02:00

45 lines
1.5 KiB
Go

// Copyright (c) 2024 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package bridgeconfig
type BackfillConfig struct {
Enabled bool `yaml:"enabled"`
MaxInitialMessages int `yaml:"max_initial_messages"`
MaxCatchupMessages int `yaml:"max_catchup_messages"`
UnreadHoursThreshold int `yaml:"unread_hours_threshold"`
Threads BackfillThreadsConfig `yaml:"threads"`
Queue BackfillQueueConfig `yaml:"queue"`
// Flag to indicate that the creator will not run the backfill queue but will still paginate
// backfill by calling DoBackfillTask directly. Note that this is not used anywhere within
// mautrix-go and exists so bridges can use it to decide when to drop backfill data.
WillPaginateManually bool `yaml:"will_paginate_manually"`
}
type BackfillThreadsConfig struct {
MaxInitialMessages int `yaml:"max_initial_messages"`
}
type BackfillQueueConfig struct {
Enabled bool `yaml:"enabled"`
BatchSize int `yaml:"batch_size"`
BatchDelay int `yaml:"batch_delay"`
MaxBatches int `yaml:"max_batches"`
MaxBatchesOverride map[string]int `yaml:"max_batches_override"`
}
func (bqc *BackfillQueueConfig) GetOverride(names ...string) int {
for _, name := range names {
override, ok := bqc.MaxBatchesOverride[name]
if ok {
return override
}
}
return bqc.MaxBatches
}