2021-11-16 16:39:38 +08:00
|
|
|
// Copyright 2021, Beeri 15. All rights reserved.
|
|
|
|
// Author: Roman Gershman (romange@gmail.com)
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "base/varz_value.h"
|
|
|
|
#include "util/http/http_handler.h"
|
2021-11-17 18:51:47 +08:00
|
|
|
#include "server/engine_shard_set.h"
|
2021-11-16 16:39:38 +08:00
|
|
|
|
|
|
|
namespace util {
|
|
|
|
class AcceptServer;
|
|
|
|
} // namespace util
|
|
|
|
|
|
|
|
namespace dfly {
|
|
|
|
|
|
|
|
class Service {
|
|
|
|
public:
|
|
|
|
using error_code = std::error_code;
|
|
|
|
|
|
|
|
explicit Service(util::ProactorPool* pp);
|
|
|
|
~Service();
|
|
|
|
|
|
|
|
void RegisterHttp(util::HttpListenerBase* listener);
|
|
|
|
|
|
|
|
void Init(util::AcceptServer* acceptor);
|
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
2021-11-17 18:51:47 +08:00
|
|
|
uint32_t shard_count() const {
|
|
|
|
return shard_set_.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
EngineShardSet& shard_set() {
|
|
|
|
return shard_set_;
|
|
|
|
}
|
|
|
|
|
2021-11-16 16:39:38 +08:00
|
|
|
util::ProactorPool& proactor_pool() {
|
|
|
|
return pp_;
|
|
|
|
}
|
|
|
|
|
2021-11-17 18:51:47 +08:00
|
|
|
void Set(std::string_view key, std::string_view val);
|
2021-11-16 16:39:38 +08:00
|
|
|
private:
|
2021-11-17 18:51:47 +08:00
|
|
|
|
2021-11-16 16:39:38 +08:00
|
|
|
base::VarzValue::Map GetVarzStats();
|
|
|
|
|
2021-11-17 18:51:47 +08:00
|
|
|
EngineShardSet shard_set_;
|
2021-11-16 16:39:38 +08:00
|
|
|
util::ProactorPool& pp_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dfly
|