Skip to content

Commit d1df5f1

Browse files
Merge pull request julien-duponchelle#88 from lxyu/remove_default_server_id
remove default server_id as discussed in julien-duponchelle#80
2 parents d01e4b0 + 5744a18 commit d1df5f1

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

pymysqlreplication/binlogstream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class BinLogStreamReader(object):
2626
"""Connect to replication stream and read event
2727
"""
2828

29-
def __init__(self, connection_settings={}, resume_stream=False,
30-
blocking=False, only_events=None, server_id=255,
31-
log_file=None, log_pos=None, filter_non_implemented_events=True,
29+
def __init__(self, connection_settings, server_id, resume_stream=False,
30+
blocking=False, only_events=None, log_file=None, log_pos=None,
31+
filter_non_implemented_events=True,
3232
ignored_events=None, auto_position=None):
3333
"""
3434
Attributes:

pymysqlreplication/tests/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
else:
1515
base = unittest.TestCase
1616

17+
1718
class PyMySQLReplicationTestCase(base):
1819
def ignoredEvents(self):
1920
return []
@@ -74,5 +75,5 @@ def resetBinLog(self):
7475
self.execute("RESET MASTER")
7576
if self.stream is not None:
7677
self.stream.close()
77-
self.stream = BinLogStreamReader(connection_settings=self.database,
78+
self.stream = BinLogStreamReader(self.database, server_id=1024,
7879
ignored_events=self.ignoredEvents())

pymysqlreplication/tests/test_basic.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def test_reading_rotate_event(self):
6060

6161
def test_connection_stream_lost_event(self):
6262
self.stream.close()
63-
self.stream = BinLogStreamReader(connection_settings=self.database,
64-
blocking=True,
65-
ignored_events=self.ignoredEvents())
63+
self.stream = BinLogStreamReader(
64+
self.database, server_id=1024, blocking=True,
65+
ignored_events=self.ignoredEvents())
6666

6767
query = "CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))"
6868
self.execute(query)
@@ -86,8 +86,8 @@ def test_connection_stream_lost_event(self):
8686

8787
def test_filtering_events(self):
8888
self.stream.close()
89-
self.stream = BinLogStreamReader(connection_settings=self.database,
90-
only_events=[QueryEvent])
89+
self.stream = BinLogStreamReader(
90+
self.database, server_id=1024, only_events=[QueryEvent])
9191
query = "CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))"
9292
self.execute(query)
9393

@@ -203,7 +203,8 @@ def test_log_pos(self):
203203
if self.stream is not None:
204204
self.stream.close()
205205
self.stream = BinLogStreamReader(
206-
connection_settings=self.database,
206+
self.database,
207+
server_id=1024,
207208
resume_stream=True,
208209
log_file=log_file,
209210
log_pos=log_pos,
@@ -223,7 +224,8 @@ def test_log_pos(self):
223224
def test_log_pos_handles_disconnects(self):
224225
self.stream.close()
225226
self.stream = BinLogStreamReader(
226-
connection_settings=self.database,
227+
self.database,
228+
server_id=1024,
227229
resume_stream=False,
228230
only_events = [FormatDescriptionEvent, QueryEvent, TableMapEvent, WriteRowsEvent, XidEvent]
229231
)
@@ -363,9 +365,8 @@ def test_read_query_event(self):
363365
gtid = self.execute(query).fetchone()[0]
364366

365367
self.stream.close()
366-
self.stream = BinLogStreamReader(connection_settings=self.database,
367-
blocking=True,
368-
auto_position=gtid)
368+
self.stream = BinLogStreamReader(
369+
self.database, server_id=1024, blocking=True, auto_position=gtid)
369370

370371
self.assertIsInstance(self.stream.fetchone(), RotateEvent)
371372
self.assertIsInstance(self.stream.fetchone(), FormatDescriptionEvent)
@@ -420,9 +421,8 @@ def test_position_gtid(self):
420421
gtid = self.execute(query).fetchone()[0]
421422

422423
self.stream.close()
423-
self.stream = BinLogStreamReader(connection_settings=self.database,
424-
blocking=True,
425-
auto_position=gtid)
424+
self.stream = BinLogStreamReader(
425+
self.database, server_id=1024, blocking=True, auto_position=gtid)
426426

427427
self.assertIsInstance(self.stream.fetchone(), RotateEvent)
428428
self.assertIsInstance(self.stream.fetchone(), FormatDescriptionEvent)

0 commit comments

Comments
 (0)