Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
TaskManagerProvider.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
23#include "etlng/ExtractorInterface.hpp"
24#include "etlng/LoaderInterface.hpp"
25#include "etlng/MonitorInterface.hpp"
26#include "etlng/TaskManagerInterface.hpp"
27#include "etlng/TaskManagerProviderInterface.hpp"
28#include "etlng/impl/Scheduling.hpp"
29#include "etlng/impl/TaskManager.hpp"
30#include "util/async/AnyExecutionContext.hpp"
31
32#include <cstdint>
33#include <functional>
34#include <memory>
35#include <optional>
36#include <utility>
37
38namespace etlng::impl {
39
44 std::reference_wrapper<etl::NetworkValidatedLedgersInterface> ledgers_;
45 std::shared_ptr<ExtractorInterface> extractor_;
46 std::shared_ptr<LoaderInterface> loader_;
47
48public:
57 std::reference_wrapper<etl::NetworkValidatedLedgersInterface> ledgers,
58 std::shared_ptr<ExtractorInterface> extractor,
59 std::shared_ptr<LoaderInterface> loader
60 )
61 : ledgers_(ledgers), extractor_(std::move(extractor)), loader_(std::move(loader))
62 {
63 }
64
65 std::unique_ptr<TaskManagerInterface>
68 std::reference_wrapper<MonitorInterface> monitor,
69 uint32_t startSeq,
70 std::optional<uint32_t> finishSeq
71 ) override
72 {
73 auto scheduler = impl::makeScheduler(impl::ForwardScheduler{ledgers_, startSeq, finishSeq});
74 // TODO: add impl::BackfillScheduler{startSeq - 1, startSeq - ...},
75
76 return std::make_unique<TaskManager>(
77 std::move(ctx), std::move(scheduler), *extractor_, *loader_, monitor, startSeq
78 );
79 }
80};
81
82} // namespace etlng::impl
Definition Scheduling.hpp:43
Implementation of the TaskManagerProvider interface.
Definition TaskManagerProvider.hpp:43
TaskManagerProvider(std::reference_wrapper< etl::NetworkValidatedLedgersInterface > ledgers, std::shared_ptr< ExtractorInterface > extractor, std::shared_ptr< LoaderInterface > loader)
Constructor.
Definition TaskManagerProvider.hpp:56
std::unique_ptr< TaskManagerInterface > make(util::async::AnyExecutionContext ctx, std::reference_wrapper< MonitorInterface > monitor, uint32_t startSeq, std::optional< uint32_t > finishSeq) override
Make a task manager.
Definition TaskManagerProvider.hpp:66
A type-erased execution context.
Definition AnyExecutionContext.hpp:41
An interface for providing the Task Manager.
Definition TaskManagerProviderInterface.hpp:37