view src/replication/replication-common.h @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents 10bcadab431c
children
line wrap: on
line source

#ifndef REPLICATION_COMMON_H
#define REPLICATION_COMMON_H

enum replication_priority {
	/* user is fully replicated, as far as we know */
	REPLICATION_PRIORITY_NONE = 0,
	/* flag changes, expunges, etc. */
	REPLICATION_PRIORITY_LOW,
	/* new emails */
	REPLICATION_PRIORITY_HIGH,
	/* synchronously wait for new emails to be replicated */
	REPLICATION_PRIORITY_SYNC
};

static inline const char *
replicator_priority_to_str(enum replication_priority priority)
{
	switch (priority) {
	case REPLICATION_PRIORITY_NONE:
		return "none";
	case REPLICATION_PRIORITY_LOW:
		return "low";
	case REPLICATION_PRIORITY_HIGH:
		return "high";
	case REPLICATION_PRIORITY_SYNC:
		return "sync";
	}
	i_unreached();
}

static inline int
replication_priority_parse(const char *str,
			   enum replication_priority *priority_r)
{
	if (strcmp(str, "none") == 0)
		*priority_r = REPLICATION_PRIORITY_NONE;
	else if (strcmp(str, "low") == 0)
		*priority_r = REPLICATION_PRIORITY_LOW;
	else if (strcmp(str, "high") == 0)
		*priority_r = REPLICATION_PRIORITY_HIGH;
	else if (strcmp(str, "sync") == 0)
		*priority_r = REPLICATION_PRIORITY_SYNC;
	else
		return -1;
	return 0;
}

#endif