10#ifndef ZYPP_MEDIA_PROVIDE_WORKER_H_INCLUDED
11#define ZYPP_MEDIA_PROVIDE_WORKER_H_INCLUDED
13#include <zypp-core/zyppng/base/Base>
14#include <zypp-core/zyppng/base/EventLoop>
15#include <zypp-core/zyppng/base/Timer>
16#include <zypp-core/zyppng/io/AsyncDataSource>
17#include <zypp-core/zyppng/rpc/MessageStream>
18#include <zypp-core/zyppng/pipelines/Expected>
19#include <zypp-proto/media/provider.pb.h>
22#include <zypp-media/ng/HeaderValueMap>
23#include <zypp-media/MediaException>
24#include <zypp-media/Mount>
81 expected<void>
run (
int recv = STDIN_FILENO,
int send = STDOUT_FILENO );
98 MediaChangeRes requestMediaChange (
const uint32_t
id,
const std::string &label,
const int32_t mediaNr,
const std::vector<std::string> &devices,
const std::optional<std::string> &desc = {} );
107 expected<AuthInfo>
requireAuthorization (
const uint32_t
id,
const zypp::Url &url,
const std::string &lastTriedUsername =
"",
const int64_t lastTimestamp = -1,
const std::map<std::string, std::string> &extraFields = {} );
120 virtual void cancel (
const std::deque<ProvideWorkerItemRef>::iterator &request ) = 0;
152 void provideFailed (
const uint32_t
id,
const uint code,
const std::string &reason,
const bool transient,
const HeaderValueMap extra = {} );
187 void readFdClosed ( uint, AsyncDataSource::ChannelCloseReason );
202 EventLoop::Ptr
_loop = EventLoop::create();
Base class for Exception.
ProvideWorkerItem(ProvideMessage &&spec)
std::string_view _workerName
void detachSuccess(const uint32_t id)
virtual void immediateShutdown()
std::deque< ProvideWorkerItemRef > _pendingProvides
void handleSingleMessage(const ProvideMessage &provide)
MediaChangeRes requestMediaChange(const uint32_t id, const std::string &label, const int32_t mediaNr, const std::vector< std::string > &devices, const std::optional< std::string > &desc={})
AsyncDataSource & controlIO()
void messageLoop(Timer &)
expected< void > executeHandshake()
AsyncDataSource::Ptr _controlIO
void onInvalidMessageReceived()
void provideStart(const uint32_t id, const zypp::Url &url, const zypp::Pathname &localFile, const zypp::Pathname &stagingFile={})
virtual void cancel(const std::deque< ProvideWorkerItemRef >::iterator &request)=0
Configuration _workerConf
std::deque< ProvideMessage > _pendingMessages
void writeFdClosed(AsyncDataSource::ChannelCloseReason)
Timer::Ptr _delayedShutdown
void attachSuccess(const uint32_t id)
void maybeDelayedShutdown()
void provideSuccess(const uint32_t id, bool cacheHit, const zypp::Pathname &localFile, const HeaderValueMap extra={})
RpcMessageStream::Ptr messageStream() const
RpcMessageStream::Ptr _stream
ProvideNotificatioMode provNotificationMode() const
expected< void > run(int recv=STDIN_FILENO, int send=STDOUT_FILENO)
virtual ProvideWorkerItemRef makeItem(ProvideMessage &&spec)
void setProvNotificationMode(const ProvideNotificatioMode &provNotificationMode)
virtual expected< WorkerCaps > initialize(const Configuration &conf)=0
void readFdClosed(uint, AsyncDataSource::ChannelCloseReason)
void pushSingleMessage(const RpcMessage &msg)
void provideFailed(const uint32_t id, const uint code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
std::deque< ProvideWorkerItemRef > & requestQueue()
ProvideNotificatioMode _provNotificationMode
expected< ProvideMessage > parseReceivedMessage(const RpcMessage &m)
bool _inControllerRequest
expected< AuthInfo > requireAuthorization(const uint32_t id, const zypp::Url &url, const std::string &lastTriedUsername="", const int64_t lastTimestamp=-1, const std::map< std::string, std::string > &extraFields={})
void invalidMessageReceived(std::exception_ptr p)
void redirect(const uint32_t id, const zypp::Url &url, const zypp::Pathname &newPath)
expected< ProvideMessage > sendAndWaitForResponse(const ProvideMessage &request, const std::vector< uint > &responseCodes)
std::exception_ptr _fatalError
ZYPP_FWD_DECL_TYPE_WITH_REFS(DeviceDriver)
zypp::proto::Envelope Message
zypp::proto::Configuration Configuration
zypp::proto::Capabilities WorkerCaps
int64_t last_auth_timestamp
std::map< std::string, std::string > extraKeys