nodeevents

package
v1.78.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: AGPL-3.0 Imports: 13 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 */
	Notifier            string        `help:"which notification provider to use" default:""`

	Customerio CustomerioConfig
}

Config contains configurable values for node events chore.

type CustomerioBatch added in v1.69.1

type CustomerioBatch struct {
	Name string         `json:"name"`
	Data CustomerioData `json:"data"`
}

CustomerioBatch contains info regarding a batch of node events for a particular node operator email address.

type CustomerioConfig added in v1.69.1

type CustomerioConfig struct {
	URL            string        `help:"the url for the customer.io endpoint to send node event data to" default:"https://track.customer.io/api/v1"`
	SiteID         string        `help:"the account id for the customer.io api" default:""`
	APIKey         string        `help:"api key for the customer.io api" default:""`
	RequestTimeout time.Duration `help:"timeout for the http request to customer.io endpoint" default:"30s"`
}

CustomerioConfig handles customer.io credentials info.

type CustomerioData added in v1.69.1

type CustomerioData struct {
	Satellite string `json:"satellite"`
	NodeIDs   string `json:"nodeIDs"`
}

CustomerioData contains the satellite name and the node IDs that had an occurrence of the event.

type CustomerioNotifier added in v1.69.1

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

CustomerioNotifier notifies customer.io about node events.

func NewCustomerioNotifier added in v1.69.1

func NewCustomerioNotifier(log *zap.Logger, config CustomerioConfig) *CustomerioNotifier

NewCustomerioNotifier is a constructor for CustomerioNotifier.

func (*CustomerioNotifier) Notify added in v1.69.1

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

Notify sends node event data to customer.io.

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)
	// GetByID get a node event by id.
	GetByID(ctx context.Context, id uuid.UUID) (nodeEvent NodeEvent, err error)
	// UpdateEmailSent updates email_sent for a group of rows.
	UpdateEmailSent(ctx context.Context, ids []uuid.UUID, timestamp time.Time) (err error)
	// UpdateLastAttempted updates last_attempted for a group of rows.
	UpdateLastAttempted(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
	LastAttempted *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 = 0
	// Offline indicates that the node is offline.
	Offline Type = 1
	// Disqualified indicates that the node is disqualified.
	Disqualified Type = 2
	// UnknownAuditSuspended indicates that the node is suspended for unknown audit errors.
	UnknownAuditSuspended Type = 3
	// UnknownAuditUnsuspended indicates that the node is no longer suspended for unknown audit errors.
	UnknownAuditUnsuspended Type = 4
	// OfflineSuspended indicates that the node is suspended for being offline.
	OfflineSuspended Type = 5
	// OfflineUnsuspended indicates that the node is no longer suspended for being offline.
	OfflineUnsuspended Type = 6
	// BelowMinVersion indicates that the node's software is below the minimum version.
	BelowMinVersion Type = 7
)

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