storj/satellite/nodeevents/db.go
Cameron 11e229cc7f satellite/nodeevents: implement node events DB
Implement node events DB with Insert and GetLatestByEmailAndEvent. Get
was changed to GetLatestByEmailAndEvent so we can verify items are being
inserted into the table without needing the ID, which is not available
to us in the tests.

Change-Id: I4abe63631c44774cd7e795fbab0cbab4d801db4c
2022-11-01 16:03:14 +00:00

33 lines
880 B
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)
}
// 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
}