backenddef (1668B)
1 #ifndef _BACKENDDEF_ 2 #define _BACKENDDEF_ 3 4 #include "sys/sys" 5 #include "error/error" 6 #include "profiler/profiler" 7 #include "backendcheck/backendcheck" 8 #include "ThreadsAndMutexes/mutex/mutex" 9 10 using namespace std; 11 12 class BackendDef { 13 public: 14 BackendDef(): 15 srv(""), prt(-1), max(0), host_match(""), url_match(""), 16 wt(1), backend_check() { 17 hostmatch(""); 18 urlmatch(""); 19 } 20 BackendDef(string s, string p, string m = "", string w = "1"); 21 22 void server(string s) { srv = s; } 23 string const &server() const { return (srv); } 24 25 void port (int p) { prt = p; } 26 int port() const { return (prt); } 27 28 unsigned maxconn() const { return (max); } 29 void maxconn (unsigned m) { max = m; } 30 31 unsigned weight() const { return wt; } 32 void weight (unsigned w); 33 unsigned adjustedweight() const { return min_wt + 34 max_wt - wt; } 35 36 void hostmatch(string const &s); 37 string const &hostmatch() const { return (host_match); } 38 regex_t const &hostregex() const { return (host_regex); } 39 40 void urlmatch(string const &u); 41 string const &urlmatch() const { return (url_match); } 42 regex_t const &urlregex() const { return (url_regex); } 43 44 BackendCheck const &backendcheck() { return backend_check; } 45 void backendcheck(BackendCheck const &b) { backend_check = b; } 46 47 private: 48 string srv; 49 int prt; 50 unsigned max; 51 string host_match; 52 regex_t host_regex; 53 string url_match; 54 regex_t url_regex; 55 unsigned wt; 56 static unsigned min_wt, max_wt; 57 static bool minmax_wt_set; 58 BackendCheck backend_check; 59 }; 60 61 #endif