(ctx context.Context, network, address string)
| 475 | } |
| 476 | |
| 477 | func (d logDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) { |
| 478 | deadline, hasDeadline := ctx.Deadline() |
| 479 | timeoutMS := 0 |
| 480 | if hasDeadline { |
| 481 | timeoutMS = int(time.Until(deadline) / time.Millisecond) |
| 482 | } |
| 483 | |
| 484 | logger := d.logger.With(slog.F("network", network), slog.F("address", address), slog.F("timeout_ms", timeoutMS)) |
| 485 | |
| 486 | logger.Debug(ctx, "pubsub dialing postgres") |
| 487 | start := time.Now() |
| 488 | conn, err := d.d.DialContext(ctx, network, address) |
| 489 | if err != nil { |
| 490 | logger.Error(ctx, "pubsub failed to dial postgres") |
| 491 | return nil, err |
| 492 | } |
| 493 | elapsed := time.Since(start) |
| 494 | logger.Debug(ctx, "pubsub postgres TCP connection established", slog.F("elapsed_ms", elapsed.Milliseconds())) |
| 495 | return conn, nil |
| 496 | } |
| 497 | |
| 498 | func (p *PGPubsub) startListener(ctx context.Context, connectURL string) error { |
| 499 | p.connected.Set(0) |
no test coverage detected