2
0

Add flush and close messages to pgproto3

This commit is contained in:
Jack Christensen
2017-05-19 17:31:22 -05:00
parent e45a42c7ef
commit b1934ad4c2
3 changed files with 95 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package pgproto3
import (
"encoding/json"
)
type Flush struct{}
func (*Flush) Frontend() {}
func (dst *Flush) Decode(src []byte) error {
if len(src) != 0 {
return &invalidMessageLenErr{messageType: "Flush", expectedLen: 0, actualLen: len(src)}
}
return nil
}
func (src *Flush) MarshalBinary() ([]byte, error) {
return []byte{'H', 0, 0, 0, 4}, nil
}
func (src *Flush) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Type string
}{
Type: "Flush",
})
}