subscription

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("subscription not found")
	ErrUnauthorized  = errors.New("unauthorized to modify subscription")
	ErrAlreadyExists = errors.New("subscription already exists for this asset")
)
View Source
var ValidNotificationTypes = map[string]bool{
	"asset_change":             true,
	"schema_change":            true,
	"upstream_schema_change":   true,
	"downstream_schema_change": true,
	"lineage_change":           true,
}

Functions

func IsValidationError

func IsValidationError(err error) bool

IsValidationError reports whether err is a user-facing validation error.

Types

type PostgresRepository

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

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(ctx context.Context, sub *Subscription) error

func (*PostgresRepository) Delete

func (r *PostgresRepository) Delete(ctx context.Context, id string) error

func (*PostgresRepository) GetByAssetAndUser

func (r *PostgresRepository) GetByAssetAndUser(ctx context.Context, assetID, userID string) (*Subscription, error)

func (*PostgresRepository) GetByID

func (r *PostgresRepository) GetByID(ctx context.Context, id string) (*Subscription, error)

func (*PostgresRepository) GetSubscribersForAsset

func (r *PostgresRepository) GetSubscribersForAsset(ctx context.Context, assetID string, notificationType string) ([]string, error)

func (*PostgresRepository) ListByUser

func (r *PostgresRepository) ListByUser(ctx context.Context, userID string) ([]*SubscriptionWithAsset, error)

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(ctx context.Context, id string, types []string) (*Subscription, error)

type Repository

type Repository interface {
	Create(ctx context.Context, sub *Subscription) error
	Update(ctx context.Context, id string, types []string) (*Subscription, error)
	Delete(ctx context.Context, id string) error
	GetByID(ctx context.Context, id string) (*Subscription, error)
	GetByAssetAndUser(ctx context.Context, assetID, userID string) (*Subscription, error)
	ListByUser(ctx context.Context, userID string) ([]*SubscriptionWithAsset, error)
	GetSubscribersForAsset(ctx context.Context, assetID string, notificationType string) ([]string, error)
}

Repository defines the subscription data access interface.

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool) Repository

type Service

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

func NewService

func NewService(repo Repository) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, assetID, userID string, types []string) (*Subscription, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id, userID string) error

func (*Service) GetByAssetAndUser

func (s *Service) GetByAssetAndUser(ctx context.Context, assetID, userID string) (*Subscription, error)

func (*Service) GetSubscribersForAsset

func (s *Service) GetSubscribersForAsset(ctx context.Context, assetID string, notificationType string) ([]string, error)

func (*Service) ListByUser

func (s *Service) ListByUser(ctx context.Context, userID string) ([]*SubscriptionWithAsset, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, id, userID string, types []string) (*Subscription, error)

type Subscription

type Subscription struct {
	ID                string    `json:"id"`
	AssetID           string    `json:"asset_id"`
	UserID            string    `json:"user_id"`
	NotificationTypes []string  `json:"notification_types"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

Subscription represents a user's subscription to notifications for a specific asset.

type SubscriptionWithAsset

type SubscriptionWithAsset struct {
	Subscription
	AssetName string `json:"asset_name"`
	AssetMRN  string `json:"asset_mrn"`
	AssetType string `json:"asset_type"`
}

SubscriptionWithAsset extends Subscription with denormalized asset metadata.

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError represents a user-facing validation failure.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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