xref: /unit/src/nxt_upstream.c (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #include <nxt_main.h>
8 
9 
10 typedef struct {
11     void   (*peer_get)(nxt_upstream_peer_t *up);
12     void   (*peer_free)(nxt_upstream_peer_t *up);
13 } nxt_upstream_name_t;
14 
15 
16 static const nxt_upstream_name_t  nxt_upstream_names[] = {
17 
18     { "round_robin", &nxt_upstream_round_robin },
19 };
20 
21 
22 void
23 nxt_upstream_create(nxt_upstream_peer_t *up)
24 {
25     /* TODO: dynamic balancer add & lvlhsh */
26     nxt_upstream_names[0].create(up);
27 }
28 
29 
30 void
31 nxt_upstream_peer(nxt_upstream_peer_t *up)
32 {
33     nxt_upstream_t  *u;
34 
35     u = up->upstream;
36 
37     if (u != NULL) {
38         u->peer_get(up);
39         return;
40     }
41 
42     nxt_upstream_create(up);
43 }
44