-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into cli-support-cdc-cluster-id
- Loading branch information
Showing
39 changed files
with
109 additions
and
82 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package codec | ||
|
||
import "github.com/pingcap/tiflow/cdc/model" | ||
|
||
// EventBatchDecoder is an abstraction for events decoder | ||
// this interface is only for testing now | ||
type EventBatchDecoder interface { | ||
// HasNext returns | ||
// 1. the type of the next event | ||
// 2. a bool if the next event is exist | ||
// 3. error | ||
HasNext() (model.MqMessageType, bool, error) | ||
// NextResolvedEvent returns the next resolved event if exists | ||
NextResolvedEvent() (uint64, error) | ||
// NextRowChangedEvent returns the next row changed event if exists | ||
NextRowChangedEvent() (*model.RowChangedEvent, error) | ||
// NextDDLEvent returns the next DDL event if exists | ||
NextDDLEvent() (*model.DDLEvent, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package codec | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pingcap/tiflow/cdc/model" | ||
"github.com/pingcap/tiflow/pkg/config" | ||
cerror "github.com/pingcap/tiflow/pkg/errors" | ||
) | ||
|
||
// EventBatchEncoder is an abstraction for events encoder | ||
type EventBatchEncoder interface { | ||
// EncodeCheckpointEvent appends a checkpoint event into the batch. | ||
// This event will be broadcast to all partitions to signal a global checkpoint. | ||
EncodeCheckpointEvent(ts uint64) (*MQMessage, error) | ||
// AppendRowChangedEvent appends the calling context, a row changed event and the dispatch | ||
// topic into the batch | ||
AppendRowChangedEvent(context.Context, string, *model.RowChangedEvent) error | ||
// EncodeDDLEvent appends a DDL event into the batch | ||
EncodeDDLEvent(e *model.DDLEvent) (*MQMessage, error) | ||
// Build builds the batch and returns the bytes of key and value. | ||
Build() []*MQMessage | ||
// Size returns the size of the batch(bytes) | ||
Size() int | ||
} | ||
|
||
// EncoderBuilder builds encoder with context. | ||
type EncoderBuilder interface { | ||
Build() EventBatchEncoder | ||
} | ||
|
||
// NewEventBatchEncoderBuilder returns an EncoderBuilder | ||
func NewEventBatchEncoderBuilder(ctx context.Context, c *Config) (EncoderBuilder, error) { | ||
switch c.protocol { | ||
case config.ProtocolDefault, config.ProtocolOpen: | ||
return newJSONEventBatchEncoderBuilder(c), nil | ||
case config.ProtocolCanal: | ||
return newCanalEventBatchEncoderBuilder(), nil | ||
case config.ProtocolAvro: | ||
return newAvroEventBatchEncoderBuilder(ctx, c) | ||
case config.ProtocolMaxwell: | ||
return newMaxwellEventBatchEncoderBuilder(), nil | ||
case config.ProtocolCanalJSON: | ||
return newCanalFlatEventBatchEncoderBuilder(c), nil | ||
case config.ProtocolCraft: | ||
return newCraftEventBatchEncoderBuilder(c), nil | ||
default: | ||
return nil, cerror.ErrMQSinkUnknownProtocol.GenWithStackByArgs(c.protocol) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cdc/sink/codec/interface_test.go → cdc/sink/mq/codec/message_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters