remote_pool.h
author Tero Marttila <terom@fixme.fi>
Fri, 29 Aug 2008 23:31:17 +0300
changeset 48 1c67f512779b
parent 26 6d615203d963
permissions -rw-r--r--
fix doc tpyos, rename some enums, fix printf format len for non-zero terminated strings (hg status), pass args to memcache_cmd_format_header via memcache_req_*, handle zero-length STORE requests, memcache_req is_buf_ours + free, other function name typos (keymemcache_req_key), fix req state behaviour re *_DATA_* for STORE requests and FETCH/END, better memcache_server connpool events/management, modular memcache_test with a working benchmark. This is a long commit message.
#ifndef REMOTE_POOL_H
#define REMOTE_POOL_H

#include "remote_node.h"

// maximum number of nodes in a remote pool
#define REMOTE_POOL_MAX 8

// how many bytes long each line in a pool file may be
#define POOL_FILE_LINE_LENGTH 512

struct remote_pool {
    // the remote_nodes are part of this struct
    struct remote_node nodes[REMOTE_POOL_MAX];
};

/*
 * Initialize the given remote_pool
 */
void remote_pool_init (struct remote_pool *pool_info);

/*
 * Add a remote_node to the pool, see remote_node_init
 */
int remote_pool_add (struct remote_pool *pool_info, const char *addr_spec);

/*
 * Adds remote_nodes to the pool based on the contents of the given file
 *
 * The format for the file is a set of "<hostname>:<portname>" lines, see
 * parse_hostport in common.h. Blank lines are skipped, and any comments
 * prefixed with a '#' char is ignored. Whitespace inside lines is also
 * ignored.
 *
 * Returns however many nodes were added (possibly zero), or -1 on error
 */
int remote_pool_load (struct remote_pool *pool_info, const char *filename);

/*
 * Choose a remote_node from the pool
 *
 * Attempts to pick the one that's least busy
 */
struct remote_node *remote_pool_get (struct remote_pool *pool_info);

/*
 * Get the number of remote render nodes in this pool
 */
int remote_pool_size (struct remote_pool *pool_info);

#endif /* REMOTE_POOL_H */