Twitch SDK (Internal)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ttv::PagedRequestFetcher Class Reference

#include <httprequestutils.h>

Public Types

typedef std::function< TTV_ErrorCode(const std::string &cursor, std::shared_ptr< Task > &task)> CreateTaskCallback
 
typedef std::function< void(TTV_ErrorCode ec)> CompleteCallback
 

Public Member Functions

 PagedRequestFetcher ()
 
TTV_ErrorCode Start (const std::string &initialCursor, CreateTaskCallback createTaskCallback, CompleteCallback completeCallback)
 
void Cancel ()
 
void FetchComplete (TTV_ErrorCode ec, const std::string &cursor)
 
bool InProgress () const
 

Protected Member Functions

TTV_ErrorCode FetchPage ()
 

Protected Attributes

CreateTaskCallback mCreateTaskCallback
 
CompleteCallback mCompleteCallback
 
std::shared_ptr< TaskmCurrentTask
 
std::string mCursor
 
bool mCancel
 

Detailed Description

A helper class that fetches all pages of an endpoint. It is assumed that only status codes in the range [200, 299] will be returned when a successful page is returned.

Member Typedef Documentation

◆ CompleteCallback

Called when page fetching is complete.

◆ CreateTaskCallback

typedef std::function<TTV_ErrorCode(const std::string& cursor, std::shared_ptr<Task>& task)> ttv::PagedRequestFetcher::CreateTaskCallback

Called by the fetcher to create and schedule the next task with a task runner.

Constructor & Destructor Documentation

◆ PagedRequestFetcher()

ttv::PagedRequestFetcher::PagedRequestFetcher ( )

Member Function Documentation

◆ Cancel()

void ttv::PagedRequestFetcher::Cancel ( )

Cancels the fetching of further pages.

◆ FetchComplete()

void ttv::PagedRequestFetcher::FetchComplete ( TTV_ErrorCode  ec,
const std::string &  cursor 
)

Called by the client to notify the fetcher that the fetch of the current page has completed.

◆ FetchPage()

TTV_ErrorCode ttv::PagedRequestFetcher::FetchPage ( )
protected

◆ InProgress()

bool ttv::PagedRequestFetcher::InProgress ( ) const
inline

Whether or not fetches are in progress.

◆ Start()

TTV_ErrorCode ttv::PagedRequestFetcher::Start ( const std::string &  initialCursor,
CreateTaskCallback  createTaskCallback,
CompleteCallback  completeCallback 
)

Kicks off the fetching of pages.

Member Data Documentation

◆ mCancel

bool ttv::PagedRequestFetcher::mCancel
protected

◆ mCompleteCallback

CompleteCallback ttv::PagedRequestFetcher::mCompleteCallback
protected

◆ mCreateTaskCallback

CreateTaskCallback ttv::PagedRequestFetcher::mCreateTaskCallback
protected

◆ mCurrentTask

std::shared_ptr<Task> ttv::PagedRequestFetcher::mCurrentTask
protected

◆ mCursor

std::string ttv::PagedRequestFetcher::mCursor
protected

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