-
Notifications
You must be signed in to change notification settings - Fork 42
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!: add support for sharded pubsub topics & remove support for named pubsub topics #1697
Conversation
size-limit report 📦
|
4a87601
to
ebbbf32
Compare
cc @LordGhostX re docs: waku-org/docs.waku.org#131 |
Adding static sharding support is a feature, not a |
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 a very important change and the PR also contains a pedantic renaming.
Do the renaming first in a different PR and let's have this PR focus on the functional change.
cc98b9c
to
ebbbf32
Compare
Fair point. Moving to draft and will rebase once #1703 is merged. |
f3c4b09
to
5e9c981
Compare
821da15
to
25964a8
Compare
25964a8
to
9c88102
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.
lgtm
450e0ba
to
fe81a26
Compare
a86bdc4
to
85500d3
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.
Approved but the APIs could be improved and more thought made on the boundaries between the various APIs.
packages/interfaces/src/message.ts
Outdated
import type { PubsubTopic } from "./misc.js"; | ||
|
||
export interface SingleTopicShardInfo extends Omit<ShardInfo, "indexList"> { |
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.
export interface SingleTopicShardInfo extends Omit<ShardInfo, "indexList"> { | |
export interface SingleTopicShardInfo extends Omit<ShardInfo, "indexList"> { |
Topic and Shard are redundant. It's a single shard info, which is also a single topic info.
The redundancy of information makes the interface name more complicated for no added value.
Also, you break the interface with ShardInfo
here as you removed the index list.
Considering you only bring one property (cluster
) over from ShardInfo
, I am not sure to understand the point of extending from ShardInfo
. Just create a new type.
Re-using the type is only useful if you want a function that accept ShardInfo
to also accept SingleTopicShardInfo
. But because of the Omit
, you are not getting that.
If that's what you want, then try to override the indexList
with a tuple type to specify that it's an array with only one number
.
If you don't need interface compatibility between ShardInfo
and SingleTopicShardInfo
, then don't make the latter extend the former, just redefine a new interface.
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 see your point that since the two interfaces don't share a lot of properties (have just one in common of the two), thus it might make more sense to define a new interface.
Omit
was used because I wanted to showcase the link between the two types, while keeping one property. When is a case you think Omit
would make sense for a usecase like this here? Perhaps when there are more number of properties?
--
Addressed redefining the interface here: 5dd508c
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.
IMO Omit
makes sense when you want common API to be used. e.g.
interface A {
foo: number
bar: string
}
interface B extends <A, "foo"> {}
function func (alpha: Partial<A>) {
...
}
// this works
func(B)
I see your point re code documentation and duplication but with so very few properties, I think it makes it less readable.
return new Encoder( | ||
contentTopic, | ||
ephemeral, | ||
pubsubTopicShardInfo?.index |
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.
why would the index not be defined? It's not optional on SingleTopicShardInfo
.
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.
maybe this is being extra cautious & is easily swappable with a simple check of pubsubTopicShardInfo
but this was just added as an extra check to ensure that if somebody force passes a string, or a structure that doesn't have index
, we fallback to using the DefaultPubsubTopic
also something @weboko wanted here: #1697 (comment)
happy to follow up with a change if you prefer
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.
actually updated this part of #1742
contentTopic, | ||
ephemeral, | ||
pubsubTopicShardInfo?.index | ||
? singleTopicShardInfoToPubsubTopic(pubsubTopicShardInfo) |
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.
Hopefully this goes away and the encoder does the automated conversion from content topic to pubsub topic cc @adklempner.
I think the encoder should do the conversion from shard info to pubsub topic too. The API should be reviewed.
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 the encoder should do the conversion from shard info to pubsub topic too. The API should be reviewed.
can you elaborate?
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.
my bad, API (createEncoder
) is looking ok actually. did not realized it was an internal API (new Encoder
).
This PR:
create${xyz}Node()
API to take inShardInfo
instead of aPubsubTopic
shardInfo
is not provided, it falls back to theDefaultPubsubTopic
createEncoder
andcreateDecoder
API to take inShardInfo
optionallyDefaultPubsubTopic
is usedfilter.createSubscription()
to take inSingleShardInfo
optionally instead of astring
DefaultPubsubTopic
is usedNotes
TODO: