Files
gitea-notification-hub/internal/storage/repository.go
T

36 lines
920 B
Go

package storage
import "context"
// Repository defines the interface for user storage operations
// This abstraction allows swapping SQLite for PostgreSQL or other databases
type Repository interface {
// User operations
GetUserByEmail(ctx context.Context, email string) (*User, error)
GetUserByGiteaUsername(ctx context.Context, username string) (*User, error)
GetUserBySlackID(ctx context.Context, slackID string) (*User, error)
UpsertUser(ctx context.Context, user *User) error
ListUsers(ctx context.Context) ([]*User, error)
// Migrations
Migrate(ctx context.Context) error
// Close the connection
Close() error
}
// ErrNotFound is returned when a user is not found
type ErrNotFound struct {
Message string
}
func (e *ErrNotFound) Error() string {
return e.Message
}
// IsNotFound checks if an error is a not found error
func IsNotFound(err error) bool {
_, ok := err.(*ErrNotFound)
return ok
}