-
Notifications
You must be signed in to change notification settings - Fork 454
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
docs: new api #472
Conversation
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.
Just some suggestions 🤷♂️ 😁
9eeef61
to
4ed4c60
Compare
4ed4c60
to
e9158bd
Compare
API.md
Outdated
|
||
| Name | Type | Description | | ||
|------|------|-------------| | ||
| options | `Object` | libp2p 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.
What are 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.
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?
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 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.
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 will create that in a new PR next week
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.
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
| Name | Type | Description | | ||
|------|------|-------------| | ||
| topic | `string` | topic to subscribe | | ||
| handler | `function(<Object>)` | handler for new data on topic | |
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.
Please describe the Object
!
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)` |
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.
`libp2p.pubsub.unsubscribe(topic)` | |
`libp2p.pubsub.unsubscribe(topic, handler)` |
Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
API.md
Outdated
|
||
| Name | Type | Description | | ||
|------|------|-------------| | ||
| options | `Object` | libp2p 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.
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
|
||
Unregisters all handlers with the given protocols | ||
|
||
`libp2p.unhandle(protocols)` |
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.
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
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)` |
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.
👍 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.
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
4fba39c
to
5de2e22
Compare
|
||
Some available network protectors: | ||
* [libp2p-pnet](https://github.com/libp2p/js-libp2p/tree/master/src/pnet) | ||
See [API.md](./doc/API.md). |
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 will add in the section before the configuration doc, which will also be linked from the API when relevant
f6d8000
to
5699779
Compare
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.
Some minor things based on the most recent changes we've made. This is looking good!
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
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 LGTM. We can iterate any final changes we need to before the final release.
* 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>
* 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>
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
## [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))
New API documentation for the async refactor