-
Notifications
You must be signed in to change notification settings - Fork 298
Conversation
} | ||
|
||
var rs = new Stream() | ||
rs.readable = true |
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.
you can use through2 instead, that way you can pipe the respons into your transform
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.
In the end, we've decided to keep using Stream for now, and maybe investigate using through2 in the future instead.
Looking good @victorbjelkholm! Couple of small notes to simplify the code. Would you want to expand the tests to include a test for peerA to peerB to make sure two peers are talking? This doesn't really fall under unit tests but imo would be good to get into a habit of writing simple integration tests, too. That way our test suites can spot when deps break. Not needed for this PR to be merged imo, but would be nice addition. |
rs.cancel = () => { | ||
request.abort() | ||
activeSubscriptions = removeSubscription(activeSubscriptions, 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.
this is now defined twice
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.
Yeah, my thinking is that if you're canceling the subscription before you got one message, we need to cancel the subscription and update the list of subscriptions.
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.
Correct, but the outer definition is enough, you are only duplicating the same code in the inner one.
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.
Ah, of course. Thanks
Thanks for reviewing!
Test for pub/sub between nodes added 👍 |
f2fef38
to
df2c2a1
Compare
@haadcode @dignifiedquire @diasdavid finished all outstanding tasks, only thing missing is a rebase. Can you confirm everything looks good? |
ipfsApi.pubsub.subscribe('my-topic', (err, subscription) => { | ||
if (err) { | ||
console.log('Something went wrong setting up the subscription') | ||
throw err |
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 use 2 space indents
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.
Sure, got no linting for .md files ;)
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.
not yet :P
If CI is happy, I am happy |
return Object.assign({}, message, { | ||
from: bs58.encode(message.from), | ||
data: Base64.decode(message.data), | ||
seqno: Base64.decode(message.seqno) |
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.
@whyrusleeping you are base64 encoding all the messages?
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.
nvm, it is just when it comes through the http-api
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.
base64 encoding happens on buffers in json
@dignifiedquire @diasdavid Tests passes in CircleCI, Travis? Not so much... Everything is passing in local as well, so not sure what's going on. If you could please take a look, I would be forever grateful:
|
59f8d9f
to
6e51424
Compare
This commit adds publish/subscribe methods to js-ipfs-api. These changes requires special version of go-ipfs currently, with pub/sub activated.
6e51424
to
7d7e4c1
Compare
For future reference: travis is trash. I'm working from a branch in my repo and in a PR to this repo. I accidently pushed to upstream repo once, deleted the branch shortly after, and now Travis is trying to use the upstream branch instead of from my fork. So the Travis status here is from js-ipfs-api/feat-pubsub but this PR is actually from VictorBjelkholm/feat-pubsub. Just to keep in mind |
@diasdavid @dignifiedquire Finally, everything is passing and CR comments have been addressed. |
@victorbjelkholm do we want to merge this into |
@dignifiedquire good question. I think separate branch is good enough, and then release it under a tag, as you suggested. Question is, how do we keep it up to date with master? Manual merges? The branch already live in |
Sounds good to me. Lets wait for @diasdavid to wake up and ask him if he has any objections |
Let's do branch ( I still need review the code, but I can do it under the new branch, will CR once I get to integrate floodsub it in js-ipfs and think through the API as a whole for both lands (already had some discussions with @whyrusleeping on how to make sure we don't make the API very HTTP biased, as the HTTP should be invisible). This probably won't happen until after DEVCON. |
@diasdavid Sounds good, I'll leave this PR as-is for now then. |
can we namespace the api under floodsub? I'm worried that we might have to make a breaking API change in the future when we get tree forming, if we use pubsub from the start. |
Might be confusing if we mix (comparing to go-ipfs where it's under pubsub rather than floodsub). What you think? |
@victorbjelkholm true (I'm still trying to convince @whyrusleeping to namespace it under floodsub too :D) |
@diasdavid ah, haha, I see... Well, if you want me to move, I'll do that, I would agree that it could make it easier for the future. |
I have a rebased branch on my machine which I will push tomorrow. |
I'm refactoring this as the implementation here was always considered temp. The work happens here: https://github.com/haadcode/js-ipfs-api/blob/fix/pubsub/src/api/pubsub.js. There's still a lot to be done, but got it up to a fairly good point yesterday. I added a really nice test to make sure messages flow nicely: https://github.com/haadcode/js-ipfs-api/blob/fix/pubsub/test/ipfs-api/pubsub.spec.js#L157. Will keep you updated. |
@haadcode Is this the PR that I should be looking at and testing against the tests at interface-ipfs-core? |
@haadcode should we close this PR in favor of one coming from https://github.com/haadcode/js-ipfs-api ? //cc @victorbjelkholm |
Yeah, we can close this. |
Follow #470 |
First iteration on the publish/subscribe that is being introduced in go-ipfs
Missing things
Readme information aboutno necessary if we get go-ipfs-npm to use new binary insteadIPFS_EXEC
having to be pointed to go-ipfs running with pub/sub when running tests--discover
flag