Skip to content

Conversation

@Zereker
Copy link
Owner

@Zereker Zereker commented Dec 26, 2025

Summary

  • Rename HeartbeatOption to IdleTimeoutOption for clarity
  • Add ErrMessageTooLarge for message size validation
  • Improve Write method documentation and backpressure handling
  • Add connection lifecycle logging
  • Add ServerLoggerOption and ServerShutdownTimeoutOption
  • Fix shutdown timeout to use non-blocking select pattern
  • Update CI to use go-version-file from go.mod
  • Use master as the only main branch
  • Update .gitignore with common entries

Test plan

  • All tests pass with -race flag
  • go vet passes
  • CI workflow validated

Changes based on the architecture review report:

1. Rename heartbeat to idleTimeout for clarity
   - The previous "heartbeat" was actually an idle timeout mechanism
   - Added IdleTimeoutOption with clear documentation explaining it's
     not a ping/pong heartbeat mechanism
   - Removed deprecated HeartbeatOption (no backward compatibility)

2. Add message size validation with ErrMessageTooLarge
   - Implemented limitedReader that returns ErrMessageTooLarge when
     the message exceeds maxReadLength
   - This provides clearer error messages when messages are too large

3. Improve Write method documentation
   - Added detailed documentation for Write, WriteBlocking, WriteTimeout
   - Documented ErrBufferFull with recommended handling strategies
   - Added backpressure handling guidance in README

4. Add connection lifecycle logging
   - Connection established/closed events logged at Info level
   - Connection options logged at Debug level
   - Server start/stop events logged at Info level
   - Added ServerLoggerOption for custom logger

5. Add graceful shutdown timeout control
   - Added ServerShutdownTimeoutOption for graceful shutdown
   - Server waits for the timeout before stopping accept

Test coverage maintained at 3:1 ratio with new tests for:
- ErrMessageTooLarge validation
- limitedReader functionality
- ServerLoggerOption
1. Fix ShutdownTimeout to use select pattern
   - Use select with time.After instead of blocking sleep
   - Add shutdownNow channel to allow Close() to bypass timeout
   - This allows immediate shutdown when all connections are done

2. Add comment to limitedReader.reset
   - Explain why only remaining is reset (bufio.Reader maintains state)

3. Use errors.Is for context.Canceled comparison
   - More robust error comparison in conn.go Run method
- Use go-version-file to read Go version from go.mod
- Use master as the only main branch
- Add common gitignore entries (workspace, debug, profiling, etc.)
@Zereker Zereker merged commit 09b7e80 into master Dec 26, 2025
3 checks passed
@Zereker Zereker deleted the claude/review-tcp-framework-Jf7bb branch December 26, 2025 09:37
Zereker added a commit that referenced this pull request Dec 26, 2025
* feat: improve TCP framework based on architecture review

Changes based on the architecture review report:

1. Rename heartbeat to idleTimeout for clarity
   - The previous "heartbeat" was actually an idle timeout mechanism
   - Added IdleTimeoutOption with clear documentation explaining it's
     not a ping/pong heartbeat mechanism
   - Removed deprecated HeartbeatOption (no backward compatibility)

2. Add message size validation with ErrMessageTooLarge
   - Implemented limitedReader that returns ErrMessageTooLarge when
     the message exceeds maxReadLength
   - This provides clearer error messages when messages are too large

3. Improve Write method documentation
   - Added detailed documentation for Write, WriteBlocking, WriteTimeout
   - Documented ErrBufferFull with recommended handling strategies
   - Added backpressure handling guidance in README

4. Add connection lifecycle logging
   - Connection established/closed events logged at Info level
   - Connection options logged at Debug level
   - Server start/stop events logged at Info level
   - Added ServerLoggerOption for custom logger

5. Add graceful shutdown timeout control
   - Added ServerShutdownTimeoutOption for graceful shutdown
   - Server waits for the timeout before stopping accept

Test coverage maintained at 3:1 ratio with new tests for:
- ErrMessageTooLarge validation
- limitedReader functionality
- ServerLoggerOption

* fix: address review feedback on shutdown timeout and code quality

1. Fix ShutdownTimeout to use select pattern
   - Use select with time.After instead of blocking sleep
   - Add shutdownNow channel to allow Close() to bypass timeout
   - This allows immediate shutdown when all connections are done

2. Add comment to limitedReader.reset
   - Explain why only remaining is reset (bufio.Reader maintains state)

3. Use errors.Is for context.Canceled comparison
   - More robust error comparison in conn.go Run method

* chore: update CI config and gitignore

- Use go-version-file to read Go version from go.mod
- Use master as the only main branch
- Add common gitignore entries (workspace, debug, profiling, etc.)

* fix: update golangci-lint config for v1.x compatibility

* fix: resolve build output conflict with example directory

---------

Co-authored-by: Zereker <Zereker@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants