summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_upstream.c
blob: e1615120f31a21d7c00541d12f65e154f8496e33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#include <nxt_main.h>


typedef struct {
    void   (*peer_get)(nxt_upstream_peer_t *up);
    void   (*peer_free)(nxt_upstream_peer_t *up);
} nxt_upstream_name_t;


static const nxt_upstream_name_t  nxt_upstream_names[] = {

    { "round_robin", &nxt_upstream_round_robin },
};


void
nxt_upstream_create(nxt_upstream_peer_t *up)
{
    /* TODO: dynamic balancer add & lvlhsh */
    nxt_upstream_names[0].create(up);
}


void
nxt_upstream_peer(nxt_upstream_peer_t *up)
{
    nxt_upstream_t  *u;

    u = up->upstream;

    if (u != NULL) {
        u->peer_get(up);
        return;
    }

    nxt_upstream_create(up);
}