forked from faasm/faabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A large number of performance changes (related to faasm#156)
- Loading branch information
1 parent
8a70efd
commit a03d5fe
Showing
32 changed files
with
907 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,53 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
#include <faabric/proto/faabric.pb.h> | ||
#include <faabric/util/asio.h> | ||
#include <faabric/util/config.h> | ||
#include <pistache/endpoint.h> | ||
#include <pistache/http.h> | ||
|
||
namespace faabric::endpoint { | ||
namespace detail { | ||
struct EndpointState; | ||
} | ||
|
||
struct HttpRequestContext | ||
{ | ||
asio::io_context& ioc; | ||
asio::any_io_executor executor; | ||
std::function<void(faabric::util::BeastHttpResponse&&)> sendFunction; | ||
}; | ||
|
||
class HttpRequestHandler | ||
{ | ||
public: | ||
virtual void onRequest(HttpRequestContext&& ctx, | ||
faabric::util::BeastHttpRequest&& request) = 0; | ||
}; | ||
|
||
class Endpoint | ||
{ | ||
public: | ||
Endpoint(); | ||
Endpoint() = delete; | ||
Endpoint(const Endpoint&) = delete; | ||
Endpoint(Endpoint&&) = delete; | ||
Endpoint& operator=(const Endpoint&) = delete; | ||
Endpoint& operator=(Endpoint&&) = delete; | ||
virtual ~Endpoint(); | ||
|
||
Endpoint(int port, int threadCount); | ||
Endpoint(int port, | ||
int threadCount, | ||
std::shared_ptr<HttpRequestHandler> requestHandlerIn); | ||
|
||
void start(bool awaitSignal = true); | ||
|
||
void stop(); | ||
|
||
virtual std::shared_ptr<Pistache::Http::Handler> getHandler() = 0; | ||
|
||
private: | ||
int port = faabric::util::getSystemConfig().endpointPort; | ||
int threadCount = faabric::util::getSystemConfig().endpointNumThreads; | ||
|
||
Pistache::Http::Endpoint httpEndpoint; | ||
int port; | ||
int threadCount; | ||
std::unique_ptr<detail::EndpointState> state; | ||
std::shared_ptr<HttpRequestHandler> requestHandler; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
#pragma once | ||
|
||
#include <faabric/endpoint/Endpoint.h> | ||
#include <faabric/proto/faabric.pb.h> | ||
#include <pistache/http.h> | ||
|
||
namespace faabric::endpoint { | ||
class FaabricEndpointHandler : public Pistache::Http::Handler | ||
class FaabricEndpointHandler final | ||
: public HttpRequestHandler | ||
, public std::enable_shared_from_this<FaabricEndpointHandler> | ||
{ | ||
public: | ||
HTTP_PROTOTYPE(FaabricEndpointHandler) | ||
|
||
void onTimeout(const Pistache::Http::Request& request, | ||
Pistache::Http::ResponseWriter writer) override; | ||
|
||
void onRequest(const Pistache::Http::Request& request, | ||
Pistache::Http::ResponseWriter response) override; | ||
|
||
std::pair<int, std::string> handleFunction(const std::string& requestStr); | ||
void onRequest(HttpRequestContext&& ctx, | ||
faabric::util::BeastHttpRequest&& request) override; | ||
|
||
private: | ||
std::pair<int, std::string> executeFunction(faabric::Message& msg); | ||
void executeFunction(HttpRequestContext&& ctx, | ||
faabric::util::BeastHttpResponse&& partialResponse, | ||
faabric::Message&& msg); | ||
|
||
void onFunctionResult(HttpRequestContext&& ctx, | ||
faabric::util::BeastHttpResponse&& partialResponse, | ||
faabric::Message& msg); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ enum FunctionCalls | |
Unregister = 3, | ||
GetResources = 4, | ||
SetThreadResult = 5, | ||
DirectResult = 6, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <boost/asio.hpp> | ||
#include <boost/beast/core.hpp> | ||
#include <boost/beast/http.hpp> | ||
#include <boost/beast/version.hpp> | ||
|
||
namespace asio = boost::asio; | ||
namespace beast = boost::beast; | ||
|
||
namespace faabric::util { | ||
using BeastHttpRequest = beast::http::request<beast::http::string_body>; | ||
using BeastHttpResponse = beast::http::response<beast::http::string_body>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
|
||
faabric_lib(endpoint | ||
Endpoint.cpp | ||
FaabricEndpoint.cpp | ||
FaabricEndpointHandler.cpp | ||
) | ||
|
||
|
Oops, something went wrong.