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

refactor: better client connection state management #364

Merged
merged 3 commits into from Aug 27, 2022

Conversation

wujunzhuo
Copy link
Collaborator

@wujunzhuo wujunzhuo commented Aug 15, 2022

This change is Reviewable

}

c.state = ConnStateDisconnected
c.errc <- err
Copy link
Contributor

Choose a reason for hiding this comment

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

In the BASIC example, if an error is returned here, the client will exit. In previous versions, the server dropped without an error。

core/client.go Outdated

stream.Close()
if closeConn {
c.conn.CloseWithError(yerr.ErrorCodeClientAbort.To(), err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should more error type checking be added so that the server knows exactly what the error code is and why? For example, something like this:

			if e, ok := err.(*quic.ApplicationError); ok {
				c.logger.Printf("%s[%s]connection closed by application error: %v", ClientLogPrefix, c.state, e)
				c.conn.CloseWithError(e.ErrorCode, e.Error())
			} else if e, ok := err.(*yerr.YomoError); ok {
				c.logger.Printf("%s[%s]connection closed by yomo error: %v", ClientLogPrefix, c.state, e)
				c.conn.CloseWithError(e.ErrorCode().To(), e.Error())
			} else {
				c.conn.CloseWithError(yerr.ErrorCodeClientAbort.To(), err.Error())
			}

c.conn.CloseWithError(yerr.To(yerr.ErrorCodeRejected), v.Message())
c.errc <- errors.New(v.Message())
break
return true, true, errors.New(v.Message())
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better to use YomoError? Like this:

    return true, true, yerr.New(yerr.ErrorCodeRejected, errors.New(v.Message()))

Copy link
Contributor

@venjiang venjiang left a comment

Choose a reason for hiding this comment

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

👍

@fanweixiao fanweixiao merged commit f6c3c73 into yomorun:master Aug 27, 2022
Copy link
Member

@fanweixiao fanweixiao left a comment

Choose a reason for hiding this comment

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

👍🏼

@wujunzhuo wujunzhuo deleted the ref/conn branch August 27, 2022 06:47
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.

None yet

3 participants