Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整理文档 #23

Closed
withlin opened this issue Jan 30, 2019 · 3 comments
Closed

整理文档 #23

withlin opened this issue Jan 30, 2019 · 3 comments
Labels

Comments

@withlin
Copy link
Owner

withlin commented Jan 30, 2019

as title

@withlin withlin changed the title 文档整理 整理文档 Jan 30, 2019
@crazelee
Copy link

将message.entries打印出来是这样的模样,这是什么问题呢,不能可视化的看到操作语句
[]com_alibaba_otter_canal_protocol.Entry{com_alibaba_otter_canal_protocol.Entry{Header:(*com_alibaba_otter_canal_protocol.Header)(0xc00010a000), EntryTypePresent:(*com_alibaba_otter_canal_protocol.Entry_EntryType)(0xc0000f8044), StoreValue:[]uint8{0x20, 0xb}, XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0}, com_alibaba_otter_canal_protocol.Entry{Header:(*com_alibaba_otter_canal_protocol.Header)(0xc00010a0e0), EntryTypePresent:(*com_alibaba_otter_canal_protocol.Entry_EntryType)(0xc0000f8070), StoreValue:[]uint8{0x12, 0x4, 0x31, 0x38, 0x38, 0x30}, XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0}}

@withlin
Copy link
Owner Author

withlin commented Jan 30, 2019

麻烦看一下 samples
里面有说,因为entries 还需要进一步解析

func printEntry(entrys []protocol.Entry) {

	for _, entry := range entrys {
		if entry.GetEntryType() == protocol.EntryType_TRANSACTIONBEGIN || entry.GetEntryType() == protocol.EntryType_TRANSACTIONEND {
			continue
		}
		rowChange := new(protocol.RowChange)

		err := proto.Unmarshal(entry.GetStoreValue(), rowChange)
		checkError(err)
		if rowChange != nil {
			eventType := rowChange.GetEventType()
			header := entry.GetHeader()
			fmt.Println(fmt.Sprintf("================> binlog[%s : %d],name[%s,%s], eventType: %s", header.GetLogfileName(), header.GetLogfileOffset(), header.GetSchemaName(), header.GetTableName(), header.GetEventType()))

			for _, rowData := range rowChange.GetRowDatas() {
				if eventType == protocol.EventType_DELETE {
					printColumn(rowData.GetBeforeColumns())
				} else if eventType == protocol.EventType_INSERT {
					printColumn(rowData.GetAfterColumns())
				} else {
					fmt.Println("-------> before")
					printColumn(rowData.GetBeforeColumns())
					fmt.Println("-------> after")
					printColumn(rowData.GetAfterColumns())
				}
			}
		}
	}
}

func printColumn(columns []*protocol.Column) {
	for _, col := range columns {
		fmt.Println(fmt.Sprintf("%s : %s  update= %t", col.GetName(), col.GetValue(), col.GetUpdated()))
	}
}

@crazelee
Copy link

image
每次都是只有解析到begin/end

withlin added a commit that referenced this issue Feb 18, 2019
@withlin withlin closed this as completed Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants