Skip to content

Allow setting the timeout on every Call type #643

@ufoscout

Description

@ufoscout

The code panics when changing the timeout of a call created using Call::unbounded_wait.
However, this doesn't make much sense, as both bounded and unbounded calls are represented by the same struct, with the only difference being an optional timeout.

In my use case, for instance, I have a service that receives a default Call instance and, only in specific cases, needs to set a timeout. Currently, this simple scenario is impossible to implement because there's no way to know if setting the timeout will cause a panic.

I’d propose removing the change_timeout() function and instead adding a simpler and more ergonomic alternative, such as:

    pub fn with_timeout(mut self, timeout_seconds: Option<u32>) -> Self {
        self.timeout_seconds = timeout_seconds;
        self
    }

Otherwise, please provide different structs for bounded and unbounded calls, so instead of a runtime panic, we can check at compile time whether a timeout can be set. But, at that point, please also add a way to convert from one type to the other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions