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

Use Arc<Store> instead of Store for lazy loading #151

Closed
wants to merge 1 commit into from
Closed

Use Arc<Store> instead of Store for lazy loading #151

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 12, 2019

Description

Change store's type used in Router and Extract to wrapped one, to load configurations after extraction.
This change affects to public trait.

Motivation and Context

Sometimes we define services for SoC. They would be dependent on another services.
Tide has per-endpoint configuration, so every services should be able to read it.

One way for it is passing a store's reference in services' constructor recursively while extraction. This looks good, but if some services depend on same services, duplicate object will be created.
Another way is extract (partial) clone of store and share it across services. If the store is big, per-request clone will be high cost.

This change helps latter one. Instead of cloning a store directly, we can clone just shared reference with few overhead.

How Has This Been Tested?

There are no additional tests.
Implementations of Extract are affected, but it can be easily fixed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mmrath
Copy link
Contributor

mmrath commented Mar 12, 2019

Why would services depend on Store? I would expect services to be independent of any of the types in tide.
Would you have some example code showing the benefit/usage?

@ghost
Copy link
Author

ghost commented Mar 13, 2019

@mmrath Sorry, actualy I have no Idea.
At the first I thought is to inject slog logger and configure logging strategies by per-endpoint, per-service, but I can not determine whether this use case is appropriate because of lack of experiences.

@aturon
Copy link
Collaborator

aturon commented Apr 10, 2019

Closing this one, since the relevant concepts were removed in #156.

@aturon aturon closed this Apr 10, 2019
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