2
0

Add a lot of documentation

This commit is contained in:
Jack Christensen
2019-06-08 19:38:34 -05:00
parent bf3a27ae3f
commit 432c2951c7
41 changed files with 202 additions and 1 deletions
+4
View File
@@ -7,6 +7,7 @@ import (
"github.com/pkg/errors"
)
// Frontend acts as a client for the PostgreSQL wire protocol version 3.
type Frontend struct {
cr ChunkReader
w io.Writer
@@ -41,15 +42,18 @@ type Frontend struct {
partialMsg bool
}
// NewFrontend creates a new Frontend.
func NewFrontend(cr ChunkReader, w io.Writer) (*Frontend, error) {
return &Frontend{cr: cr, w: w}, nil
}
// Send sends a message to the backend.
func (b *Frontend) Send(msg FrontendMessage) error {
_, err := b.w.Write(msg.Encode(nil))
return err
}
// Receive receives a message from the backend.
func (b *Frontend) Receive() (BackendMessage, error) {
if !b.partialMsg {
header, err := b.cr.Next(5)