Skip to content

Commit 9b88753

Browse files
committed
Add sample annotations
1 parent b81ee9b commit 9b88753

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sample/CanalSharp.SimpleClient/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static void Main(string[] args)
3434
}
3535
}
3636

37+
/// <summary>
38+
/// 输出数据
39+
/// </summary>
40+
/// <param name="entrys">一个entry表示一个数据库变更</param>
3741
private static void PrintEntry(List<Entry> entrys)
3842
{
3943
foreach (var entry in entrys)
@@ -47,6 +51,7 @@ private static void PrintEntry(List<Entry> entrys)
4751

4852
try
4953
{
54+
//获取行变更
5055
rowChange = RowChange.Parser.ParseFrom(entry.StoreValue);
5156
}
5257
catch (Exception e)
@@ -56,10 +61,13 @@ private static void PrintEntry(List<Entry> entrys)
5661

5762
if (rowChange != null)
5863
{
64+
//变更类型 insert/update/delete 等等
5965
EventType eventType = rowChange.EventType;
66+
//输出binlog信息 表名 数据库名 变更类型
6067
Console.WriteLine(
6168
$"================> binlog[{entry.Header.LogfileName}:{entry.Header.LogfileOffset}] , name[{entry.Header.SchemaName},{entry.Header.TableName}] , eventType :{eventType}");
6269

70+
//输出 insert/update/delete 变更类型列数据
6371
foreach (var rowData in rowChange.RowDatas)
6472
{
6573
if (eventType == EventType.Delete)
@@ -83,10 +91,15 @@ private static void PrintEntry(List<Entry> entrys)
8391
}
8492
}
8593

94+
/// <summary>
95+
/// 输出每个列的详细数据
96+
/// </summary>
97+
/// <param name="columns"></param>
8698
private static void PrintColumn(List<Column> columns)
8799
{
88100
foreach (var column in columns)
89101
{
102+
//输出列明 列值 是否变更
90103
Console.WriteLine($"{column.Name}{column.Value} update= {column.Updated}");
91104
}
92105
}

0 commit comments

Comments
 (0)