MCPcopy
hub / github.com/jackc/pgx / Flush

Method Flush

pgproto3/backend.go:80–101  ·  view source on GitHub ↗

Flush writes any pending messages to the frontend (i.e. the client).

()

Source from the content-addressed store, hash-verified

78
79// Flush writes any pending messages to the frontend (i.e. the client).
80func (b *Backend) Flush() error {
81 if err := b.encodeError; err != nil {
82 b.encodeError = nil
83 b.wbuf = b.wbuf[:0]
84 return &writeError{err: err, safeToRetry: true}
85 }
86
87 n, err := b.w.Write(b.wbuf)
88
89 const maxLen = 1024
90 if len(b.wbuf) > maxLen {
91 b.wbuf = make([]byte, 0, maxLen)
92 } else {
93 b.wbuf = b.wbuf[:0]
94 }
95
96 if err != nil {
97 return &writeError{err: err, safeToRetry: n == 0}
98 }
99
100 return nil
101}
102
103// Trace starts tracing the message traffic to w. It writes in a similar format to that produced by the libpq function
104// PQtrace.

Calls 1

WriteMethod · 0.45