jackc / pglogrepl

PostgreSQL logical replication library for Go.
MIT License
338 stars 63 forks source link

pglogrepl_demo: how to handle with wal2json plugin output #21

Open dungnh-bpp opened 3 years ago

dungnh-bpp commented 3 years ago

So my questions is: I wanna use wal2json instead of pgoutput or test_decoding output plugin, how to determine clientXLogPos when application consume message succeess. In your pglogrepl_demo example: you 're using clientXLogPos = xld.WALStart + pglogrepl.LSN(len(xld.WALData)) with pgoutput plugin to determixe client xlogpos, right? If I use wal2json, how to determine that? Can you help me for this Thanks

ubombi commented 2 years ago

Using PrimaryKeepaliveMessage.

viggy28 commented 1 year ago

Sorry for digging into an old issue. I cannot even run it with wal2json as the output plugin in the demo example.

It panics since the pglogrepl.Message is Unknown

panic: interface conversion: interface is nil, not pglogrepl.Message 

goroutine 1 [running]:
github.com/jackc/pglogrepl.Parse({0xc0000f401e, 0xa8, 0xa8})
        /Users/visi/go/pkg/mod/github.com/jackc/pglogrepl@v0.0.0-20230318140337-5ef673a9d169/message.go:649 +0x2b9
main.main()
        /Users/visi/Sourcecontrol/github.com/viggy28/pgsavior/main.go:136 +0xdda