Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Jan 6, 2021
1 parent 828572e commit 2530587
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
16 changes: 8 additions & 8 deletions pkg/streamer/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ const (
FileCmpBigger
)

// SwitchPath represents next binlog file path which should be switched
type SwitchPath struct {
nextUUID string
nextBinlogName string
}

// CollectAllBinlogFiles collects all valid binlog files in dir
func CollectAllBinlogFiles(dir string) ([]string, error) {
if dir == "" {
Expand Down Expand Up @@ -311,10 +317,7 @@ func relaySubDirUpdated(ctx context.Context, watcherInterval time.Duration, dir
}

// needSwitchSubDir checks whether the reader need to switch to next relay sub directory
func needSwitchSubDir(ctx context.Context, relayDir, currentUUID, latestFilePath string, latestFileSize int64, switchCh chan struct {
nextUUID string
nextBinlogName string
}, errCh chan error) {
func needSwitchSubDir(ctx context.Context, relayDir, currentUUID, latestFilePath string, latestFileSize int64, switchCh chan SwitchPath, errCh chan error) {
var (
err error
nextUUID string
Expand Down Expand Up @@ -359,10 +362,7 @@ func needSwitchSubDir(ctx context.Context, relayDir, currentUUID, latestFilePath
return
}

switchCh <- struct {
nextUUID string
nextBinlogName string
}{nextUUID, nextBinlogName}
switchCh <- SwitchPath{nextUUID, nextBinlogName}
return
}
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/streamer/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,8 @@ func (t *testFileSuite) TestNeedSwitchSubDir(c *C) {
latestFilePath string
latestFileSize int64
data = []byte("binlog file data")
switchCh = make(chan struct {
nextUUID string
nextBinlogName string
}, 1)
errCh = make(chan error, 1)
switchCh = make(chan SwitchPath, 1)
errCh = make(chan error, 1)
)

ctx := context.Background()
Expand Down
5 changes: 1 addition & 4 deletions pkg/streamer/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,7 @@ func (r *BinlogReader) parseFile(
return false, false, latestPos, "", "", nil
}

switchCh := make(chan struct {
nextUUID string
nextBinlogName string
}, 1)
switchCh := make(chan SwitchPath, 1)
switchErrCh := make(chan error, 1)
updatePathCh := make(chan string, 1)
updateErrCh := make(chan error, 1)
Expand Down

0 comments on commit 2530587

Please sign in to comment.