OptimizedCopyWithBufferSizeAndMetrics performs optimized copying with custom buffer size and metrics
(dst, src net.Conn, bufferSize int, recordBytes func(int64))
| 305 | |
| 306 | // OptimizedCopyWithBufferSizeAndMetrics performs optimized copying with custom buffer size and metrics |
| 307 | func OptimizedCopyWithBufferSizeAndMetrics(dst, src net.Conn, bufferSize int, recordBytes func(int64)) { |
| 308 | done := make(chan struct{}, 2) |
| 309 | |
| 310 | // Copy from src to dst |
| 311 | go func() { |
| 312 | defer func() { done <- struct{}{} }() |
| 313 | copyWithBufferAndMetrics(dst, src, bufferSize, recordBytes) |
| 314 | }() |
| 315 | |
| 316 | // Copy from dst to src |
| 317 | go func() { |
| 318 | defer func() { done <- struct{}{} }() |
| 319 | copyWithBufferAndMetrics(src, dst, bufferSize, recordBytes) |
| 320 | }() |
| 321 | |
| 322 | // Wait for either direction to complete |
| 323 | <-done |
| 324 | |
| 325 | // Close both connections to stop the other direction |
| 326 | dst.Close() |
| 327 | src.Close() |
| 328 | |
| 329 | // Wait for the other direction to complete |
| 330 | <-done |
| 331 | } |
| 332 | |
| 333 | // OptimizedCopyWithContextAndMetrics performs high-performance bidirectional copying with context and metrics |
| 334 | func OptimizedCopyWithContextAndMetrics(ctx context.Context, dst, src net.Conn, recordBytes func(int64)) { |
no test coverage detected