Send sends the given messages over the wire. If an error is returned, then the connection has been closed, and a new one should be opened.
(t *testing.T, messages ...pgproto3.FrontendMessage)
| 7559 | // Send sends the given messages over the wire. If an error is returned, then the connection has been closed, and a new |
| 7560 | // one should be opened. |
| 7561 | func (c *RawWireConnection) Send(t *testing.T, messages ...pgproto3.FrontendMessage) error { |
| 7562 | if len(messages) == 0 { |
| 7563 | return nil |
| 7564 | } |
| 7565 | hasMessage := false |
| 7566 | for _, message := range messages { |
| 7567 | if message == nil { |
| 7568 | continue |
| 7569 | } |
| 7570 | hasMessage = true |
| 7571 | if startupMessage, ok := message.(*pgproto3.StartupMessage); ok { |
| 7572 | c.startup = startupMessage |
| 7573 | } |
| 7574 | c.frontend.Send(message) |
| 7575 | } |
| 7576 | if !hasMessage { |
| 7577 | return nil |
| 7578 | } |
| 7579 | go func() { |
| 7580 | c.errChan <- c.frontend.Flush() |
| 7581 | }() |
| 7582 | return c.handleErrorChannel(t, true) |
| 7583 | } |
| 7584 | |
| 7585 | // init handles the startup message, authentication, and initial messages from the server. |
| 7586 | func (c *RawWireConnection) init(t *testing.T) { |
no test coverage detected