libzypp 17.31.23
zyppng::worker::ProvideWorker Class Referenceabstract

#include </home/abuild/rpmbuild/BUILD/libzypp-17.31.23/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 Member Functions

 ProvideWorker (std::string_view workerName)
 
virtual ~ProvideWorker ()
 
RpcMessageStream::Ptr 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< AuthInforequireAuthorization (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)
 

Protected Member Functions

virtual void initLog ()
 
virtual expected< WorkerCapsinitialize (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 uint code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
 
void provideFailed (const uint32_t id, const uint code, const bool transient, const zypp::Exception &e)
 
void attachSuccess (const uint32_t id)
 
void detachSuccess (const uint32_t id)
 
void redirect (const uint32_t id, const zypp::Url &url, const zypp::Pathname &newPath)
 
AsyncDataSource & controlIO ()
 

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 RpcMessage &msg)
 
expected< ProvideMessagesendAndWaitForResponse (const ProvideMessage &request, const std::vector< uint > &responseCodes)
 
expected< ProvideMessageparseReceivedMessage (const RpcMessage &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
 
RpcMessageStream::Ptr _stream
 
Configuration _workerConf
 
std::exception_ptr _fatalError
 
std::deque< ProvideMessage_pendingMessages
 
std::deque< ProvideWorkerItemRef > _pendingProvides
 

Detailed Description

Definition at line 67 of file provideworker.h.

Member Enumeration Documentation

◆ ProvideNotificatioMode

Enumerator
ONLY_NEW_PROVIDES 
QUEUE_NOT_EMTPY 

Definition at line 71 of file provideworker.h.

◆ MediaChangeRes

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

Enumerator
SUCCESS 
ABORT 
SKIP 

Definition at line 93 of file provideworker.h.

Constructor & Destructor Documentation

◆ ProvideWorker()

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

Definition at line 38 of file provideworker.cc.

◆ ~ProvideWorker()

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

Definition at line 56 of file provideworker.cc.

Member Function Documentation

◆ messageStream()

RpcMessageStream::Ptr zyppng::worker::ProvideWorker::messageStream ( ) const

Definition at line 59 of file provideworker.cc.

◆ run()

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

Definition at line 64 of file provideworker.cc.

◆ requestQueue()

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

Definition at line 102 of file provideworker.cc.

◆ immediateShutdown()

virtual void zyppng::worker::ProvideWorker::immediateShutdown ( )
inlinevirtual

Called when the worker process exits

Reimplemented in zyppng::worker::MountingWorker.

Definition at line 87 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 239 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 257 of file provideworker.cc.

◆ provNotificationMode()

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

Definition at line 107 of file provideworker.cc.

◆ setProvNotificationMode()

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

Definition at line 111 of file provideworker.cc.

◆ initLog()

void zyppng::worker::ProvideWorker::initLog ( )
protectedvirtual

Definition at line 115 of file provideworker.cc.

◆ initialize()

virtual expected< WorkerCaps > zyppng::worker::ProvideWorker::initialize ( const Configuration conf)
protectedpure virtual

◆ provide()

virtual void zyppng::worker::ProvideWorker::provide ( )
protectedpure 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)
protectedpure virtual

◆ makeItem()

ProvideWorkerItemRef zyppng::worker::ProvideWorker::makeItem ( ProvideMessage &&  spec)
protectedvirtual

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 121 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 126 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 137 of file provideworker.cc.

◆ provideFailed() [1/2]

void zyppng::worker::ProvideWorker::provideFailed ( const uint32_t  id,
const uint  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 150 of file provideworker.cc.

◆ provideFailed() [2/2]

void zyppng::worker::ProvideWorker::provideFailed ( const uint32_t  id,
const uint  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 164 of file provideworker.cc.

◆ attachSuccess()

void zyppng::worker::ProvideWorker::attachSuccess ( const uint32_t  id)
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 178 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 188 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 286 of file provideworker.cc.

◆ executeHandshake()

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

Definition at line 291 of file provideworker.cc.

◆ maybeDelayedShutdown()

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

Definition at line 352 of file provideworker.cc.

◆ messageLoop()

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

Definition at line 330 of file provideworker.cc.

◆ readFdClosed()

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

Definition at line 363 of file provideworker.cc.

◆ writeFdClosed()

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

Definition at line 369 of file provideworker.cc.

◆ messageReceived()

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

Definition at line 375 of file provideworker.cc.

◆ onInvalidMessageReceived()

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

Definition at line 384 of file provideworker.cc.

◆ invalidMessageReceived()

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

Definition at line 389 of file provideworker.cc.

◆ handleSingleMessage()

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

Definition at line 400 of file provideworker.cc.

◆ pushSingleMessage()

void zyppng::worker::ProvideWorker::pushSingleMessage ( const RpcMessage &  msg)
private

Definition at line 433 of file provideworker.cc.

◆ sendAndWaitForResponse()

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

Definition at line 196 of file provideworker.cc.

◆ parseReceivedMessage()

expected< ProvideMessage > zyppng::worker::ProvideWorker::parseReceivedMessage ( const RpcMessage &  m)
private

Definition at line 462 of file provideworker.cc.

Member Data Documentation

◆ _provNotificationMode

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

Definition at line 198 of file provideworker.h.

◆ _inControllerRequest

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

Definition at line 199 of file provideworker.h.

◆ _isRunning

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

Definition at line 200 of file provideworker.h.

◆ _workerName

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

Definition at line 201 of file provideworker.h.

◆ _loop

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

Definition at line 202 of file provideworker.h.

◆ _msgAvail

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

Definition at line 203 of file provideworker.h.

◆ _delayedShutdown

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

Definition at line 204 of file provideworker.h.

◆ _controlIO

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

Definition at line 205 of file provideworker.h.

◆ _stream

RpcMessageStream::Ptr zyppng::worker::ProvideWorker::_stream
private

Definition at line 206 of file provideworker.h.

◆ _workerConf

Configuration zyppng::worker::ProvideWorker::_workerConf
private

Definition at line 207 of file provideworker.h.

◆ _fatalError

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

Definition at line 209 of file provideworker.h.

◆ _pendingMessages

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

Definition at line 211 of file provideworker.h.

◆ _pendingProvides

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

Definition at line 212 of file provideworker.h.


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