Skip to content

Commit

Permalink
Merge pull request #16 from CanalClient/dev
Browse files Browse the repository at this point in the history
Update README
  • Loading branch information
withlin authored Dec 21, 2018
2 parents 98765ed + c80acbf commit 3bb2622
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,24 @@ or you can install it from nuget manager(a graphic ui) in visual studio
````golang

connector := client.NewSimpleCanalConnector("192.168.199.17", 11111, "", "", "example", 60000, 60*60*1000)
connector.Connect()
connector.Subscribe(".*\\\\..*")
err :=connector.Connect()
if err != nil {
log.Println(err)
os.Exit(1)
}
err = connector.Subscribe(".*\\\\..*")
if err != nil {
log.Println(err)
os.Exit(1)
}

for {

message := connector.Get(100, nil, nil)
message,err := connector.Get(100, nil, nil)
if err != nil {
log.Println(err)
os.Exit(1)
}
batchId := message.Id
if batchId == -1 || len(message.Entries) <= 0 {
time.Sleep(300 * time.Millisecond)
Expand Down
19 changes: 15 additions & 4 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,24 @@ go get github.com/CanalSharp/canal-go
````golang

connector := client.NewSimpleCanalConnector("192.168.199.17", 11111, "", "", "example", 60000, 60*60*1000)
connector.Connect()
connector.Subscribe(".*\\\\..*")
err :=connector.Connect()
if err != nil {
log.Println(err)
os.Exit(1)
}
err = connector.Subscribe(".*\\\\..*")
if err != nil {
log.Println(err)
os.Exit(1)
}

for {

message := connector.Get(100, nil, nil)
message,err := connector.Get(100, nil, nil)
if err != nil {
log.Println(err)
os.Exit(1)
}
batchId := message.Id
if batchId == -1 || len(message.Entries) <= 0 {
time.Sleep(300 * time.Millisecond)
Expand All @@ -95,7 +107,6 @@ connector := client.NewSimpleCanalConnector("192.168.199.17", 11111, "", "", "ex
printEntry(message.Entries)

}

````

更多详情请查看 [Sample](https://github.com/CanalSharp/canal-go/tree/master/samples)
Expand Down

0 comments on commit 3bb2622

Please sign in to comment.