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

docs: new api #472

Merged
merged 7 commits into from
Dec 10, 2019
Merged

docs: new api #472

merged 7 commits into from
Dec 10, 2019

Conversation

vasco-santos
Copy link
Member

New API documentation for the async refactor

API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Just some suggestions 🤷‍♂️ 😁

API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
@vasco-santos vasco-santos mentioned this pull request Nov 21, 2019
1 task
API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated

| Name | Type | Description |
|------|------|-------------|
| options | `Object` | libp2p options |
Copy link
Member

Choose a reason for hiding this comment

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

What are the options?

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 would like to have a specific MD doc for the options/libp2p configuration, where this would point out. As there are so many options and instructions for configuration, I think it will be easier for people reading the docs to digest a lighter API, while being able to consult the options when needed. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think linking to a second doc for that would be useful. There is a lot of possible configuration, so avoiding that overwhelming this doc has merit.

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 will create that in a new PR next week

Copy link
Member Author

Choose a reason for hiding this comment

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

So, after writting that in #495 , I think I will document the first level properties of the options object here and point to the other doc

API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated
| Name | Type | Description |
|------|------|-------------|
| topic | `string` | topic to subscribe |
| handler | `function(<Object>)` | handler for new data on topic |
Copy link
Member

Choose a reason for hiding this comment

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

Please describe the Object!

API.md Outdated Show resolved Hide resolved
API.md Outdated

Unsubscribes the given handler from a pubsub topic. If no handler is provided, all handlers for the topic are removed.

`libp2p.pubsub.unsubscribe(topic)`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`libp2p.pubsub.unsubscribe(topic)`
`libp2p.pubsub.unsubscribe(topic, handler)`

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
API.md Outdated Show resolved Hide resolved
API.md Outdated

| Name | Type | Description |
|------|------|-------------|
| options | `Object` | libp2p options |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think linking to a second doc for that would be useful. There is a lot of possible configuration, so avoiding that overwhelming this doc has merit.

API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated

Unregisters all handlers with the given protocols

`libp2p.unhandle(protocols)`
Copy link
Contributor

Choose a reason for hiding this comment

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

It sounds like we need to clarify how handle works in these docs. It's not possible to register multiple handlers for a given protocol. For example:

libp2p.handle('/echo/1.0.0', handler)
libp2p.handle('/echo/1.0.0', otherHandler)

will only ever call otherHandler. If you think about this like setting up HTTP routes, you wouldn't route GET https://libp2p.io/protocol to two places. It's a n:1 routing system (protocols:route), rather than a subscription system.

So when you call unhandle, you are removing support for that protocol completely, and notifying peers (now that we have identify push) that's happening.

API.md Outdated Show resolved Hide resolved
API.md Outdated Show resolved Hide resolved
API.md Outdated
Iterates over all content routers in series to find providers of the given key.
Once a content router succeeds, the iteration will stop.

`libp2p.contentRouting.findProviders(cid, options)`
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 We haven't refactored this quite yet, should happen in the next day or two, and I intend to make all array based queries async iterable.

API.md Outdated Show resolved Hide resolved
vasco-santos and others added 2 commits December 1, 2019 19:55
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

Some available network protectors:
* [libp2p-pnet](https://github.com/libp2p/js-libp2p/tree/master/src/pnet)
See [API.md](./doc/API.md).
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 will add in the section before the configuration doc, which will also be linked from the API when relevant

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

Some minor things based on the most recent changes we've made. This is looking good!

doc/API.md Outdated Show resolved Hide resolved
doc/API.md Outdated Show resolved Hide resolved
doc/API.md Outdated Show resolved Hide resolved
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

This LGTM. We can iterate any final changes we need to before the final release.

@jacobheun jacobheun merged commit ca474fd into refactor/async-await Dec 10, 2019
@daviddias daviddias deleted the docs/new-api branch December 10, 2019 16:00
jacobheun added a commit that referenced this pull request Dec 12, 2019
* docs: new api

* chore: new iteration

* chore: apply suggestions from code review

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: address review

* docs: add events

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
jacobheun added a commit that referenced this pull request Jan 24, 2020
* docs: new api

* chore: new iteration

* chore: apply suggestions from code review

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: address review

* docs: add events

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
maschad pushed a commit to maschad/js-libp2p that referenced this pull request Jun 21, 2023
Send DHT query events to the onProgress callback if one is passed to
allow operation-specific progress events to pass up the stack.

Refs: libp2p#1574
maschad pushed a commit to maschad/js-libp2p that referenced this pull request Jun 21, 2023
## [9.2.0](libp2p/js-libp2p-kad-dht@v9.1.5...v9.2.0) (2023-05-05)

### Features

* invoke onProgress callback if passed as an option ([libp2p#472](libp2p/js-libp2p-kad-dht#472)) ([0bef25f](libp2p/js-libp2p-kad-dht@0bef25f))
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.

4 participants