WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
BaseLoadBalancerHeuristic.h
1#pragma once
2
3#include "Import/WebFrameworkCore.h"
4
5namespace framework
6{
7 namespace load_balancer
8 {
12 class WEB_FRAMEWORK_API BaseLoadBalancerHeuristic
13 {
14 private:
15 std::string ip;
16 std::string port;
17 bool useHTTPS;
18
19 public:
20 BaseLoadBalancerHeuristic(std::string_view ip, std::string_view port, bool useHTTPS);
21
26 virtual uint64_t operator ()() const = 0;
27
31 virtual void onStart();
32
36 virtual void onEnd();
37
42 const std::string& getIp() const;
43
48 const std::string& getPort() const;
49
54 bool getUseHTTPS() const;
55
56 virtual ~BaseLoadBalancerHeuristic() = default;
57 };
58
59 using createHeuristicFunction = void* (*)(std::string_view ip, std::string_view port, bool useHTTPS);
60 }
61}
62
63#ifdef __LINUX__
68#define DECLARE_HEURISTIC(subclassName) extern "C" __attribute__((visibility("default"))) void* create##subclassName##Heuristic(std::string_view ip, std::string_view port, bool useHTTPS) \
69{ \
70 return new subclassName(ip, port, useHTTPS); \
71}
72#else
77#define DECLARE_HEURISTIC(subclassName) extern "C" __declspec(dllexport) void* create##subclassName##Heuristic(std::string_view ip, std::string_view port, bool useHTTPS) \
78{ \
79 return new subclassName(ip, port, useHTTPS); \
80}
81#endif