db

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(ctx context.Context, db *mongo.Database) error

type CollectionName

type CollectionName string
const (
	CommandRegistrationsCollection CollectionName = "command_registrations"
	GuildConfigCollection          CollectionName = "guild_config"
)

func (CollectionName) String

func (c CollectionName) String() string

type CommandRegistration

type CommandRegistration struct {
	GuildId     string `bson:"guild_id"`
	CommandId   string `bson:"command_id"`
	CommandName string `bson:"command_name"`
}

type Func

type Func func(ctx context.Context, cb Callback) error

type GuildConfig

type GuildConfig struct {
	GuildId       string         `bson:"guild_id"`
	ScrapeConfigs []ScrapeConfig `bson:"scrape_configs"`
}

func NewGuildConfig

func NewGuildConfig(guildId string) *GuildConfig

type Repo

type Repo interface {
	RegisterCommand(ctx context.Context, guildId string, commandId string, commandName string) error
	GetRegisteredCommands(ctx context.Context, guildId string) ([]CommandRegistration, error)
	GetGuildConfigs(ctx context.Context) ([]GuildConfig, error)
	GetGuildConfig(ctx context.Context, guildId string) (*GuildConfig, error)
	SetGuildConfig(ctx context.Context, config *GuildConfig) error
	ClearGuildInfo(ctx context.Context, guildId string) error
}

func SetupInMemoryDatabase

func SetupInMemoryDatabase(logger logrus.FieldLogger) Repo

func SetupMongoDatabase

func SetupMongoDatabase(cfg config.Database) Repo

type ScrapeConfig

type ScrapeConfig struct {
	Name                  string   `bson:"scrape_name"`
	Endpoint              string   `bson:"endpoint"`
	Username              string   `bson:"username"`
	Password              string   `bson:"password"`
	ScrapeIntervalMinutes int64    `bson:"scrape_interval_minutes"`
	AlertChannelId        string   `bson:"alert_channel_id"`
	InhibitedAlerts       []string `bson:"inhibited_alerts"`
}

Jump to

Keyboard shortcuts

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