store

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRegion       = "us-east-1"
	DefaultBucketPrefix = "ethrand"
)

Functions

This section is empty.

Types

type AlertAlreadyRegisteredError

type AlertAlreadyRegisteredError struct {
	Network string
	Channel string
	Guild   string
	Client  string
}

AlertAlreadyRegisteredError represents an error when trying to register an alert that already exists.

func (*AlertAlreadyRegisteredError) Error

Error implements error.

type AlertNotRegisteredError

type AlertNotRegisteredError struct {
	Network string
	Guild   string
	Client  string
}

AlertNotRegisteredError represents an error when trying to deregister an alert that doesn't exist.

func (*AlertNotRegisteredError) Error

func (e *AlertNotRegisteredError) Error() string

Error implements error.

type BaseRepo

type BaseRepo struct {
	// contains filtered or unexported fields
}

BaseRepo contains common S3 functionality for all repositories.

func NewBaseRepo

func NewBaseRepo(ctx context.Context, log *logrus.Logger, cfg *S3Config, metrics *Metrics) (BaseRepo, error)

NewBaseRepo creates a new base repository with common S3 functionality.

func (*BaseRepo) GetS3Client

func (b *BaseRepo) GetS3Client() *s3.Client

GetS3Client returns the underlying S3 client.

func (*BaseRepo) VerifyConnection

func (b *BaseRepo) VerifyConnection(ctx context.Context) error

VerifyConnection verifies the S3 connection and bucket accessibility.

type CheckArtifact

type CheckArtifact struct {
	Network   string    `json:"network"`
	Client    string    `json:"client"`
	CheckID   string    `json:"checkId"`
	Type      string    `json:"type"` // log, png, etc
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Content   []byte    `json:"content"`
}

CheckArtifact represents a single artifact from a check run.

type ChecksRepo

type ChecksRepo struct {
	BaseRepo
}

ChecksRepo implements Repository for check artifacts.

func NewChecksRepo

func NewChecksRepo(ctx context.Context, log *logrus.Logger, cfg *S3Config, metrics *Metrics) (*ChecksRepo, error)

NewChecksRepo creates a new ChecksRepo.

func (*ChecksRepo) GetArtifact

func (s *ChecksRepo) GetArtifact(ctx context.Context, network, client, checkID, artifactType string) (*CheckArtifact, error)

GetArtifact retrieves an artifact from S3.

func (*ChecksRepo) GetBucket

func (s *ChecksRepo) GetBucket() string

GetBucket returns the S3 bucket name.

func (*ChecksRepo) GetPrefix

func (s *ChecksRepo) GetPrefix() string

GetPrefix returns the S3 prefix.

func (*ChecksRepo) GetStore

func (s *ChecksRepo) GetStore() *s3.Client

GetStore returns the S3 client.

func (*ChecksRepo) Key

func (s *ChecksRepo) Key(artifact *CheckArtifact) string

Key implements Repository[*CheckArtifact].

func (*ChecksRepo) List

func (s *ChecksRepo) List(ctx context.Context) ([]*CheckArtifact, error)

List implements Repository[*CheckArtifact].

func (*ChecksRepo) Persist

func (s *ChecksRepo) Persist(ctx context.Context, artifact *CheckArtifact) error

Persist implements Repository[*CheckArtifact].

func (*ChecksRepo) Purge

func (s *ChecksRepo) Purge(ctx context.Context, identifiers ...string) error

Purge implements Repository[*CheckArtifact].

type ClientMention

type ClientMention struct {
	Network        string    `json:"network"`
	Client         string    `json:"client"`
	DiscordGuildID string    `json:"discordGuildId"` // Added field to store the guild/server ID
	Mentions       []string  `json:"mentions"`       // List of role/user IDs to mention
	Enabled        bool      `json:"enabled"`        // Whether mentions are enabled
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
}

ClientMention represents a set of mentions for a client on a network.

type HiveSummaryRepo added in v0.0.13

type HiveSummaryRepo struct {
	BaseRepo
}

HiveSummaryRepo implements Repository for Hive summary alerts.

func NewHiveSummaryRepo added in v0.0.13

func NewHiveSummaryRepo(ctx context.Context, log *logrus.Logger, cfg *S3Config, metrics *Metrics) (*HiveSummaryRepo, error)

NewHiveSummaryRepo creates a new HiveSummaryRepo.

func (*HiveSummaryRepo) GetByNetwork added in v0.0.13

func (s *HiveSummaryRepo) GetByNetwork(ctx context.Context, network string) (*hive.HiveSummaryAlert, error)

GetByNetwork retrieves a Hive summary alert by network.

func (*HiveSummaryRepo) GetPreviousSummaryResult added in v0.0.13

func (s *HiveSummaryRepo) GetPreviousSummaryResult(ctx context.Context, network string) (*hive.SummaryResult, error)

GetPreviousSummaryResult retrieves the previous summary result.

func (*HiveSummaryRepo) Key added in v0.0.13

Key implements Repository for Hive summary alerts.

func (*HiveSummaryRepo) List added in v0.0.13

List implements Repository for Hive summary alerts.

func (*HiveSummaryRepo) Persist added in v0.0.13

func (s *HiveSummaryRepo) Persist(ctx context.Context, alert *hive.HiveSummaryAlert) error

Persist implements Repository for Hive summary alerts.

func (*HiveSummaryRepo) Purge added in v0.0.13

func (s *HiveSummaryRepo) Purge(ctx context.Context, identifiers ...string) error

Purge implements Repository for Hive summary alerts.

func (*HiveSummaryRepo) StoreSummaryResult added in v0.0.13

func (s *HiveSummaryRepo) StoreSummaryResult(ctx context.Context, result *hive.SummaryResult) error

StoreSummaryResult stores a summary result for historical tracking.

type MentionsRepo

type MentionsRepo struct {
	BaseRepo
}

MentionsRepo implements Repository[*ClientMention].

func NewMentionsRepo

func NewMentionsRepo(ctx context.Context, log *logrus.Logger, cfg *S3Config, metrics *Metrics) (*MentionsRepo, error)

NewMentionsRepo creates a new MentionsRepo.

func (*MentionsRepo) Get

func (s *MentionsRepo) Get(ctx context.Context, network, client, guildID string) (*ClientMention, error)

Get retrieves a specific mention by network, client, and guild ID.

func (*MentionsRepo) Key

func (s *MentionsRepo) Key(mention *ClientMention) string

Key implements Repository[*ClientMention].

func (*MentionsRepo) List

func (s *MentionsRepo) List(ctx context.Context) ([]*ClientMention, error)

List implements Repository[*ClientMention].

func (*MentionsRepo) Persist

func (s *MentionsRepo) Persist(ctx context.Context, mention *ClientMention) error

Persist implements Repository[*ClientMention].

func (*MentionsRepo) Purge

func (s *MentionsRepo) Purge(ctx context.Context, identifiers ...string) error

Purge implements Repository[*ClientMention].

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(namespace string) *Metrics

type MonitorAlert

type MonitorAlert struct {
	Network        string             `json:"network"`
	Client         string             `json:"client"`
	CheckID        string             `json:"checkId"`
	Enabled        bool               `json:"enabled"`
	DiscordChannel string             `json:"discordChannel"`
	DiscordGuildID string             `json:"discordGuildId"`
	Interval       time.Duration      `json:"interval"`
	Schedule       string             `json:"schedule"`
	ClientType     clients.ClientType `json:"clientType"`
	CreatedAt      time.Time          `json:"createdAt"`
	UpdatedAt      time.Time          `json:"updatedAt"`
}

MonitorAlert represents a monitor alert.

type MonitorRepo

type MonitorRepo struct {
	BaseRepo
}

MonitorRepo implements Repository[*MonitorAlert].

func NewMonitorRepo

func NewMonitorRepo(ctx context.Context, log *logrus.Logger, cfg *S3Config, metrics *Metrics) (*MonitorRepo, error)

NewMonitorRepo creates a new MonitorRepo.

func (*MonitorRepo) Key

func (s *MonitorRepo) Key(alert *MonitorAlert) string

Key implements Repository[*MonitorAlert].

func (*MonitorRepo) List

func (s *MonitorRepo) List(ctx context.Context) ([]*MonitorAlert, error)

List implements Repository[*MonitorAlert].

func (*MonitorRepo) Persist

func (s *MonitorRepo) Persist(ctx context.Context, alert *MonitorAlert) error

Persist implements Repository[*MonitorAlert].

func (*MonitorRepo) Purge

func (s *MonitorRepo) Purge(ctx context.Context, identifiers ...string) error

Purge implements Repository[*MonitorAlert].

type Repository

type Repository[T any] interface {
	// List returns all items of type T.
	List(ctx context.Context) ([]T, error)
	// Persist stores an item of type T.
	Persist(ctx context.Context, item T) error
	// Purge removes an item based on its identifiers.
	Purge(ctx context.Context, identifiers ...string) error
	// Key returns the key for an item based on its identifiers.
	Key(item T) string
}

Repository defines a generic interface for S3-backed storage.

type S3Config

type S3Config struct {
	AccessKeyID     string
	SecretAccessKey string
	Bucket          string
	Prefix          string
	EndpointURL     string // Optional. If empty, uses default SDK endpoints.
	Region          string // Optional. Defaults to us-east-1.
}

S3Config contains the configuration for the S3 client.

Jump to

Keyboard shortcuts

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