pub struct Request {Show 33 fields
pub id: Uuid,
pub platform: String,
pub account: String,
pub module: String,
pub url: String,
pub method: String,
pub headers: Headers,
pub cookies: Cookies,
pub retry_times: usize,
pub task_retry_times: usize,
pub use_new_client: bool,
pub timeout: u64,
pub meta: MetaData,
pub params: Option<Vec<(String, String)>>,
pub json: Option<Value>,
pub body: Option<Vec<u8>>,
pub form: Option<Value>,
pub cache_headers: Option<Vec<String>>,
pub proxy: Option<ProxyEnum>,
pub limit_id: String,
pub download_middleware: Vec<String>,
pub data_middleware: Vec<String>,
pub task_finished: bool,
pub time_sleep_secs: Option<u64>,
pub context: ExecutionMark,
pub run_id: Uuid,
pub prefix_request: Uuid,
pub hash_str: Option<String>,
pub enable_session: bool,
pub enable_response_cache: bool,
pub enable_locker: Option<bool>,
pub downloader: String,
pub priority: Priority,
/* private fields */
}Fields§
§id: Uuid§platform: String§account: String§module: String§url: String§method: String§headers: Headers§retry_times: usize§task_retry_times: usize§use_new_client: bool§timeout: u64§meta: MetaDatameta from ParserModel and ErrorModel is appended to Task.meta in TaskFactory.
meta stores extra information. In Module.generate, Task.meta,
ShopInfo.extra, and ModuleConfig are merged into Request.meta.
Metadata sources include Task.meta, LoginInfo.extra, ModuleConfig, and trait-level
additions. Caller-defined fields are used to distinguish task/login/trait data.
params: Option<Vec<(String, String)>>§json: Option<Value>§body: Option<Vec<u8>>§form: Option<Value>§cache_headers: Option<Vec<String>>Header names that should be cached.
Example: Cache-Control, Expires, ETag.
proxy: Option<ProxyEnum>§limit_id: StringRate-limit identifier.
Used to mark requests that belong to the same rate-limit group.
Defaults to module_id.
download_middleware: Vec<String>§data_middleware: Vec<String>§task_finished: bool§time_sleep_secs: Option<u64>§context: ExecutionMark§run_id: Uuid§prefix_request: Uuid§hash_str: Option<String>Custom hash string used to override default request hash calculation.
enable_session: bool§enable_response_cache: bool§enable_locker: Option<bool>Enable distributed lock for this request to ensure serial execution within the same task/run
downloader: String§priority: PriorityImplementations§
Source§impl Request
impl Request
pub fn new(url: impl AsRef<str>, method: impl AsRef<str>) -> Self
pub fn with_priority(self, priority: Priority) -> Self
pub fn use_proxy(&mut self, proxy: ProxyEnum) -> &mut Request
pub fn task_id(&self) -> String
pub fn module_id(&self) -> String
Sourcepub fn task_runtime_id(&self) -> String
pub fn task_runtime_id(&self) -> String
Run-scoped task identifier for error tracking. Includes run_id to isolate
error state across different DAG runs.
Sourcepub fn module_runtime_id(&self) -> String
pub fn module_runtime_id(&self) -> String
Run-scoped module identifier for error tracking. Includes run_id to isolate
error state across different DAG runs.
pub fn with_params( self, params: Vec<(impl AsRef<str>, impl AsRef<str>)>, ) -> Self
pub fn with_headers(self, headers: Headers) -> Self
pub fn with_json<T: Serialize + ?Sized>(self, json: &T) -> Self
pub fn with_body(self, body: Vec<u8>) -> Self
pub fn with_form<T: Serialize + ?Sized>(self, form: &T) -> Self
pub fn with_meta<T>(self, meta: T) -> Selfwhere
T: Serialize,
pub fn add_meta<T>(self, key: impl AsRef<str>, value: T) -> Selfwhere
T: Serialize,
pub fn with_login_info(self, info: &LoginInfo) -> Self
pub fn with_task_config<T>(self, task_meta: T) -> Selfwhere
T: Serialize + for<'de> Deserialize<'de>,
pub fn with_module_config(self, value: &ModuleConfig) -> Self
pub fn with_sleep(self, secs: u64) -> Self
pub fn with_context(self, ctx: ExecutionMark) -> Self
pub fn hash(&self) -> String
pub fn enable_session(self, enable: bool) -> Self
pub fn enable_response_cache(self, enable: bool) -> Self
pub fn enable_response_cache_with<T>(self, hash_able: &T) -> Selfwhere
T: Serialize,
Trait Implementations§
Source§impl CacheAble for Request
impl CacheAble for Request
fn field() -> impl AsRef<str>
fn serialized_size_hint(&self) -> Option<usize>
fn clone_for_serialize(&self) -> Option<Self>
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
sync: &'life2 CacheService,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn send_persistent<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
sync: &'life2 CacheService,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_persistent<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
sync: &'life2 CacheService,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_with_ttl<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
sync: &'life2 CacheService,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_nx<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
sync: &'life2 CacheService,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sync<'life0, 'life1, 'async_trait>(
id: &'life0 str,
sync: &'life1 CacheService,
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
id: &'life0 str,
sync: &'life1 CacheService,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn scan<'life0, 'life1, 'async_trait>(
pattern_suffix: &'life0 str,
sync: &'life1 CacheService,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cache_id(id: &str, cache: &CacheService) -> String
Source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl EventProcessorTrait<Request, ()> for RequestPublish
impl EventProcessorTrait<Request, ()> for RequestPublish
fn pre_status(&self, input: &Request) -> Option<EventEnvelope>
fn finish_status(&self, input: &Request, _output: &()) -> Option<EventEnvelope>
fn working_status(&self, input: &Request) -> Option<EventEnvelope>
fn error_status(&self, input: &Request, err: &Error) -> Option<EventEnvelope>
fn retry_status( &self, input: &Request, retry_policy: &RetryPolicy, ) -> Option<EventEnvelope>
Source§impl EventProcessorTrait<Request, (Request, Option<ModuleConfig>)> for ConfigProcessor
impl EventProcessorTrait<Request, (Request, Option<ModuleConfig>)> for ConfigProcessor
fn pre_status(&self, _input: &Request) -> Option<EventEnvelope>
fn finish_status( &self, _input: &Request, _out: &(Request, Option<ModuleConfig>), ) -> Option<EventEnvelope>
fn working_status(&self, _input: &Request) -> Option<EventEnvelope>
fn error_status(&self, _input: &Request, _err: &Error) -> Option<EventEnvelope>
fn retry_status( &self, _input: &Request, _retry_policy: &RetryPolicy, ) -> Option<EventEnvelope>
Source§impl From<&Request> for RequestEvent
impl From<&Request> for RequestEvent
Source§impl From<&Request> for DownloadEvent
impl From<&Request> for DownloadEvent
Source§impl From<&Request> for RequestMiddlewareEvent
impl From<&Request> for RequestMiddlewareEvent
Source§impl Identifiable for Request
impl Identifiable for Request
Source§impl Offloadable for Request
impl Offloadable for Request
fn should_offload(&self, _threshold: usize) -> bool
fn offload<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_storage: &'life1 Arc<dyn BlobStorage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reload<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_storage: &'life1 Arc<dyn BlobStorage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Prioritizable for Request
impl Prioritizable for Request
fn get_priority(&self) -> Priority
Source§impl ProcessorTrait<Request, ()> for RequestPublish
impl ProcessorTrait<Request, ()> for RequestPublish
Source§fn process<'life0, 'async_trait>(
&'life0 self,
input: Request,
context: ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process<'life0, 'async_trait>(
&'life0 self,
input: Request,
context: ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 Request,
error: Error,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 Request,
error: Error,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn pre_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn pre_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn post_process<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_output: &'life2 Output,
_context: &'life3 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn post_process<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_output: &'life2 Output,
_context: &'life3 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn should_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn should_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§impl ProcessorTrait<Request, (Request, Option<ModuleConfig>)> for ConfigProcessor
impl ProcessorTrait<Request, (Request, Option<ModuleConfig>)> for ConfigProcessor
Source§fn process<'life0, 'async_trait>(
&'life0 self,
input: Request,
context: ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<(Request, Option<ModuleConfig>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process<'life0, 'async_trait>(
&'life0 self,
input: Request,
context: ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<(Request, Option<ModuleConfig>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn pre_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Request,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn pre_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Request,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Request,
_error: Error,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<(Request, Option<ModuleConfig>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Request,
_error: Error,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = ProcessorResult<(Request, Option<ModuleConfig>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn post_process<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_output: &'life2 Output,
_context: &'life3 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn post_process<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_output: &'life2 Output,
_context: &'life3 ProcessorContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn should_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn should_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_input: &'life1 Input,
_context: &'life2 ProcessorContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl !Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more