Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

http: embed http server in both meta and replica #139

Merged
merged 30 commits into from
Aug 13, 2018
Merged

http: embed http server in both meta and replica #139

merged 30 commits into from
Aug 13, 2018

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Jul 17, 2018

This PR involves rewrite of the original HTTP message parser and implementation of a simple http service framework. Note that before this PR, rDSN does actually not support HTTP.

The old http parser suppose the user always sending request like:

http http://127.0.0.1:34601/DSF_THRIFT_JSON/0/RPC_CLI_CLI_CALL

which is not a humanable way to use on browser.

On the current design, user can simply access the url path which is registered by a valid http_sevice.

http http://127.0.0.1:34601/ => root_http_service
http http://127.0.0.1:34601/threads => threads_http_service::default_handler
http http://127.0.0.1:34601/pprof/heap => profile_http_service::heap
http http://127.0.0.1:34601/pprof/profile => profile_http_service::profile

This PR effects little on the other modules of rDSN. It creates a http server for both the meta server and replica sever (not for collector). Tasks of http rpc are handled via rpc_code RPC_HTTP_SERVICE:

DEFINE_TASK_CODE_RPC(RPC_HTTP_SERVICE, TASK_PRIORITY_LOW, THREAD_POOL_DEFAULT);

Related issues

Results:

➜  http http://127.0.0.1:34601        
HTTP/1.1 200 OK
Content-Length: 11
Content-Type: text/plain

hello world

image

neverchanje and others added 24 commits July 14, 2018 00:13
We don't need factory2, the only place use it is `network::get_message_parser_info`.

```
➜  rdsn git:(master) ✗ ag factory2
src/core/core/message_parser.cpp
174:                                              message_parser::factory2 f2,
184:    info.factory2 = f2;

src/core/core/tool_api.cpp
211:                                 message_parser::factory2 f2,

src/core/core/network.cpp
465:std::pair<message_parser::factory2, size_t>
470:        pinfo.factory2, "message parser '%s' not registerd or invalid!", hdr_format.to_string());
471:    return std::make_pair(pinfo.factory2, pinfo.parser_size);

src/core/core/message_parser_manager.h
47:            : fmt(NET_HDR_INVALID), factory(nullptr), factory2(nullptr), parser_size(0)
53:        message_parser::factory2 factory2;
64:                          message_parser::factory2 f2,

include/dsn/tool_api.h
167:                                         message_parser::factory2 f2,

include/dsn/tool-api/network.h
134:    DSN_API std::pair<message_parser::factory2, size_t>

include/dsn/tool-api/message_parser.h
98:    typedef message_parser *(*factory2)(void *);
```

However there's nowhere calling this function

```
➜  rdsn git:(master) ✗ ag get_message_parser_info
src/core/core/network.cpp
466:network::get_message_parser_info(network_header_format hdr_format)

include/dsn/tool-api/network.h
135:    get_message_parser_info(network_header_format hdr_format);
```

Thus I removed it to simplify the design.
# Conflicts:
#	include/dsn/utility/blob.h
#	src/dist/replication/lib/replication_service_app.cpp
@neverchanje neverchanje requested review from shengofsun and qinzuoyan and removed request for qinzuoyan and shengofsun July 18, 2018 08:01
@neverchanje neverchanje requested review from shengofsun and qinzuoyan and removed request for shengofsun July 19, 2018 05:45
@neverchanje neverchanje mentioned this pull request Jul 20, 2018
shengofsun
shengofsun previously approved these changes Aug 10, 2018
@@ -67,7 +67,11 @@ struct fast_code

typedef struct message_header
{
// For thrift protocol this is "THRT".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THFT

@qinzuoyan qinzuoyan merged commit 89edcc6 into master Aug 13, 2018
@qinzuoyan qinzuoyan deleted the http branch August 21, 2018 03:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants