Skip to content

Connection loss management #125

@GuillaumeDua

Description

@GuillaumeDua

Idea :
zk::connection should provide a way to reconnect after a connection is loss,
as well as an atomic state

Considering the following example :

zk::connection con = zk::connection::connection("zk://addr:port/?opts");

// somewhere else ...

switch (con->state())
{  // handle some connection loss cases
   case zk::state::closed: [[fallthrough]];
   case zk::state::expired_session:
   {
	reset_connection(); // smthg like `con = zk::connection::connection("zk://addr:port/?opts");`
	break;
   }
   default:
	break;
}

In the sample above, the issue is the switch/case is error-prone, as erasing con content may result in invalid con->state() read in a concurrent context.
This force the user to create some blocking operation using memory barriers and perhaps condition_variales,
to ensure no wrong states are evaluated during connection reset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions