libzypp 17.37.10

zyppng::worker::ProvideWorker Class Referenceabstract

`#include <zypp-media/ng/worker/provideworker.h>`

Inheritance diagram for zyppng::worker::ProvideWorker:

## Public Types
enum | ProvideNotificatioMode { ONLY_NEW_PROVIDES , QUEUE_NOT_EMTPY }
enum | MediaChangeRes { SUCCESS , ABORT , SKIP }
Public Types inherited from zyppng::Base
using | Ptr = std::shared_ptr<Base>
using | WeakPtr = std::weak_ptr<Base>

## Public Member Functions
| ProvideWorker (std::string_view workerName)
virtual | ~ProvideWorker ()
StompFrameStreamRef | messageStream () const
expected< void > | run (int recv=STDIN_FILENO, int send=STDOUT_FILENO)
std::deque< ProvideWorkerItemRef > & | requestQueue ()
virtual void | immediateShutdown ()
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={})
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={})
ProvideNotificatioMode | provNotificationMode () const
void | setProvNotificationMode (const ProvideNotificatioMode &provNotificationMode)
Public Member Functions inherited from zyppng::Base
| Base ()
virtual | ~Base ()
WeakPtr | parent () const
void | addChild (const Base::Ptr &child)
void | removeChild (const Ptr &child)
const std::unordered_set< Ptr > & | children () const
std::thread::id | threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > | findChildren () const
template<typename T>
std::shared_ptr< T > | shared_this () const
template<typename T>
std::shared_ptr< T > | shared_this ()
template<typename T>
std::weak_ptr< T > | weak_this () const
template<typename T>
std::weak_ptr< T > | weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Protected Member Functions
virtual void | initLog ()
virtual expected< WorkerCaps > | initialize (const Configuration &conf)=0
virtual void | provide ()=0
virtual void | cancel (const std::deque< ProvideWorkerItemRef >::iterator &request)=0
virtual ProvideWorkerItemRef | makeItem (ProvideMessage &&spec)
void | provideStart (const uint32_t id, const zypp::Url &url, const zypp::Pathname &localFile, const zypp::Pathname &stagingFile={})
void | provideSuccess (const uint32_t id, bool cacheHit, const zypp::Pathname &localFile, const HeaderValueMap extra={})
void | provideFailed (const uint32_t id, const ProvideMessage::Code code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
void | provideFailed (const uint32_t id, const ProvideMessage::Code code, const bool transient, const zypp::Exception &e)
void | attachSuccess (const uint32_t id, const std::optional< std::string > &localMountPoint={})
void | detachSuccess (const uint32_t id)
void | redirect (const uint32_t id, const zypp::Url &url, const zypp::Pathname &newPath)
AsyncDataSource & | controlIO ()
Protected Member Functions inherited from zyppng::Base
| Base (BasePrivate &dd)

## Private Member Functions
expected< void > | executeHandshake ()
void | maybeDelayedShutdown ()
void | messageLoop (Timer &)
void | readFdClosed (uint, AsyncDataSource::ChannelCloseReason)
void | writeFdClosed (AsyncDataSource::ChannelCloseReason)
void | messageReceived ()
void | onInvalidMessageReceived ()
void | invalidMessageReceived (std::exception_ptr p)
void | handleSingleMessage (const ProvideMessage &provide)
void | pushSingleMessage (const zypp::PluginFrame &msg)
expected< ProvideMessage > | sendAndWaitForResponse (const ProvideMessage &request, const std::vector< uint > &responseCodes)
expected< ProvideMessage > | parseReceivedMessage (const zypp::PluginFrame &m)

## Private Attributes
ProvideNotificatioMode | _provNotificationMode = QUEUE_NOT_EMTPY
bool | _inControllerRequest = false
bool | _isRunning = false
std::string_view | _workerName
EventLoop::Ptr | _loop = EventLoop::create()
Timer::Ptr | _msgAvail = Timer::create()
Timer::Ptr | _delayedShutdown = Timer::create()
AsyncDataSource::Ptr | _controlIO
StompFrameStreamRef | _stream
ProviderConfiguration | _workerConf
std::exception_ptr | _fatalError
std::deque< ProvideMessage > | _pendingMessages
std::deque< ProvideWorkerItemRef > | _pendingProvides

## Additional Inherited Members
Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) | make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivate > | d_ptr

## Detailed Description

Definition at line 65 of file provideworker.h.

## Member Enumeration Documentation

## ◆ ProvideNotificatioMode

enum zyppng::worker::ProvideWorker::ProvideNotificatioMode

Enumerator
ONLY_NEW_PROVIDES |
QUEUE_NOT_EMTPY |

Definition at line 69 of file provideworker.h.

## ◆ MediaChangeRes

enum zyppng::worker::ProvideWorker::MediaChangeRes

This will request a media change from the user and BLOCK until it was acknowledged.

Enumerator
SUCCESS |
ABORT |
SKIP |

Definition at line 91 of file provideworker.h.

## Constructor & Destructor Documentation

## ◆ ProvideWorker()

zyppng::worker::ProvideWorker::ProvideWorker | ( | std::string_view | workerName | ) |

Definition at line 37 of file provideworker.cc.

## ◆ ~ProvideWorker()

zyppng::worker::ProvideWorker::~ProvideWorker | ( |  | ) |
| virtual

Definition at line 55 of file provideworker.cc.

## Member Function Documentation

## ◆ messageStream()

StompFrameStreamRef zyppng::worker::ProvideWorker::messageStream | ( |  | ) | const

Definition at line 58 of file provideworker.cc.

## ◆ run()

expected< void > zyppng::worker::ProvideWorker::run | ( | int | recv = STDIN_FILENO,
|  | int | send = STDOUT_FILENO )

Definition at line 63 of file provideworker.cc.

## ◆ requestQueue()

std::deque< ProvideWorkerItemRef > & zyppng::worker::ProvideWorker::requestQueue | ( |  | ) |

Definition at line 101 of file provideworker.cc.

## ◆ immediateShutdown()

virtual void zyppng::worker::ProvideWorker::immediateShutdown | ( |  | ) |
| inline virtual

Called when the worker process exits

Reimplemented in zyppng::worker::MountingWorker.

Definition at line 85 of file provideworker.h.

## ◆ requestMediaChange()

ProvideWorker::MediaChangeRes zyppng::worker::ProvideWorker::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 = {} )

Definition at line 238 of file provideworker.cc.

## ◆ requireAuthorization()

expected< AuthInfo > zyppng::worker::ProvideWorker::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 = {} )

This will send a authorization request message to the controller, asking for credentials for a given url. The lastTimstamp should be initialized with the last AuthInfo timestamp that was received from the controller or -1 if none was received before.

Note
  this blocks until a answer is received, all other received messages are delayed

Definition at line 256 of file provideworker.cc.

## ◆ provNotificationMode()

ProvideWorker::ProvideNotificatioMode zyppng::worker::ProvideWorker::provNotificationMode | ( |  | ) | const

Definition at line 106 of file provideworker.cc.

## ◆ setProvNotificationMode()

void zyppng::worker::ProvideWorker::setProvNotificationMode | ( | const ProvideNotificatioMode & | provNotificationMode | ) |

Definition at line 110 of file provideworker.cc.

## ◆ initLog()

void zyppng::worker::ProvideWorker::initLog | ( |  | ) |
| protected virtual

Definition at line 114 of file provideworker.cc.

## ◆ initialize()

virtual expected< WorkerCaps > zyppng::worker::ProvideWorker::initialize | ( | const Configuration & | conf | ) |
| protected pure virtual

Implemented in zyppng::worker::MountingWorker.

## ◆ provide()

virtual void zyppng::worker::ProvideWorker::provide | ( |  | ) |
| protected pure virtual

Automatically called whenever a new item is enqueued.

Implemented in zyppng::worker::MountingWorker.

## ◆ cancel()

virtual void zyppng::worker::ProvideWorker::cancel | ( | const std::deque< ProvideWorkerItemRef >::iterator & | request | ) |
| protected pure virtual

## ◆ makeItem()

ProvideWorkerItemRef zyppng::worker::ProvideWorker::makeItem | ( | ProvideMessage && | spec | ) |
| protected virtual

Always called to create new items for the request queue, override this to populate the queue with instances of custom ProvideItem subclasses.

Cancel requests are directly handled by calling cancel(), however Attach and Detach requests are enqueued as well

Definition at line 120 of file provideworker.cc.

## ◆ provideStart()

void zyppng::worker::ProvideWorker::provideStart | ( | const uint32_t | id,
|  | const zypp::Url & | url,
|  | const zypp::Pathname & | localFile,
|  | const zypp::Pathname & | stagingFile = {} )
| protected

Send a ProvideStart signal to the controller, this is to notify the controller that we have started providing the file the argument localFile has to refer to the file where the file will be provided into, it will be used to calculate statistics about download speed on the controller side. The stagingFile argument can be used for cases where the worker uses a staging area to download files into but later moves the file over to the result filename. In those cases the provider will check both locations for the file when calculating stats

Note
  Always call ref before sending this message.

Definition at line 125 of file provideworker.cc.

## ◆ provideSuccess()

void zyppng::worker::ProvideWorker::provideSuccess | ( | const uint32_t | id,
|  | bool | cacheHit,
|  | const zypp::Pathname & | localFile,
|  | const HeaderValueMap | extra = {} )
| protected

Send a ProvideSuccess message to the controller. This is to signal that we are finished with providing a file and release the file to be used by the controller side.

Definition at line 136 of file provideworker.cc.

## ◆ provideFailed() [1/2]

void zyppng::worker::ProvideWorker::provideFailed | ( | const uint32_t | id,
|  | const ProvideMessage::Code | code,
|  | const std::string & | reason,
|  | const bool | transient,
|  | const HeaderValueMap | extra = {} )
| protected

Send a ProvideFailed message to the controller. This is to signal that we are failed providing a resource

Note
  If the request referenced a ident before make sure to manually release it after sending the message.

Definition at line 149 of file provideworker.cc.

## ◆ provideFailed() [2/2]

void zyppng::worker::ProvideWorker::provideFailed | ( | const uint32_t | id,
|  | const ProvideMessage::Code | code,
|  | const bool | transient,
|  | const zypp::Exception & | e )
| protected

Overload of provideFailed that takes a zypp::Exception to fill in the error details

Note
  If the request referenced a ident before make sure to manually release it after sending the message.

Definition at line 163 of file provideworker.cc.

## ◆ attachSuccess()

void zyppng::worker::ProvideWorker::attachSuccess | ( | const uint32_t | id,
|  | const std::optional< std::string > & | localMountPoint = {} )
| protected

Send a AttachSuccess message to the controller. This is to signal that we are finished with mounting and verifying a medium

Definition at line 177 of file provideworker.cc.

## ◆ detachSuccess()

void zyppng::worker::ProvideWorker::detachSuccess | ( | const uint32_t | id | ) |
| protected

Send a DetachSuccess message to the controller. This is to signal that we are finished unmounting a medium

Definition at line 187 of file provideworker.cc.

## ◆ redirect()

void zyppng::worker::ProvideWorker::redirect | ( | const uint32_t | id,
|  | const zypp::Url & | url,
|  | const zypp::Pathname & | newPath )
| protected

Send a Redirect message to the controller for the given request ID. This is similar to sending a ProvideSuccess message and the request will be removed from the queue, which means the worker also has to remove it from its internal queue.

## ◆ controlIO()

AsyncDataSource & zyppng::worker::ProvideWorker::controlIO | ( |  | ) |
| protected

Returns the control IO datasource, only valid after run was called

Definition at line 284 of file provideworker.cc.

## ◆ executeHandshake()

expected< void > zyppng::worker::ProvideWorker::executeHandshake | ( |  | ) |
| private

Definition at line 289 of file provideworker.cc.

## ◆ maybeDelayedShutdown()

void zyppng::worker::ProvideWorker::maybeDelayedShutdown | ( |  | ) |
| private

Definition at line 350 of file provideworker.cc.

## ◆ messageLoop()

void zyppng::worker::ProvideWorker::messageLoop | ( | Timer & |  | ) |
| private

Definition at line 328 of file provideworker.cc.

## ◆ readFdClosed()

void zyppng::worker::ProvideWorker::readFdClosed | ( | uint | ,
|  | AsyncDataSource::ChannelCloseReason | )
| private

Definition at line 361 of file provideworker.cc.

## ◆ writeFdClosed()

void zyppng::worker::ProvideWorker::writeFdClosed | ( | AsyncDataSource::ChannelCloseReason |  | ) |
| private

Definition at line 367 of file provideworker.cc.

## ◆ messageReceived()

void zyppng::worker::ProvideWorker::messageReceived | ( |  | ) |
| private

Definition at line 373 of file provideworker.cc.

## ◆ onInvalidMessageReceived()

void zyppng::worker::ProvideWorker::onInvalidMessageReceived | ( |  | ) |
| private

Definition at line 382 of file provideworker.cc.

## ◆ invalidMessageReceived()

void zyppng::worker::ProvideWorker::invalidMessageReceived | ( | std::exception_ptr | p | ) |
| private

Definition at line 387 of file provideworker.cc.

## ◆ handleSingleMessage()

void zyppng::worker::ProvideWorker::handleSingleMessage | ( | const ProvideMessage & | provide | ) |
| private

Definition at line 398 of file provideworker.cc.

## ◆ pushSingleMessage()

void zyppng::worker::ProvideWorker::pushSingleMessage | ( | const zypp::PluginFrame & | msg | ) |
| private

Definition at line 431 of file provideworker.cc.

## ◆ sendAndWaitForResponse()

expected< ProvideMessage > zyppng::worker::ProvideWorker::sendAndWaitForResponse | ( | const ProvideMessage & | request,
|  | const std::vector< uint > & | responseCodes )
| private

Definition at line 195 of file provideworker.cc.

## ◆ parseReceivedMessage()

expected< ProvideMessage > zyppng::worker::ProvideWorker::parseReceivedMessage | ( | const zypp::PluginFrame & | m | ) |
| private

Definition at line 459 of file provideworker.cc.

## Member Data Documentation

## ◆ _provNotificationMode

ProvideNotificatioMode zyppng::worker::ProvideWorker::_provNotificationMode = QUEUE_NOT_EMTPY
| private

Definition at line 196 of file provideworker.h.

## ◆ _inControllerRequest

bool zyppng::worker::ProvideWorker::_inControllerRequest = false
| private

Definition at line 197 of file provideworker.h.

## ◆ _isRunning

bool zyppng::worker::ProvideWorker::_isRunning = false
| private

Definition at line 198 of file provideworker.h.

## ◆ _workerName

std::string_view zyppng::worker::ProvideWorker::_workerName
| private

Definition at line 199 of file provideworker.h.

## ◆ _loop

EventLoop::Ptr zyppng::worker::ProvideWorker::_loop = EventLoop::create()
| private

Definition at line 200 of file provideworker.h.

## ◆ _msgAvail

Timer::Ptr zyppng::worker::ProvideWorker::_msgAvail = Timer::create()
| private

Definition at line 201 of file provideworker.h.

## ◆ _delayedShutdown

Timer::Ptr zyppng::worker::ProvideWorker::_delayedShutdown = Timer::create()
| private

Definition at line 202 of file provideworker.h.

## ◆ _controlIO

AsyncDataSource::Ptr zyppng::worker::ProvideWorker::_controlIO
| private

Definition at line 203 of file provideworker.h.

## ◆ _stream

StompFrameStreamRef zyppng::worker::ProvideWorker::_stream
| private

Definition at line 204 of file provideworker.h.

## ◆ _workerConf

ProviderConfiguration zyppng::worker::ProvideWorker::_workerConf
| private

Definition at line 205 of file provideworker.h.

## ◆ _fatalError

std::exception_ptr zyppng::worker::ProvideWorker::_fatalError
| private

Definition at line 207 of file provideworker.h.

## ◆ _pendingMessages

std::deque<ProvideMessage> zyppng::worker::ProvideWorker::_pendingMessages
| private

Definition at line 209 of file provideworker.h.

## ◆ _pendingProvides

std::deque<ProvideWorkerItemRef> zyppng::worker::ProvideWorker::_pendingProvides
| private

Definition at line 210 of file provideworker.h.

The documentation for this class was generated from the following files:

- zypp-media/ng/worker/provideworker.h
- zypp-media/ng/worker/provideworker.cc