github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/cdc/scheduler/internal/table_executor.go (about) 1 // Copyright 2022 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package internal 15 16 import ( 17 "context" 18 19 "github.com/pingcap/tiflow/cdc/model" 20 "github.com/pingcap/tiflow/cdc/processor/tablepb" 21 ) 22 23 // TableExecutor is an abstraction for "Processor". 24 // 25 // This interface is so designed that it would be the least problematic 26 // to adapt the current Processor implementation to it. 27 // TODO find a way to make the semantics easier to understand. 28 type TableExecutor interface { 29 // AddTableSpan add a new table span with `Checkpoint.CheckpointTs` 30 // if `isPrepare` is true, the 1st phase of the 2 phase scheduling protocol. 31 // if `isPrepare` is false, the 2nd phase. 32 AddTableSpan( 33 ctx context.Context, span tablepb.Span, checkpoint tablepb.Checkpoint, isPrepare bool, 34 ) (done bool, err error) 35 36 // IsAddTableSpanFinished make sure the requested table span is in the proper status 37 IsAddTableSpanFinished(span tablepb.Span, isPrepare bool) (done bool) 38 39 // RemoveTableSpan remove the table, return true if the table is already removed 40 RemoveTableSpan(span tablepb.Span) (done bool) 41 // IsRemoveTableSpanFinished convince the table is fully stopped. 42 // return false if table is not stopped 43 // return true and corresponding checkpoint otherwise. 44 IsRemoveTableSpanFinished(span tablepb.Span) (model.Ts, bool) 45 46 // GetTableSpanStatus return the checkpoint and resolved ts for the given table span. 47 GetTableSpanStatus(span tablepb.Span, collectStat bool) tablepb.TableStatus 48 }