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

Problem 10: UseDbScopeAttribute was replaced by InteractionScopeAttribute. #11

Merged
merged 3 commits into from
Mar 26, 2019

Conversation

kegor
Copy link
Contributor

@kegor kegor commented Mar 19, 2019

Problem #10:
InteractionScopeAttribute needs to be added.

Solution:
In this PR were added InteractionScopeAttribute and InteractionScopeMiddleware, using them (in the current iteration) we can return untouched response or Db.Scope(next)/new Transaction.Scope(new) depending on attribute mode.

Related task: #5.

Tests:

  1. Reference to the updated Starcounter.Startup was added into HeadsOmni sub-modules: SignIn/UserAdmin/Products/Showroom/Blending.
  2. In the HeadsOmni solution build.cake and setup.cs were changed to run only apps from p.1.
  3. In the composition for the Product page was added input that shows Products.Product.Name value.
  4. Were performed two checks with using [InteractionScope(InteractionScopeAttribute.InteractionScopeMode.AttachOrCreate)] (default) [InteractionScope(InteractionScopeAttribute.InteractionScopeMode.AlwaysCreate)] on the ProductPage, results on the screenshots below.

Screenshots:
shared_scope

new_scope

@kegor kegor requested a review from mtornwall March 19, 2019 07:59
Copy link

@mtornwall mtornwall left a comment

Choose a reason for hiding this comment

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

Left some change requests and suggestions. Really nice work. Thanks for the thorough testing.


namespace Starcounter.Startup.Routing.Middleware
{
public class InteractionScopeMiddleware : IPageMiddleware

Choose a reason for hiding this comment

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

  • Will the DbScope attribute still work?
  • Do we use it anywhere?
    • If yes, can we mark it obsolete and implement its logic in InteractionScopeMiddleware?
    • If no, can we drop it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mtornwall the answers:

  1. Before changing UseDbScope on InteractionScope attribute i made few searches:
    I found usage of the UseDbScope attribute in the 6 apps: https://github.com/search?q=org%3AStarcounter+UseDbScope&type=Code, but at the same time i found invocation of the AddDbScopeMiddleware (that registers related middleware IIUC) only in AssortmentManager: https://github.com/search?q=org%3AStarcounter+AddDbScopeMiddleware&type=Code (and in Starcounter.Startup itself).
  2. So my plan was: simultaneously with replacing old attribute with new one make the replacement in these apps, and invoke method AddInteractionScopeMiddleware in all, to restore initial logic. This why i decided to add the case with returning just next() as it was in the old attribute (we are discussing this point above currently).

Choose a reason for hiding this comment

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

@kegor Sounds like a reasonable plan.

Choose a reason for hiding this comment

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

Note though, when you upgrade the Startup version used by the HeadsOmni apps (and others), we'll need to do the same for the Buildcraft apps that use it. I can take care of that if you tell me the version to upgrade to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mtornwall, seems like improvements by your comments were made, could we go further with merge or some new tests should be made, what do you think?

@@ -0,0 +1,8 @@
namespace Starcounter.Startup.Routing.Enums

Choose a reason for hiding this comment

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

No need for a separate namespace to hold the enums.

@@ -1,17 +1,11 @@
using System;
using Starcounter.Startup.Routing.Enums;

namespace Starcounter.Startup.Routing.Middleware
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class InteractionScopeAttribute : Attribute

Choose a reason for hiding this comment

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

This class should go in the same namespace as the Url attribute I think.

@kegor
Copy link
Contributor Author

kegor commented Mar 25, 2019

After discussion with @mtornwall i made following test:
Martin i did few steps:

  1. Made local 0.8.0 version package of the Starcounter.Startup.
  2. Pulled HeadsOmni master and tried build-all (with commented lines for MGen/DoctorM in build.cake), and got success.
  3. Then updated Starcounter.Startup version in the VS package manager.
  4. Removed all occurrences of the UseDbScopeAttribute in the HeadsOmni solution opened in the VS.
  5. Made build-all/run-all/load-config and checked that after signing in, the pages of the BlendingEditor (randomly selected app) opening as usual.

@kegor kegor merged commit e848739 into master Mar 26, 2019
@kegor kegor deleted the 10-add-interactionscope-attribute branch March 26, 2019 15:25
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