nodeevents

package
v1.68.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error is the standard error class for node events.
	Error = errs.Class("node events")
)

Functions

This section is empty.

Types

type Chore added in v1.68.1

type Chore struct {
	Loop *sync2.Cycle
	// contains filtered or unexported fields
}

Chore is a chore that reads events from node events and sends emails.

func NewChore added in v1.68.1

func NewChore(log *zap.Logger, db DB, satellite string, notifier Notifier, config Config) *Chore

NewChore is a constructor for Chore.

func (*Chore) Close added in v1.68.1

func (chore *Chore) Close() error

Close closes the chore.

func (*Chore) Run added in v1.68.1

func (chore *Chore) Run(ctx context.Context) (err error)

Run runs the chore.

func (*Chore) SetNotifier added in v1.68.1

func (chore *Chore) SetNotifier(n Notifier)

SetNotifier sets the notifier on chore for testing.

func (*Chore) SetNow added in v1.68.1

func (chore *Chore) SetNow(f func() time.Time)

SetNow sets nowFn on chore for testing.

type Config added in v1.68.1

type Config struct {
	Interval            time.Duration `help:"how long to wait before checking the node events DB again if there is nothing to work on" default:"5m"`
	SelectionWaitPeriod time.Duration `` /* 130-byte string literal not displayed */
}

Config contains configurable values for node events chore.

type DB

type DB interface {
	// Insert a node event into the node events table.
	Insert(ctx context.Context, email string, nodeID storj.NodeID, event Type) (nodeEvent NodeEvent, err error)
	// GetLatestByEmailAndEvent gets latest node event by email and event type.
	GetLatestByEmailAndEvent(ctx context.Context, email string, event Type) (nodeEvent NodeEvent, err error)
	// GetNextBatch gets the next batch of events to combine into an email.
	GetNextBatch(ctx context.Context, firstSeenBefore time.Time) (events []NodeEvent, err error)
	// UpdateEmailSent updates email_sent for a group of rows.
	UpdateEmailSent(ctx context.Context, ids []uuid.UUID, timestamp time.Time) (err error)
}

DB implements the database for node events.

architecture: Database

type MockNotifier added in v1.68.1

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

MockNotifier implements the Notifier interface.

func NewMockNotifier added in v1.68.1

func NewMockNotifier(log *zap.Logger) *MockNotifier

NewMockNotifier is a constructor for MockNotifier.

func (*MockNotifier) Notify added in v1.68.1

func (m *MockNotifier) Notify(ctx context.Context, satellite string, events []NodeEvent) (err error)

Notify stores the events in the Notifications field so they can be checked.

type NodeEvent

type NodeEvent struct {
	ID        uuid.UUID
	Email     string
	NodeID    storj.NodeID
	Event     Type
	CreatedAt time.Time
	EmailSent *time.Time
}

NodeEvent contains information needed to notify a node operator about something that happened to a node.

type Notifier added in v1.68.1

type Notifier interface {
	// Notify notifies a node operator about an event that occurred on some of their nodes.
	Notify(ctx context.Context, satellite string, events []NodeEvent) (err error)
}

Notifier notifies node operators about node events.

type Type

type Type int

Type is a type of node event.

const (
	// Online indicates that the node has come back online.
	Online Type = iota
	// Offline indicates that the node is offline.
	Offline
	// Disqualified indicates that the node is disqualified.
	Disqualified
	// UnknownAuditSuspended indicates that the node is suspended for unknown audit errors.
	UnknownAuditSuspended
	// UnknownAuditUnsuspended indicates that the node is no longer suspended for unknown audit errors.
	UnknownAuditUnsuspended
	// OfflineSuspended indicates that the node is suspended for being offline.
	OfflineSuspended
	// OfflineUnsuspended indicates that the node is no longer suspended for being offline.
	OfflineUnsuspended
	// BelowMinVersion indicates that the node's software is below the minimum version.
	BelowMinVersion
)

func (Type) Name added in v1.68.1

func (t Type) Name() (name string, err error)

Name returns the name of the node event Type.

Jump to

Keyboard shortcuts

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