view src/director/mail-host.h @ 18067:a7e830b9b967

director: Added support for backend cluster "tags". This allows using a single director ring for multiple backend clusters. By default everything has an empty tag. A passdb lookup can return "director_tag" field containing the wanted tag name. If there aren't any backend servers with the wanted tag, it's treated the same as if there aren't any backend servers available (= wait for 30 secs for a backend and then return temporary failure). Tags can be added to configuration by adding @tag suffix to IPs/hosts. For example: director_mail_servers = 10.0.0.100-10.0.0.110@name1 10.0.0.120@name2 "doveadm director add" can also add tags either with @tag suffix or with -t parameter. "doveadm director status user@domain" requires giving the user's correct tag with -t parameter or the results won't be correct (empty tag's results are shown). Tags can't currently be changed for an existing host without removing it first.
author Timo Sirainen <tss@iki.fi>
date Wed, 12 Nov 2014 06:58:37 +0200
parents b9df3d654710
children 0ee3e734249a
line wrap: on
line source

#ifndef MAIL_HOST_H
#define MAIL_HOST_H

#include "net.h"

struct mail_host_list;

struct mail_host {
	unsigned int user_count;
	unsigned int vhost_count;

	struct ip_addr ip;
	char *tag;
};
ARRAY_DEFINE_TYPE(mail_host, struct mail_host *);

struct mail_host *
mail_host_add_ip(struct mail_host_list *list, const struct ip_addr *ip,
		 const char *tag);
struct mail_host *
mail_host_lookup(struct mail_host_list *list, const struct ip_addr *ip);
struct mail_host *
mail_host_get_by_hash(struct mail_host_list *list, unsigned int hash,
		      const char *tag);

int mail_hosts_parse_and_add(struct mail_host_list *list,
			     const char *hosts_string);
void mail_host_set_tag(struct mail_host *host, const char *tag);
void mail_host_set_vhost_count(struct mail_host_list *list,
			       struct mail_host *host,
			       unsigned int vhost_count);
void mail_host_remove(struct mail_host_list *list, struct mail_host *host);

bool mail_hosts_have_usable(struct mail_host_list *list);
const ARRAY_TYPE(mail_host) *mail_hosts_get(struct mail_host_list *list);

struct mail_host_list *mail_hosts_init(bool consistent_hashing);
void mail_hosts_deinit(struct mail_host_list **list);

struct mail_host_list *mail_hosts_dup(const struct mail_host_list *src);

#endif