2
0

msgReader implemented in terms of ChunkReader

This should substantially reduce memory allocations and memory copies.

It also means that PostgreSQL messages are always entirely buffered in memory
before processing begins. This simplifies the message processing code.

In particular, Conn.WaitForNotification is dramatically simplified by this
change.
This commit is contained in:
Jack Christensen
2017-02-13 20:41:58 -06:00
parent 84802ece05
commit 11b82b3ca4
7 changed files with 130 additions and 467 deletions
+5 -5
View File
@@ -1,6 +1,7 @@
package pgx_test
import (
"context"
"fmt"
"github.com/jackc/pgx"
"reflect"
@@ -88,11 +89,10 @@ func TestSimpleReplicationConnection(t *testing.T) {
for {
var message *pgx.ReplicationMessage
message, err = replicationConn.WaitForReplicationMessage(time.Duration(1 * time.Second))
if err != nil {
if err != pgx.ErrNotificationTimeout {
t.Fatalf("Replication failed: %v %s", err, reflect.TypeOf(err))
}
ctx, _ := context.WithTimeout(context.Background(), time.Second)
message, err = replicationConn.WaitForReplicationMessage(ctx)
if err != nil && err != context.DeadlineExceeded {
t.Fatalf("Replication failed: %v %s", err, reflect.TypeOf(err))
}
if message != nil {
if message.WalMessage != nil {