Skip to content

Commit ca576c9

Browse files
author
Dylan Terry
committed
Add some comments and remember to remove SetEventHandler and the eventHandler attribute
1 parent f04825e commit ca576c9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

replication/binlogsyncer.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import (
1111
"sync"
1212
"time"
1313

14-
"github.com/siddontang/go-log/loggers"
15-
1614
"github.com/google/uuid"
1715
"github.com/pingcap/errors"
1816
"github.com/siddontang/go-log/log"
17+
"github.com/siddontang/go-log/loggers"
1918

2019
"github.com/go-mysql-org/go-mysql/client"
2120
. "github.com/go-mysql-org/go-mysql/mysql"
@@ -58,7 +57,7 @@ type BinlogSyncerConfig struct {
5857
TLSConfig *tls.Config
5958

6059
// Use replication.Time structure for timestamp and datetime.
61-
// We will use Local location for timestamp and UTC location for datatime.
60+
// We will use Local location for timestamp and UTC location for datetime.
6261
ParseTime bool
6362

6463
// If ParseTime is false, convert TIMESTAMP into this specified timezone. If
@@ -137,7 +136,7 @@ type EventHandler interface {
137136
HandleEvent(e *BinlogEvent) error
138137
}
139138

140-
// BinlogSyncer syncs binlog event from server.
139+
// BinlogSyncer syncs binlog events from the server.
141140
type BinlogSyncer struct {
142141
m sync.RWMutex
143142

@@ -164,11 +163,9 @@ type BinlogSyncer struct {
164163
lastConnectionID uint32
165164

166165
retryCount int
167-
168-
eventHandler EventHandler
169166
}
170167

171-
// NewBinlogSyncer creates the BinlogSyncer with cfg.
168+
// NewBinlogSyncer creates the BinlogSyncer with the given configuration.
172169
func NewBinlogSyncer(cfg BinlogSyncerConfig) *BinlogSyncer {
173170
if cfg.Logger == nil {
174171
streamHandler, _ := log.NewStreamHandler(os.Stdout)
@@ -185,7 +182,7 @@ func NewBinlogSyncer(cfg BinlogSyncerConfig) *BinlogSyncer {
185182
cfg.EventCacheCount = 10240
186183
}
187184

188-
// Clear the Password to avoid outputing it in log.
185+
// Clear the Password to avoid outputting it in logs.
189186
pass := cfg.Password
190187
cfg.Password = ""
191188
cfg.Logger.Infof("create BinlogSyncer with config %+v", cfg)
@@ -393,12 +390,6 @@ func (b *BinlogSyncer) enableSemiSync() error {
393390
return nil
394391
}
395392

396-
func (b *BinlogSyncer) SetEventHandler(handler EventHandler) {
397-
b.m.Lock()
398-
defer b.m.Unlock()
399-
b.eventHandler = handler
400-
}
401-
402393
func (b *BinlogSyncer) prepare() error {
403394
if b.isClosed() {
404395
return errors.Trace(ErrSyncClosed)
@@ -834,6 +825,7 @@ func (b *BinlogSyncer) parseEvent(data []byte) (*BinlogEvent, bool, error) {
834825
return e, needACK, nil
835826
}
836827

828+
// handleEventAndACK processes an event and sends an ACK if necessary.
837829
func (b *BinlogSyncer) handleEventAndACK(s *BinlogStreamer, e *BinlogEvent, needACK bool) error {
838830
// Update the next position based on the event's LogPos
839831
if e.Header.LogPos > 0 {

0 commit comments

Comments
 (0)