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

deprecate App::data and App::data_factory #2271

Merged
merged 5 commits into from Jun 22, 2021
Merged

deprecate App::data and App::data_factory #2271

merged 5 commits into from Jun 22, 2021

Conversation

robjtede
Copy link
Member

@robjtede robjtede commented Jun 19, 2021

PR Type

Deprecation

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Partially addresses the problem we have with .app_data(val) vs .data(val) vs .app_data(Data::new(val)) by deprecating .data(val) and encouraging use of .app_data(Data::new(val)) as a replacement.

Also deprecates App::data_factory() because of it's limited use. There is a plan to introduce a similar type LazyData post-v4 that would be used in the same way as Data and more useful because it allows the app to start serving requests before it resolves.

@robjtede robjtede added B-semver-patch A-web project: actix-web labels Jun 19, 2021
@robjtede robjtede requested a review from a team June 19, 2021 20:09
@robjtede robjtede changed the title deprecate App::data deprecate App::data and App::data_factory` Jun 19, 2021
@robjtede robjtede changed the title deprecate App::data and App::data_factory` deprecate App::data and App::data_factory Jun 19, 2021
@ibraheemdev
Copy link
Member

Won't people just start doing .app_data(Foo)?

@aliemjay

This comment has been minimized.

@robjtede
Copy link
Member Author

robjtede commented Jun 19, 2021

Won't people just start doing .app_data(Foo)?

Hopefully the deprecation notice will accurately guide existing users to the new code setup.

For new users, I suspect it will be far easier to document on .app_data and the Data extractor how they work together without having to talk about 2 methods for inserting data values. This should become even clearer when there is more than 1 data extraction type.

I think there are more steps we can take to help, too. For example, the Data<T> extraction debug error could check the inner T type's existence in the map and report it in the error with instructions on how to fix it.

Very willing to debate this further and hash out the complete set of implications; consider this my opening statement.

Copy link
Member

@popzxc popzxc left a comment

Choose a reason for hiding this comment

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

I'm OK with changes and actually it makes sense and looks good.

However, now tests for these methods have warnings, and due to many jobs it makes the diff bloated and hard to watch. Wouldn't it be better to add #[allow(deprecated)] to these tests?

@robjtede robjtede merged commit 12f7720 into master Jun 22, 2021
@robjtede robjtede deleted the deprecate-data branch June 22, 2021 14:51
@rsalmei
Copy link

rsalmei commented Jun 28, 2021

Since this will be a major version release, why don't you just remove instead of deprecate?

@robjtede
Copy link
Member Author

Since this will be a major version release, why don't you just remove instead of deprecate?

It would be overly distruptive to migration since it would affect almost all AW apps.

@otavio
Copy link
Contributor

otavio commented Jun 28, 2021

I second the removal as well. We kind of expect breaking changes when doing major upgrades so it allows the removal of old code.

We could mark it as deprecated if releasing it on a minor or patch versions.

@popzxc
Copy link
Member

popzxc commented Jun 28, 2021

Nah, I think that it'd be too radical. While I'm all in for removing things, but for a mature framework that is already being used in production by many teams, it's better to do things gradually.

It's OK to clean up the code, but it's less OK to be not predictable and sudden.

Given the fact that 4.0 is not so far away, it'll reduce amount of people who will be able to quickly switch to a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants