-
Notifications
You must be signed in to change notification settings - Fork 207
Json package report try #2 #810
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
Conversation
|
There's at least one error: |
|
Would it be possible to include homepage as well? |
86a75cd to
1786e2d
Compare
|
Fixed and cleaned up. Ready for review :) |
Depends... there's some packages which have 150+ releases and there's also .cabal files which are not that cheap to parse and take a significant amount of time and space to parse. But I don't think you need to parse all Btw, when there's a |
|
@hvr re: re: caching, yes, requests for the version listing only force parsing of the cabal files for that package. Requests for a particular version only parse that one version. Would it be too optimistic to assume that when we are only using these top-level fields, laziness saves us from having to parse the whole file? |
|
I noticed that the sample endpoints do not have .json, is that intentional? |
|
@alexcmcdaniel Thanks, yep. If you just type those example URLs into a browser you'll get html. Implicitly I meant for an |
Yes. To claim a successful parse the whole file needs to be examined. Usually lazy parsing only works well if your format supports laziness explicitly. |
|
@imalsogreg any updates? |
|
@alexcmcdaniel I'm slowly working on the caching part. |
|
@imalsogreg how is the caching coming? |
8e4ac86 to
a73f029
Compare
|
I added AcidState actions for the API endpoints. It does read-through caching, with a hook on package change to delete the cache lines for a package. I did not add any backup logic, since all the data that would be backed up is a redundant view of other already-backed-up data. And our API is cheap to call. So the backup would cost us more in maintenance and versioning than it would help us with site integrity. Think so? I've rebased to clean up the commit history, added a couple small tests and gone through a cleanup pass. Is there anything else we should do before final review and merge? Any more fields to add to the package description API? |
| -- | Basic information about a package. These values are | ||
| -- used in the `/package/:packagename` JSON endpoint | ||
| data PackageBasicDescription = PackageBasicDescription | ||
| { pbd_license :: License |
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.
Can we make these fields strict? We put that into a map in memory, it would be a shame to introduce a leak.
| import Data.Aeson ((.=), (.:)) | ||
| import Data.Acid (Query, Update, makeAcidic) | ||
| import qualified Data.HashMap.Strict as HashMap | ||
| import qualified Data.Map as Map |
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.
Also it might make sense to use Data.Map.Strict here.
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.
Note: You should use Data.Map.Strict instead of this module if:
You will eventually need all the values stored.
The stored values don't represent large virtual data structures to be lazily computed.
Sounds like me! 👍
0da8279 to
b7cebc6
Compare
|
Anyone available to approve/request changes? I'd love to get this in to hackage :) |
| setDescriptionFor pkgId descr = State.modify $ \p -> | ||
| case descr of | ||
| Just d -> p {descriptions = Map.alter (const (Just d)) pkgId (descriptions p)} | ||
| Nothing -> p {descriptions = Map.filterWithKey (\pkgId' _ -> fst pkgId' /= fst pkgId) (descriptions p)} |
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.
@iamalsogreg can you explain why we wouldn't use Map.delete here?
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.
Yah - since descriptions is keyed on (PackageIdentifier, Maybe Int), if I use delete, I would be deleting just a particular package/metadata combination. But what I want is for a change to the package to delete every package entry for some fixed package, at every metadata revision.
If there were a deleteWithKey function that transforms the key before deciding what to delete, that could be nicer than the filterWithKey I use.
|
Ah makes sense, I didn't see both fst! |
|
@imalsogreg hey sorry to make a last second request but would it be possible to add the homepage as well? |
|
oh never mind I see that you added it in the last commit, any update on the timing of the release? @imalsogreg @hvr |
|
I am also interested in this pull request, any update? |
Package JSON API (replacement of #810)
|
obsoleted by #996 |
Replacement for #399
Add two endpoints, which reuse existing URLs but use the requested content type to choose a JSON response instead of HTML. The new endpoints provide basic information about a package (author, description, license), and a listing of available versions for a package, along with each version's deprecation status.
For example:
/package/avro-0.4.1.2/package/avroFor the first (single-version) view, the URL can specify a metadata revision:
/packages/avro-0.4.1.1/revision/1(when no revision is specified, the most recent one is used)
NOTE: There is no caching implemented for these endpoints. Is it Ok to assume that the computations being done (parsing several cabal files per request) are cheap enough to justify not adding some AcidState caching?
There is no dependencies data in this PR. I'm thinking of adding that in a second PR, after talking with @hvr about his ideas for formatting there.
/cc @hvr @alexcmcdaniel @gbaz