def sync_state(leader: Optional[str], sync_standby: Optional[Collection[str]],
                   quorum: Optional[int]) -> Dict[str, Any]:
        """Build ``sync_state`` dictionary.

        :param leader: name of the leader node that manages ``/sync`` key.
        :param sync_standby: collection of currently known synchronous standby node names.
        :param quorum: if the node from :attr:`~SyncState.sync_standby` list is doing a leader race it should
                       see at least :attr:`~SyncState.quorum` other nodes from the
                       :attr:`~SyncState.sync_standby` + :attr:`~SyncState.leader` list

        :returns: dictionary that later could be serialized to JSON or saved directly to DCS.
        """
        return {'leader': leader, 'quorum': quorum,
                'sync_standby': ','.join(sorted(sync_standby)) if sync_standby else None}
Build ``sync_state`` dictionary.

        :param leader: name of the leader node that manages ``/sync`` key.
        :param sync_standby: collection of currently known synchronous standby node names.
        :param quorum: if the node from :attr:`~SyncState.sync_standby` list is doing a leader race it should
                       see at least :attr:`~SyncState.quorum` other nodes from the
                       :attr:`~SyncState.sync_standby` + :attr:`~SyncState.leader` list

        :returns: dictionary that later could be serialized to JSON or saved directly to DCS.
        
patroni/dcs/__init__.py