@@ -223,7 +223,13 @@ var resumeCmd = &cobra.Command{
223223 return err
224224 }
225225
226- return NewClient (port ).Resume (cmd .Context ())
226+ fromFailure , _ := cmd .Flags ().GetBool ("from-failure" )
227+
228+ resumeOptions := resumeRequest {
229+ FromFailure : fromFailure ,
230+ }
231+
232+ return NewClient (port ).Resume (cmd .Context (), resumeOptions )
227233 },
228234}
229235
@@ -369,7 +375,9 @@ func main() {
369375 startCmd .Flags ().MarkHidden ("pause-on-initial-sync" ) //nolint:errcheck
370376
371377 pauseCmd .Flags ().Int ("port" , DefaultServerPort , "Port number" )
378+
372379 resumeCmd .Flags ().Int ("port" , DefaultServerPort , "Port number" )
380+ resumeCmd .Flags ().Bool ("from-failure" , false , "Reuse from failure" )
373381
374382 finalizeCmd .Flags ().Int ("port" , DefaultServerPort , "Port number" )
375383 finalizeCmd .Flags ().Bool ("ignore-history-lost" , false , "Ignore history lost error" )
@@ -876,7 +884,33 @@ func (s *server) handleResume(w http.ResponseWriter, r *http.Request) {
876884 return
877885 }
878886
879- err := s .mlink .Resume (ctx )
887+ var params resumeRequest
888+
889+ if r .ContentLength != 0 {
890+ data , err := io .ReadAll (r .Body )
891+ if err != nil {
892+ http .Error (w ,
893+ http .StatusText (http .StatusInternalServerError ),
894+ http .StatusInternalServerError )
895+
896+ return
897+ }
898+
899+ err = json .Unmarshal (data , & params )
900+ if err != nil {
901+ http .Error (w ,
902+ http .StatusText (http .StatusBadRequest ),
903+ http .StatusBadRequest )
904+
905+ return
906+ }
907+ }
908+
909+ options := & mongolink.ResumeOptions {
910+ ResumeFromFailure : params .FromFailure ,
911+ }
912+
913+ err := s .mlink .Resume (ctx , * options )
880914 if err != nil {
881915 writeResponse (w , resumeResponse {Err : err .Error ()})
882916
@@ -984,6 +1018,12 @@ type pauseResponse struct {
9841018 Err string `json:"error,omitempty"`
9851019}
9861020
1021+ // resumeRequest represents the request body for the /resume endpoint.
1022+ type resumeRequest struct {
1023+ // FromFailure indicates whether to resume from a failed state.
1024+ FromFailure bool `json:"fromFailure,omitempty"`
1025+ }
1026+
9871027// resumeResponse represents the response body for the /resume
9881028// endpoint.
9891029type resumeResponse struct {
@@ -1022,8 +1062,8 @@ func (c MongoLinkClient) Pause(ctx context.Context) error {
10221062}
10231063
10241064// Resume sends a request to resume the cluster replication.
1025- func (c MongoLinkClient ) Resume (ctx context.Context ) error {
1026- return doClientRequest [resumeResponse ](ctx , c .port , http .MethodPost , "resume" , nil )
1065+ func (c MongoLinkClient ) Resume (ctx context.Context , req resumeRequest ) error {
1066+ return doClientRequest [resumeResponse ](ctx , c .port , http .MethodPost , "resume" , req )
10271067}
10281068
10291069func doClientRequest [T any ](ctx context.Context , port int , method , path string , body any ) error {
0 commit comments