rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

swarm/src/behaviour: Deprecate NetworkBehaviourEventProcess

Open mxinden opened this issue 2 years ago • 5 comments

Description

In preparation for https://github.com/libp2p/rust-libp2p/pull/2751.

Change checklist

  • [x] I have performed a self-review of my own code
  • [x] I have made corresponding changes to the documentation
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [x] A changelog entry has been made in the appropriate crates

mxinden avatar Jul 31 '22 10:07 mxinden

Change default for event_process to true instead of false. User that would like to keep using it would have to explicitly add #[event_process=false] rather than it being the default

I think there is a confusion here. Today, by default, event_process is false and thereby the derive macro uses the out_event mechanism instead of the NetworkBehaviourEventProcess mechanism. See https://github.com/libp2p/rust-libp2p/pull/2214.

https://github.com/libp2p/rust-libp2p/blob/eaf3f3a7fb4aba228ebd15366ab79b64cf37832c/swarm-derive/src/lib.rs#L73-L75

Am I missing something @elenaf9?

mxinden avatar Jul 31 '22 12:07 mxinden

Change default for event_process to true instead of false. User that would like to keep using it would have to explicitly add #[event_process=false] rather than it being the default

I think there is a confusion here. Today, by default, event_process is false and thereby the derive macro uses the out_event mechanism instead of the NetworkBehaviourEventProcess mechanism. See #2214.

https://github.com/libp2p/rust-libp2p/blob/eaf3f3a7fb4aba228ebd15366ab79b64cf37832c/swarm-derive/src/lib.rs#L73-L75

Am I missing something @elenaf9?

You are right, I mixed it up what event_process=false means. But since default event_process=false already means that out_event is used it makes it even easier. So to rephrase my idea above: Instead of just deprecating NetworkBehaviourEventProcess, in my opinion the first release should already include the changes in the proc macro (and the changes in our examples and other behaviours, so effectively everything from #2751), just that we don't remove the support for event_process = true and NetworkBehaviourEventProcess yet. For users that want to stick with the deprecated event_process nothing would change. The benefit would be that users that do want to switch can then already use the generated enum. Any reason why this would not make sense?

elenaf9 avatar Jul 31 '22 12:07 elenaf9

I think that is a really good idea actually!

thomaseizinger avatar Jul 31 '22 13:07 thomaseizinger

@elenaf9 @thomaseizinger with https://github.com/libp2p/rust-libp2p/pull/2792 merged, would you mind taking another look?

mxinden avatar Aug 10 '22 07:08 mxinden

One more thing: I think if we are deprecating NetworkBehaviourEventProcess we should also already change our examples & tests to not use it anymore (examples/distributed-key-value-store.rs, examples/chat.rs, ...). Can be done in a separate PR, but imo it should be part of the same release.

elenaf9 avatar Aug 11 '22 07:08 elenaf9

One more thing: I think if we are deprecating NetworkBehaviourEventProcess we should also already change our examples & tests to not use it anymore (examples/distributed-key-value-store.rs, examples/chat.rs, ...). Can be done in a separate PR, but imo it should be part of the same release.

That is a good point. https://github.com/libp2p/rust-libp2p/pull/2784/commits/0f3ef691ff1499c3fb85f96c21a26b44fea28e23 does the change.

mxinden avatar Aug 12 '22 08:08 mxinden

As far as I can tell all comments are addressed and everyone approved. Thus I am merging here. Happy to do any follow-ups in case I missed something.

As always, thanks for all the input @elenaf9 and @thomaseizinger!

mxinden avatar Aug 16 '22 04:08 mxinden