Skip to content

Commit

Permalink
Black and clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker committed Sep 28, 2020
1 parent 1260ff8 commit 5fb0033
Show file tree
Hide file tree
Showing 131 changed files with 13,052 additions and 11,182 deletions.
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
BasedOnStyle: Mozilla

---
Language: Cpp

# Avoid excessive linebreaks on function definitions
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None

IndentWidth: 4
DerivePointerAlignment: false
---
15 changes: 15 additions & 0 deletions bin/run_clang_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

# Find all .h or .cpp files we want to format
FILES=$(find . \( -name "*.h" -o -name "*.cpp" -o -name "*.c" \) \
-not -path "./build/*" \
-not -path "./third-party/*")

for f in $FILES
do
echo "Format $f"
clang-format-10 -i $f
done

11 changes: 6 additions & 5 deletions examples/hello_world.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <faabric/util/logging.h>

#include <faabric/executor/FaabricMain.h>
#include <faabric/endpoint/FaabricEndpoint.h>
#include <faabric/executor/FaabricMain.h>

using namespace faabric::executor;

FAABRIC_EXECUTOR() {
FAABRIC_EXECUTOR()
{
auto logger = faabric::util::getLogger();

logger->info("Hello world!");
Expand All @@ -14,9 +15,10 @@ FAABRIC_EXECUTOR() {
return true;
}

int main() {
int main()
{
faabric::util::initLogging();
const std::shared_ptr<spdlog::logger> &logger = faabric::util::getLogger();
const std::shared_ptr<spdlog::logger>& logger = faabric::util::getLogger();

// Start the worker pool
logger->info("Starting faaslet pool in the background");
Expand All @@ -34,4 +36,3 @@ int main() {

return EXIT_SUCCESS;
}

27 changes: 14 additions & 13 deletions include/faabric/endpoint/Endpoint.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#pragma once

#include <pistache/http.h>
#include <pistache/endpoint.h>
#include <faabric/util/config.h>
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <proto/faabric.pb.h>


namespace faabric::endpoint {
class Endpoint {
public:
Endpoint() = default;
class Endpoint
{
public:
Endpoint() = default;

Endpoint(int port, int threadCount);

Endpoint(int port, int threadCount);
void start();

void start();
virtual std::shared_ptr<Pistache::Http::Handler> getHandler() = 0;

virtual std::shared_ptr<Pistache::Http::Handler> getHandler() = 0;
private:
int port = faabric::util::getSystemConfig().endpointPort;
int threadCount = faabric::util::getSystemConfig().endpointNumThreads;
};
private:
int port = faabric::util::getSystemConfig().endpointPort;
int threadCount = faabric::util::getSystemConfig().endpointNumThreads;
};
}
13 changes: 7 additions & 6 deletions include/faabric/endpoint/FaabricEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
#include <faabric/util/config.h>

namespace faabric::endpoint {
class FaabricEndpoint : public Endpoint {
public:
FaabricEndpoint();
class FaabricEndpoint : public Endpoint
{
public:
FaabricEndpoint();

FaabricEndpoint(int port, int threadCount);
FaabricEndpoint(int port, int threadCount);

std::shared_ptr<Pistache::Http::Handler> getHandler() override;
};
std::shared_ptr<Pistache::Http::Handler> getHandler() override;
};
}
21 changes: 12 additions & 9 deletions include/faabric/endpoint/FaabricEndpointHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
#include <proto/faabric.pb.h>

namespace faabric::endpoint {
class FaabricEndpointHandler : public Pistache::Http::Handler {
public:
HTTP_PROTOTYPE(FaabricEndpointHandler)
class FaabricEndpointHandler : public Pistache::Http::Handler
{
public:
HTTP_PROTOTYPE(FaabricEndpointHandler)

void onTimeout(const Pistache::Http::Request &request, Pistache::Http::ResponseWriter writer) override;
void onTimeout(const Pistache::Http::Request& request,
Pistache::Http::ResponseWriter writer) override;

void onRequest(const Pistache::Http::Request &request, Pistache::Http::ResponseWriter response) override;
void onRequest(const Pistache::Http::Request& request,
Pistache::Http::ResponseWriter response) override;

std::string handleFunction(const std::string &requestStr);
std::string handleFunction(const std::string& requestStr);

private:
std::string executeFunction(faabric::Message &msg);
};
private:
std::string executeFunction(faabric::Message& msg);
};
}
12 changes: 5 additions & 7 deletions include/faabric/endpoint/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ using namespace faabric::endpoint;

void _entrypoint(int argc, char* argv[]);

#define FAABRIC_HTTP_MAIN(port) \
void main(int argc, char* argv[]) { \
\
} \
\
void _entrypoint(int argc, char* argv[]) {

#define FAABRIC_HTTP_MAIN(port) \
void main(int argc, char* argv[]) {} \
\
void _entrypoint(int argc, char* argv[]) \
{
61 changes: 34 additions & 27 deletions include/faabric/executor/FaabricExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,57 @@
#include <faabric/util/logging.h>

namespace faabric::executor {
class FaabricExecutor {
public:
explicit FaabricExecutor(int threadIdxIn);
class FaabricExecutor
{
public:
explicit FaabricExecutor(int threadIdxIn);

virtual ~FaabricExecutor() { }
virtual ~FaabricExecutor() {}

void bindToFunction(const faabric::Message &msg, bool force = false);
void bindToFunction(const faabric::Message& msg, bool force = false);

void run();
void run();

bool isBound();
bool isBound();

virtual std::string processNextMessage();
virtual std::string processNextMessage();

std::string executeCall(faabric::Message &call);
std::string executeCall(faabric::Message& call);

void finish();
void finish();

void flush();
void flush();

std::string id;
std::string id;

const int threadIdx;
protected:
virtual bool doExecute(faabric::Message &msg);
const int threadIdx;

virtual void postBind(const faabric::Message &msg, bool force);
protected:
virtual bool doExecute(faabric::Message& msg);

virtual void preFinishCall(faabric::Message &call, bool success, const std::string &errorMsg);
virtual void postBind(const faabric::Message& msg, bool force);

virtual void postFinish();
virtual void preFinishCall(faabric::Message& call,
bool success,
const std::string& errorMsg);

virtual void postFlush();
virtual void postFinish();

bool _isBound = false;
virtual void postFlush();

faabric::scheduler::Scheduler &scheduler;
bool _isBound = false;

std::shared_ptr<faabric::scheduler::InMemoryMessageQueue> currentQueue;
faabric::scheduler::Scheduler& scheduler;

int executionCount = 0;
private:
faabric::Message boundMessage;
std::shared_ptr<faabric::scheduler::InMemoryMessageQueue> currentQueue;

void finishCall(faabric::Message &msg, bool success, const std::string &errorMsg);
};
int executionCount = 0;

private:
faabric::Message boundMessage;

void finishCall(faabric::Message& msg,
bool success,
const std::string& errorMsg);
};
}
22 changes: 12 additions & 10 deletions include/faabric/executor/FaabricMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
#include <faabric/util/config.h>

namespace faabric::executor {
class FaabricMain {
public:
explicit FaabricMain(faabric::executor::FaabricPool &poolIn);
class FaabricMain
{
public:
explicit FaabricMain(faabric::executor::FaabricPool& poolIn);

void startBackground();
void startBackground();

void shutdown();
private:
faabric::util::SystemConfig &conf;
faabric::scheduler::Scheduler &scheduler;
void shutdown();

faabric::executor::FaabricPool &pool;
};
private:
faabric::util::SystemConfig& conf;
faabric::scheduler::Scheduler& scheduler;

faabric::executor::FaabricPool& pool;
};
}
Loading

0 comments on commit 5fb0033

Please sign in to comment.