Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add QUIC server support #423

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

juniorjse
Copy link

Enable support for QUIC protocol to expand connection options in supported environments.

juniorjse and others added 20 commits October 7, 2024 15:56
- Modified GetAddr, GetConnChan
- Added EnableProxyProtocol, IsRunning, GetConfiguredAddress, ListenAndServe
- Updated Read, Write methods
- Implemented GetNextMessage
- Removed SetDeadline methods
- Modified GetAddr, GetConnChan
- Added EnableProxyProtocol, IsRunning, GetConfiguredAddress, ListenAndServe
- Updated Read, Write methods
- Implemented GetNextMessage
- Removed SetDeadline methods
examples/demo/cluster_grpc/main_quic.go Outdated Show resolved Hide resolved
}

// EnableProxyProtocol not implemented for QUIC, keep as No-op or implement as needed
func (a *QuicAcceptor) EnableProxyProtocol() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guthyerrz I think it's important to understand who's using proxy protocol and what's the use case, so we evaluate if we need to implement this right away or not


// Write writes data to the connection with a defined deadline
func (q *QuicConnWrapper) Write(p []byte) (int, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) // 5 seconds timeout as an example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this timeout configurable instead of hardcoding it here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do it


// Close closes the QUIC connection
func (q *QuicConnWrapper) Close() error {
return q.conn.CloseWithError(0, "closed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't really read the API here, but do all connections need to be closed with errors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quic-go documentation specifies that to close a connection you must use CloseWithError, as there is no simple Close() method. quic-go does not provide a way to close the connection without reporting an error code and message


// GetNextMessage reads the next message available in the QUIC stream
func (q *QuicConnWrapper) GetNextMessage() (b []byte, err error) {
// Read data from the stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you leverage io utilities that go provides in this method, just like we do for the tcp acceptor?
https://github.com/topfreegames/pitaya/blob/main/pkg/acceptor/tcp_acceptor.go#L55-L74

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, you seem to be assuming the maximum size of a message will be 1024 bytes, which is inaccurate

juniorjse and others added 6 commits November 11, 2024 15:01
This change introduces a new `--acceptor` flag, allowing users to choose between TCP and QUIC protocols when running the server. Examples:

- For TCP: `go run main.go --acceptor=tcp`
- For QUIC: `go run main.go --acceptor=quic`
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