alias

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAliasAlreadyExists = errors.New("alias already exists")
View Source
var ErrAliasNotFound = errors.New("alias not found")

Functions

This section is empty.

Types

type Alias

type Alias struct {
	ID        int    `json:"id"`
	ContentID int    `json:"contentId"`
	Alias     string `json:"alias"`
}

type Repository

type Repository interface {
	Create(ctx context.Context, a *Alias) error
	DeleteByContentID(ctx context.Context, contentID int) error
	FindByAlias(ctx context.Context, alias string) (*Alias, error)
	FindByContentID(ctx context.Context, contentID int) ([]*Alias, error)
	FindAll(ctx context.Context) ([]*Alias, error)
	// Repoint re-points an alias from one content id to another. The WHERE
	// clause is guarded on the current content id so a concurrent change
	// cannot be silently overwritten; ErrAliasNotFound is returned when the
	// alias is absent or already points elsewhere.
	Repoint(ctx context.Context, aliasStr string, fromContentID, toContentID int) error
}

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, contentID int, aliasStr string) error

func (*Service) DeleteByContentID

func (s *Service) DeleteByContentID(ctx context.Context, contentID int) error

func (*Service) FindAll

func (s *Service) FindAll(ctx context.Context) ([]*Alias, error)

func (*Service) FindByAlias

func (s *Service) FindByAlias(ctx context.Context, aliasStr string) (*Alias, error)

func (*Service) FindByContentID

func (s *Service) FindByContentID(ctx context.Context, contentID int) ([]*Alias, error)

func (*Service) Repoint added in v0.10.0

func (s *Service) Repoint(ctx context.Context, aliasStr string, fromContentID, toContentID int) error

Repoint re-points an existing alias to a new content id, but only when it still points at the expected fromContentID (concurrent changes fail with ErrAliasNotFound instead of being overwritten). Used by importers to adopt an alias whose previous target no longer exists.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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