storj/satellite/nodeevents/db.go
Cameron 6e77e094ce satellite/nodeevents: add NodeEvents methods GetNextBatch, UpdateEmailSent
Change-Id: I0df3dd8f97d99da434fa7ef8049f13ae9a521af9
2022-11-11 22:55:41 +00:00

37 lines
1.2 KiB
Go

// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package nodeevents
import (
"context"
"time"
"storj.io/common/storj"
"storj.io/common/uuid"
)
// DB implements the database for node events.
//
// architecture: Database
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)
}
// NodeEvent contains information needed to notify a node operator about something that happened to a node.
type NodeEvent struct {
ID uuid.UUID
Email string
NodeID storj.NodeID
Event Type
CreatedAt time.Time
EmailSent *time.Time
}