11package landprovider
22
3+ //go:generate mockgen -source=land_provider.go -destination=mock/land_provider_mock.go -package=mock
4+
35import (
46 "context"
7+ "errors"
8+ "fmt"
59
610 "github.com/uber/submitqueue/entity"
711)
812
13+ // ErrLandRejected is returned by LandProvider implementations when the land operation
14+ // was attempted but rejected due to the changes themselves (e.g., merge conflict, policy
15+ // violation). This is a terminal failure — retrying will not help.
16+ // Infrastructure errors (network timeout, API unavailable) should be returned as plain
17+ // errors so the consumer can retry.
18+ var ErrLandRejected = errors .New ("land rejected" )
19+
20+ // IsLandRejected returns true if any error in the error chain is an ErrLandRejected.
21+ func IsLandRejected (err error ) bool {
22+ return errors .Is (err , ErrLandRejected )
23+ }
24+
25+ // WrapLandRejected wraps ErrLandRejected with a descriptive reason from the land provider.
26+ func WrapLandRejected (err error ) error {
27+ return fmt .Errorf ("%w: %w" , ErrLandRejected , err )
28+ }
29+
930// LandEntry pairs a land strategy with the change to land.
1031// Each entry represents one request's contribution to a batch land operation.
1132type LandEntry struct {
@@ -22,6 +43,7 @@ type LandProvider interface {
2243 // Land merges the provided changes into the target branch of the given queue.
2344 // The queue identifies the repository and target branch.
2445 // Each entry contains a change and the strategy to use for landing it.
46+ // Returns ErrLandRejected if the land was rejected due to the changes themselves.
2547 Land (ctx context.Context , queue string , entries []LandEntry ) (Result , error )
2648}
2749
0 commit comments