Documentation
¶
Overview ¶
Package domain defines the review domain's ports, DTOs, and errors — the interactive "Start review" flow's contracts. It imports only the standard library and the shared kernel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrActiveReviewExists = errors.New("review: active review already exists")
ErrActiveReviewExists marks a user who already has an in-progress review on the PR — a duplicate "Start review" click, which the use case treats as a no-op. The infrastructure layer maps the store's unique-violation sentinel to this.
Functions ¶
This section is empty.
Types ¶
type HandlerParams ¶
type HandlerParams struct {
Recorder Recorder
Messages MessageChecker
Decorator MessageDecorator
Logger *slog.Logger
Now func() time.Time
}
HandlerParams bundles the start-review use case's dependencies. Now supplies the clock (time.Now in production, a fixed clock in tests).
type MessageChecker ¶
type MessageChecker interface {
HasMessages(ctx context.Context, repository string, prNumber int) (bool, error)
}
MessageChecker confirms notifycat owns a message for the PR before acting on a click.
type MessageDecorator ¶
type MessageDecorator interface {
AppendReviewingMarker(ctx context.Context, message MessageRef, reviewer Reviewer, since time.Time) error
}
MessageDecorator edits the PR message in place, appending an in-review marker for the reviewer while passing the original blocks through untouched.
type MessageRef ¶
type MessageRef struct {
Channel string
TS string
RawBlocks json.RawMessage
Fallback string
}
MessageRef addresses the interactive PR message and carries its original block array (echoed back by Slack) so the decorator can append a marker without re-composing the whole message. RawBlocks is opaque JSON passed through untouched; Fallback is the message's top-level plain-text.
type Recorder ¶
type Recorder interface {
// HasActiveReview reports whether the user already has an in-progress review
// on the PR (a repeat click is a no-op).
HasActiveReview(ctx context.Context, repository string, prNumber int, userID string) (bool, error)
// Start records the user as a reviewer. It returns ErrActiveReviewExists when
// a concurrent click already recorded them.
Start(ctx context.Context, repository string, prNumber int, userID, userName string) error
}
Recorder records and inspects per-PR review sessions.
type Reviewer ¶
Reviewer is the Slack user who clicked "Start review". UserID is the stable "U…" identifier; UserName is a display convenience and may be absent.
type StartReview ¶
type StartReview interface {
Handle(ctx context.Context, command StartReviewCommand) error
}
StartReview records a reviewer and decorates the PR message on a verified "Start review" click. A duplicate click (same user) is a no-op.
type StartReviewCommand ¶
type StartReviewCommand struct {
Repository string
PRNumber int
Reviewer Reviewer
Message MessageRef
}
StartReviewCommand is the parsed intent of a verified "Start review" button click: who clicked, on which PR, and the message to decorate.