-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathabstract_server.h
99 lines (84 loc) · 1.69 KB
/
abstract_server.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/************************************************
* Copyright MaybeShewill-CV. All Rights Reserved.
* Author: MaybeShewill-CV
* File: base_server.h
* Date: 22-6-21
************************************************/
#ifndef MORTRED_MODEL_SERVER_BASESERVER_H
#define MORTRED_MODEL_SERVER_BASESERVER_H
#include <toml/toml.hpp>
#include <workflow/WFTask.h>
#include <workflow/WFHttpServer.h>
#include "common/status_code.h"
namespace jinq {
namespace server {
class BaseAiServer {
public:
/***
*
*/
virtual ~BaseAiServer() = default;
/***
* 构造函数
* @param config
*/
BaseAiServer() = default;
/***
*
* @param cfg
* @return
*/
virtual jinq::common::StatusCode init(const decltype(toml::parse(""))& cfg) = 0;
/***
*
* @param input
* @param output
* @return
*/
virtual void serve_process(WFHttpTask* task) = 0;
/***
*
* @return
*/
virtual bool is_successfully_initialized() const = 0;
/***
*
* @param port
* @return
*/
inline int start(unsigned short port) {
return _m_server->start(port);
};
/***
*
* @param host
* @param port
* @return
*/
inline int start(const char *host, unsigned short port) {
return _m_server->start(host, port);
};
/***
*
*/
inline void stop() {
return _m_server->stop();
};
/***
*
*/
inline void shutdown() {
_m_server->shutdown();
};
/***
*
*/
inline void wait_finish() {
_m_server->wait_finish();
}
protected:
std::unique_ptr<WFHttpServer> _m_server;
};
}
}
#endif //MORTRED_MODEL_SERVER_BASESERVER_H