Skip to content

feat: add Close() method to RedHub server#40

Merged
gitsrc merged 1 commit intomainfrom
feat/add-close-method
Jan 11, 2026
Merged

feat: add Close() method to RedHub server#40
gitsrc merged 1 commit intomainfrom
feat/add-close-method

Conversation

@gitsrc
Copy link
Member

@gitsrc gitsrc commented Jan 11, 2026

Add a Close() method to allow graceful shutdown of the RedHub server. This addresses issue #14 and provides a similar API to tidwall/redcon.

Changes:

  • Add mu, addr, and running fields to RedHub struct for server state
  • Add Close() method that gracefully shuts down the server
  • Modify ListenAndServe to track server state
  • Add unit tests for Close() functionality
  • Add integration test for Close() method

The Close() method:

  • Returns error if server is not running
  • Calls gnet.Stop() to gracefully shutdown
  • Is thread-safe with mutex protection
  • Can be called from any goroutine

@gitsrc gitsrc force-pushed the feat/add-close-method branch from 3f19dad to 7f53f51 Compare January 11, 2026 13:02
Add a Close() method to allow graceful shutdown of the RedHub server.
This addresses issue #14 and provides a similar API to tidwall/redcon.

Changes:
- Add mu, addr, and running fields to RedHub struct for server state
- Add Close() method that gracefully shuts down the server
- Modify ListenAndServe to track server state
- Add unit tests for Close() functionality
- Add integration test for Close() method

The Close() method:
- Returns error if server is not running
- Calls gnet.Stop() to gracefully shutdown
- Is thread-safe with mutex protection
- Can be called from any goroutine

Signed-off-by: BlockCraftsman <167502426+BlockCraftsman@users.noreply.github.com>
@gitsrc gitsrc force-pushed the feat/add-close-method branch from 7f53f51 to 9aceb31 Compare January 11, 2026 13:03
@gitsrc gitsrc merged commit 0462cca into main Jan 11, 2026
12 checks passed
@gitsrc gitsrc deleted the feat/add-close-method branch January 11, 2026 13:04
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