zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

add 'open' function without parameters for create session with default config

Open milyin opened this issue 1 year ago • 7 comments

Describe the feature

@kydos wrote "I think we should have an overloaded zenoh::open() that does not take the config. Having to create a config just to pass it seems an avoidable step."

milyin avatar Mar 10 '24 13:03 milyin

This is possible in C/C++, but for Rust the name should be different. This could be Session::default() for example. BTW: why it was decided to have just standalone open function, not the Session::open or Session::new ?

milyin avatar Mar 10 '24 13:03 milyin

This could be implemented this way:

let s = zenoh::open().wait()?;
...
let c = Config::from_file(file)?;
let s = zenoh::open().config(c).wait()?;

I.e. make open function without parameters and add .config() setter to OpenBuilder

@Mallets what do you think?

milyin avatar May 30 '24 15:05 milyin

The proposal looks good to me and makes the API more coherent.

Mallets avatar Jun 10 '24 08:06 Mallets

On my side, I'm against, because I don't think we want the user to use default config. I don't know our user use cases at all, but is there some users that are really using default config in production?

About coherence, I don't think having configuration as a required parameter is an inconsistency. Other methods also have required parameter, like keyexpr for declare_subscriber. The question is again, do we want to encourage user to use the default configuration?

wyfo avatar Jun 11 '24 08:06 wyfo

Maybe scout could be a better candidate for this kind signature change?

wyfo avatar Jun 17 '24 20:06 wyfo

According to latest discussion, zenoh::open() will keep accepting Config as of Today. @milyin I believe we can close the issue.

Mallets avatar Jun 25 '24 09:06 Mallets

@Mallets Is scout a better candidate for a signature rework?

wyfo avatar Jun 25 '24 09:06 wyfo