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

feat: create @helia/remote-pinner library #2

Merged
merged 18 commits into from
Aug 29, 2023
Merged

feat: create @helia/remote-pinner library #2

merged 18 commits into from
Aug 29, 2023

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Aug 14, 2023

addresses part of #1

  • Creates the pinning library
  • adds 100% test coverage
  • adds instructions for use in README

@welcome
Copy link

welcome bot commented Aug 14, 2023

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link
Member Author

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

self review

@SgtPooki
Copy link
Member Author

ping @achingbrain @whizzzkid

Copy link

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

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

this looks good as a wrapper class, but I had a few thoughts on the design:

  • can this instead be a plugin?
  • the plugin can subscribe to AddPinEvents.
  • then run the pinning task on the remote service.
  • This way we can have multiple pinning services instead of wrapping one inside the other?

src/index.ts Outdated
constructor (private readonly heliaInstance: Helia, private readonly remotePinningClient: RemotePinningServiceClient) {
}

private async getOrigins (otherOrigins: Pin['origins']): Promise<Set<string>> {

Choose a reason for hiding this comment

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

wondering if this can be static method.

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 think users could just use the pin response directly to get origins, they shouldn't be depending on this method

src/index.ts Outdated
}
}

export function createRemotePinner (heliaInstance: Helia, remotePinningClient: RemotePinningServiceClient, options?: HeliaRemotePinningOptions): HeliaRemotePinner {

Choose a reason for hiding this comment

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

would this interface not be like helia? also an opportunity to leverage mixins

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'm not sure what you mean. This is a factory function and I think we want it to remain fairly lightweight. it's not doing much users couldn't do themselves, it's just a helper library

Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

Looking good!

Some comments inline.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/errors.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
test/index.spec.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@achingbrain
Copy link
Member

If it's desirable to use multiple pinning service endpoints, this module could take RemotePinningServiceClient | RemotePinningServiceClient[] and just try them all when adding/replacing pins?

@SgtPooki
Copy link
Member Author

SgtPooki commented Aug 25, 2023

If it's desirable to use multiple pinning service endpoints, this module could take RemotePinningServiceClient | RemotePinningServiceClient[] and just try them all when adding/replacing pins?

I think i'll leave this out for now as the error handling on this would be fairly excessive. We can add later if we want. created #5 to track

Copy link

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

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

Lgtm

@SgtPooki SgtPooki merged commit 7ee93a7 into main Aug 29, 2023
17 checks passed
@SgtPooki SgtPooki deleted the feat/first-impl branch August 29, 2023 20:01
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.

None yet

3 participants