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: support connection type #15

Merged
merged 13 commits into from
Oct 26, 2021
Merged

Conversation

NNcrawler
Copy link
Member

No description provided.

@NNcrawler NNcrawler linked an issue Sep 28, 2021 that may be closed by this pull request
.env.test Outdated Show resolved Hide resolved
Copy link
Member

@ramey ramey left a comment

Choose a reason for hiding this comment

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

Have added a few comments, let me know if you want to discuss them offline.

.env.sample Outdated Show resolved Hide resolved
integration/integration_test.go Show resolved Hide resolved
websocket/connection/conn.go Outdated Show resolved Hide resolved
websocket/connection/identifier.go Outdated Show resolved Hide resolved
websocket/connection/conn.go Show resolved Hide resolved
websocket/pinger.go Outdated Show resolved Hide resolved
websocket/handler_test.go Show resolved Hide resolved
websocket/handler_test.go Show resolved Hide resolved
websocket/connection/upgrader.go Show resolved Hide resolved
websocket/connection/upgrader.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
websocket/connection/identifier.go Outdated Show resolved Hide resolved
Copy link
Member

@ramey ramey left a comment

Choose a reason for hiding this comment

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

LGTM!!

docs/concepts/architecture.md Outdated Show resolved Hide resolved
@@ -93,15 +93,15 @@ The above response model is self-explanatory. Clients can choose to retry for er

## Headers

Raccoon service accepts headers to identify a user connection uniquely. The header name is made configurable as it enables clients to specify a header name that works for them. For, e.g. for a mobile app having a request header as `X-User-id` which identifies the user \(client\) connecting to Raccoon, can configure Raccoon service with the config set as below `SERVER_WEBSOCKET_CONN_UNIQ_ID_HEADER=X-User-id`
Raccoon service accepts headers to identify a user connection uniquely. The header name is made configurable as it enables clients to specify a header name that works for them. For, e.g. for a mobile app having a request header as `X-User-ID` which identifies the user \(client\) connecting to Raccoon, can configure Raccoon service with the config set as below `SERVER_WEBSOCKET_CONN_ID_HEADER=X-User-ID`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we include the other group parameter and explain clearly, also point it as optional

func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request) (Conn, error) {
identifier := Identifer{
ID: r.Header.Get(u.connIDHeader),
// If connGroupHeader is empty string. By default, it will always have an empty string as Group. This means uniqueness only depends on ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

If the default value is empty how does it work with dashboards where the metrics are expected to be grouped by conn_group?
Could we supply a default value by default when the config is loaded? (set this to say user)?
This way it is forced for someone to set it. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

It simply will ignore the tag. No need to group if metrics don't have groups. Default value on tag value? IMO default tag value is confusing. Better not showing it at all if it's not there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolving this since it's addressed per how we should handle default in the other section.


conn, err := u.gorillaUg.Upgrade(w, r, nil)
if err != nil {
metrics.Increment("user_connection_failure_total", fmt.Sprintf("reason=ugfailure,conn_group=%s", identifier.Group))
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't choose this type in dashboard if we have a default tag as empty right?

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's not there then it's not available. Why would anyone want to select it if it's not there?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's say:
x-1 version of deployment where there was no conn group
x version of deployment where there is conn_group and now the value is 'web'

On dashboard the grouped by has only 'web' ==> how would you select metrics based on empty (no conn group) pre x deployment?

Technically allowing default as "" values will see this problem for new deployments of raccoon. For upgrade from x-1 to x we have the problem listed above.

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case, I'll have --default-- as default group to differentiate it with user-defined group header value. I'll also add the identifier factory back for testability. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Like we discussed in the group: There should be a group_default configurable variable whose default value is --default--. This will enable users provide/override this default thus enforcing a cleaner solution and avoids a situation that leads to what is discussed in the comments.

We also need to clarify clearly as part of the architecture docs in how this default_group works and also cite it as a configurable option as part of the production checks section.

websocket/connection/upgrader.go Show resolved Hide resolved
websocket/connection/upgrader_test.go Show resolved Hide resolved
Copy link
Contributor

@chakravarthyvp chakravarthyvp left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor comment

}
return Identifer{
ID: h.Get(u.connIDHeader),
// If connGroupHeader is empty string. By default, it will always have an empty string as Group. This means uniqueness only depends on ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

should we reword this now?

@ramey ramey merged commit a562cd5 into raystack:main Oct 26, 2021
@ravisuhag ravisuhag linked an issue Dec 11, 2021 that may be closed by this pull request
@ravisuhag ravisuhag removed a link to an issue Dec 11, 2021
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.

support connection type as unique identifier along with id
4 participants