-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Implemented a Provider structure for Files, Cache, and Database adapters. Added a new memory cache implementation. #291
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fc9b4c4
Added the memory cache and tests.
ce40215
Implemented the new cache/provider to replace the old cache.js. All t…
94835a3
Added default TTL
127bdb7
Gave up my reservations about relying on Node module caching to enfor…
c853957
Clean up, added documentation. Moved resolveAdapter to the provider
ac6b6df
Moved the requirement statement to the top of the file
91feeac
Merged in the changes to DatabaseProvider and FilesProvider. Updated …
9488a9e
Rebased and moved to the new structure
8d8a01c
Fixed the pathing issues with the new structure
6b29cbc
Updated to ES6
9405e35
Removed deprecated FilesAdapter and DatabaseAdapter
cf0247f
Prevent crashing by adding default args
20b7835
Updated bin/parse-server to wrap the options as an app { ... app: { o…
309775d
Decoupled providers and default adapters.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this breaking change on the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a separate PR probably. I wanted to separate the application configuration from the server configuration (see
args.app
inindex.js
), so that I could passargs.app
to a constructor:new ParseApp(args.app);
. Basically just namespacing the app options. This would likely change to an array when we implement multiple apps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I have
{applications: [] }
Then ignore all other keys in configuration, in the sense that all apps should and could be configured differently (DB provider, keys, adapters, cloud code etc...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the singleton providers (mail, cache, database, files) would need to have a map of
app:adapter
. I started implementing it and decided it would be better to get this merged first. The DatabaseProvider already kind of implements this, but I want to refactor it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not get too opinionated on general configuration vs per app configuration. If designed properly, no matter how many app run on the server it should work. We should not have singletons as we create new instances of the ParseServer, it doesn't make any sense that on server configuration interfere with another.
Today, the multiple server is not supported because of the singletons everywhere, which are more bad design decisions we need to turn right don't you think?
I mean, when developing apps, I just want to quickly update my json configuration with a new set APP keys and get running, like we did back in the parse days :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I've refactored all the singletons out in a fork of mine, but it's a pretty major revision. I've harped on it in a few issues, but never gotten any traction. Basically you have to pass the context down via the Express req object. So if you need to access the MailProvider you have to do something like
req.Parse.Server.MailProvider.getAdapter()
. This is also cool because you can write custom middleware when running ParseServer as an express plugin.getAdapter()
would becomegetAdapter(appId)
for all the service providers.I'm not sure the singletons are blocking multiple servers though. Once we map applications to adapters then I think we're clear to run multiple servers each with independent adapter configurations for the same application. I was strongly against singletons, but I started to look at the Mongoose source and figured if Mongoose is using them, then we're probably safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a CLI and Docker has some good opportunities to basically bootstrap a Parse server stack with just a 1 liner:
docker run parse-server:latest --config '{ databaseURI, appId, masterKey }'
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
npm install -g parse-server && parse-server --config path/to/config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh, singletons have given me a real pain to make the multiple apps work correctly, the first in line being Parse, because everything is asynchronous, you can't guarantee that your singleton didn't change it's state between 2 callbacks :)