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

Initial work on hex_api #11

Merged
merged 5 commits into from
Apr 27, 2018
Merged

Initial work on hex_api #11

merged 5 commits into from
Apr 27, 2018

Conversation

wojtekmach
Copy link
Member

There's more to be done in other PRs, see updated roadmap: #6.


get_package_test() ->
{ok, Package} = hex_api:get_package("ecto", ?OPTIONS),
#{<<"name">> := <<"ecto">>, <<"releases">> := _} = Package,
Copy link
Member Author

@wojtekmach wojtekmach Mar 28, 2018

Choose a reason for hiding this comment

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

another option is to return atom keys so that it's easier to work with, mimics registry functions (also atom keys), and we could document all fields as a type. wdyt @ericmj?

somewhat related, should it be hex_api:get_package("ecto") or hex_api:get_package(<<"ecto">>) here and in other places? I'm starting to think the latter would be better because we almost always return binaries not charlists.

Copy link
Member

Choose a reason for hiding this comment

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

Atom keys sound good. We should binaries over charlists as much as possible.

@wojtekmach
Copy link
Member Author

@ericmj I still need to add docs but would appreciate feedback on the implementation in the meantime.

src/hex_api.erl Outdated
{downloads, [week, recent, day, all]},
inserted_at,
updated_at
],
Copy link
Member

Choose a reason for hiding this comment

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

Are the fields for string to atom conversion? I wonder if we should use strings instead so that we don't have to update this library for each new field the API adds.

Copy link
Member Author

@wojtekmach wojtekmach Apr 22, 2018

Choose a reason for hiding this comment

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

#11 (comment) :) I wanted atom keys and chose whitelist approach as opposed to blacklist approach for 2 reasons: it nicely handles deprecated fields and different shapes: downloads shape is known but links is not etc.

I am aware of increased maintenance burden of adding new fields. Hope its not too pretentious but I consider Hex to be mostly complete :) so I dont think this will be a huge issue in practice but its definitely not ideal. That being said, If we stick to it I gotta feeling I will regrey it the next time we do happen to add a new field, but let me sit on it for a couple days anyway :)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the reminder 😀. Sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've decided to revert these changes. The reason is when hex_erl is released and used by build tools, when we add a new field in hexpm we'll need to update hex_erl and then bump both hex & rebar which seems too much.

I'd still like to use atom keys here (and in tarball metadata!) but maybe will use blacklist approach later; keeping as strings for now.

sorry for going back'n'forth 😅

@wojtekmach wojtekmach merged commit eb327f8 into master Apr 27, 2018
@wojtekmach wojtekmach deleted the wm-api branch April 27, 2018 15:55
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