69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include "lib/api/public/ServiceContext.h"
|
|
#include "lib/api/services/AlgoDefinitionService.server.pb.h"
|
|
#include "lib/utils/bts_no_copy.h"
|
|
#include "lib/persistence/SqliteStore.h"
|
|
#include "lib/persistence/IStore.h"
|
|
#include "lib/api/public/ServiceContext.h"
|
|
#include "lib/api/services/OrderService.pb.h"
|
|
#include "lib/api/services/OrderService.client.pb.h"
|
|
#include "lib/utils/PBUtils.h"
|
|
#include "lib/utils/TimeStamp.h"
|
|
#include "lib/logging/logging.h"
|
|
#include "lib/utils/bts_assert.h"
|
|
|
|
#include <google/protobuf/util/time_util.h>
|
|
#include <boost/tokenizer.hpp>
|
|
#include <fmt/format.h>
|
|
#include <map>
|
|
#include <set>
|
|
#include <utility>
|
|
#include <string>
|
|
|
|
#define HIDE_REMOVED_DEFINITIONS
|
|
|
|
// aliases for verbose types
|
|
using ServiceContext = bts::api::ServiceContext;
|
|
using SqliteStore = bts::persistence::SqliteStore;
|
|
using IStore = bts::persistence::IStore;
|
|
using Row = bts::api::orderman::algo::AlgoDefinitionRecord;
|
|
using RowMetadata = bts::api::orderman::algo::AlgoDefinitionRecordMetadata;
|
|
using UpdateRequest = bts::api::orderman::algo::AlgoDefinitionUpdateRequest;
|
|
using UpdateResponse = bts::api::orderman::algo::AlgoDefinitionUpdateResponse;
|
|
using RemoveRequest = bts::api::orderman::algo::AlgoDefinitionRemoveRequest;
|
|
using RemoveResponse = bts::api::orderman::algo::AlgoDefinitionRemoveResponse;
|
|
template <typename T> using APIResponse = bts::api::Response<T>;
|
|
|
|
namespace bts {
|
|
namespace api {
|
|
namespace orderman {
|
|
namespace algo {
|
|
|
|
class AlgoDefinitionServiceServer : public AlgoDefinitionServiceBase
|
|
{
|
|
private:
|
|
struct PImpl;
|
|
struct ErrorMessageFormatter;
|
|
std::unique_ptr<PImpl> me;
|
|
public:
|
|
AlgoDefinitionServiceServer (bts::api::ServiceContext& context);
|
|
~AlgoDefinitionServiceServer ();
|
|
|
|
void save_algo_definition(const UpdateRequest& request, const APIResponse<UpdateResponse>& response) override;
|
|
void remove_algo_definition(const RemoveRequest &request, const APIResponse<RemoveResponse>& response) override;
|
|
|
|
private:
|
|
RowMetadata _mk_metadata(const uint32_t user_id);
|
|
// loads algos from the db and publises them
|
|
void _publish_all();
|
|
bool _publish_update(bool insert, const Row& row);
|
|
// template helpers
|
|
const Row* _find_row(const uint32_t key);
|
|
uint32_t _get_unused_key();
|
|
};
|
|
}
|
|
}
|
|
}
|
|
} |