Documentation
¶
Index ¶
- Variables
- type Alias
- type Repository
- type Service
- func (s *Service) Create(ctx context.Context, contentID int, aliasStr string) error
- func (s *Service) DeleteByContentID(ctx context.Context, contentID int) error
- func (s *Service) FindAll(ctx context.Context) ([]*Alias, error)
- func (s *Service) FindByAlias(ctx context.Context, aliasStr string) (*Alias, error)
- func (s *Service) FindByContentID(ctx context.Context, contentID int) ([]*Alias, error)
- func (s *Service) Repoint(ctx context.Context, aliasStr string, fromContentID, toContentID int) error
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 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) DeleteByContentID ¶
func (*Service) FindByAlias ¶
func (*Service) FindByContentID ¶
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.
Click to show internal directories.
Click to hide internal directories.