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: WithLocalPublication option to enable local only publishing on a topic #481

Merged
merged 2 commits into from
Jul 1, 2022

Conversation

Wondertan
Copy link
Contributor

An attempt to close #480

I know that it is better to discuss the solution first, but waiting is not fun while coding is and I am ok to redo that if we find a better solution.

We can also sneak here similar cases like an option to publish to the mesh only, so doing something like the code below during validation is not needed anymore:

if self == peer {
	return 
}

@@ -1143,7 +1144,9 @@ func (p *PubSub) checkSigningPolicy(msg *Message) error {
func (p *PubSub) publishMessage(msg *Message) {
p.tracer.DeliverMessage(msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we trace such local messages or not?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the tracer can see it's a local publication from the Local field -- but we might want to have some special casing in some tracers.
I think we should leave it as for now.

@Wondertan
Copy link
Contributor Author

@vyzo, gentle ping. Do you think this is a reasonable publish option? Should we proceed, or close the PR?

@vyzo
Copy link
Collaborator

vyzo commented Jun 28, 2022

well, i am a little conflicted about it.
Do we have a concrete use case? If so, yes.

@vyzo
Copy link
Collaborator

vyzo commented Jun 28, 2022

leave it open for now, i'd like to see others in the community chime in as well.
My concern is that i dont want people to use this as in process pubsub, there are specialized libs for that.
On the other hand, i can see it being useful in some cases, but i'd like to make that concrete.

@Wondertan
Copy link
Contributor Author

Wondertan commented Jun 28, 2022

Got your concern. We don't use PubSub for in-process pubsubing only, but we use it for pubsubing when msgs need to be both delivered to a local instance of some component and remote instances on peers. However, there is an edge case where the local instance is out of sync and only it needs to rcv msgs, s.t. network is not spammed with no more relevant msgs. And we would like to solve this case over the same code path and without the need to spawn another internal pubsubing mechanism specifically for the case. I can give you more details and even point to sources if you want.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

ok, fair enough.
Lets improve the documentation a bit and i will merge.

topic.go Outdated Show resolved Hide resolved
@Wondertan Wondertan requested a review from vyzo June 30, 2022 08:15
Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

thank you!

@@ -1143,7 +1144,9 @@ func (p *PubSub) checkSigningPolicy(msg *Message) error {
func (p *PubSub) publishMessage(msg *Message) {
p.tracer.DeliverMessage(msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the tracer can see it's a local publication from the Local field -- but we might want to have some special casing in some tracers.
I think we should leave it as for now.

@vyzo vyzo merged commit 96efa27 into libp2p:master Jul 1, 2022
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.

Option to enable local only publishing on a topic
2 participants