github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/pkg/sink/codec/decoder.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 codec
    15  
    16  import "github.com/pingcap/tiflow/cdc/model"
    17  
    18  // RowEventDecoder is an abstraction for events decoder
    19  // this interface is only for testing now
    20  type RowEventDecoder interface {
    21  	// AddKeyValue add the received key and values to the decoder,
    22  	// should be called before `HasNext`
    23  	// decoder decode the key and value into the event format.
    24  	AddKeyValue(key, value []byte) error
    25  
    26  	// HasNext returns
    27  	//     1. the type of the next event
    28  	//     2. a bool if the next event is exist
    29  	//     3. error
    30  	HasNext() (model.MessageType, bool, error)
    31  	// NextResolvedEvent returns the next resolved event if exists
    32  	NextResolvedEvent() (uint64, error)
    33  	// NextRowChangedEvent returns the next row changed event if exists
    34  	NextRowChangedEvent() (*model.RowChangedEvent, error)
    35  	// NextDDLEvent returns the next DDL event if exists
    36  	NextDDLEvent() (*model.DDLEvent, error)
    37  }