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

core: add attrs to request message #903

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

carl-mastrangelo
Copy link
Contributor

This is an example of adding Attrs (as an alternative to SessionContext). Attrs are type safe, and make it easy to find out where a particular Key is used. Attrs is mutable as there are several places where it its mutated. Since we don't have the error prone checks to ensure return values are used, it would be risky to make Attrs immutable.

@@ -31,6 +32,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.w3c.dom.Attr;
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@artgon
Copy link
Contributor

artgon commented Oct 7, 2020

I like it conceptually but I don't like the name "Attrs". For example, I think SessionContext is a lot more descriptive.

@carl-mastrangelo
Copy link
Contributor Author

@artgon I can make the accessor something like callAttrs. I feel Session is the wrong terminology too (a session persists across multiple calls). I am using the Attrs in other places so I don't think it would be correct to change the type name, just the variable name.

@artgon
Copy link
Contributor

artgon commented Oct 7, 2020

What about RequestAttrs? or RequestAttributes? I would suggest RequestContext but that's overloaded as is.

@argha-c
Copy link
Collaborator

argha-c commented Oct 7, 2020

Yeah, given the usage, the name should allude to this being a request level attribute store. Avoid RequestContext since that has connotations based on prior usage in other frameworks/libs.

@argha-c
Copy link
Collaborator

argha-c commented Oct 7, 2020

Unrelated to this change but since we're on this class,

T result = (T) attrs.storage.get(this);
if (result != null) {
return result;

I think the type conversion should happen on line 67, ie. after the null check, not before.

@carl-mastrangelo
Copy link
Contributor Author

I'm also hesitant to use the word Request because its shared for the request and the response, same as SessionContext.

@artgon
Copy link
Contributor

artgon commented Oct 8, 2020

So, we need a word that includes both Request and Response but isn't "Session" :)

@carl-mastrangelo
Copy link
Contributor Author

I think Call encompasses both.

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