@@ -677,7 +677,8 @@ where
677677 /// use hammerwork::Worker;
678678 /// use std::time::Duration;
679679 /// # use std::sync::Arc;
680- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
680+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
681+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
681682 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
682683 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
683684 ///
@@ -688,6 +689,8 @@ where
688689 /// // Lower frequency polling for reduced load
689690 /// let slow_worker = Worker::new(queue, "slow".to_string(), handler)
690691 /// .with_poll_interval(Duration::from_secs(5));
692+ /// # Ok(())
693+ /// # }
691694 /// ```
692695 pub fn with_poll_interval ( mut self , interval : Duration ) -> Self {
693696 self . poll_interval = interval;
@@ -709,13 +712,16 @@ where
709712 /// ```rust,no_run
710713 /// use hammerwork::Worker;
711714 /// # use std::sync::Arc;
712- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
715+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
716+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
713717 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
714718 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
715719 ///
716720 /// // Critical jobs get more retry attempts
717721 /// let critical_worker = Worker::new(queue, "critical".to_string(), handler)
718722 /// .with_max_retries(10);
723+ /// # Ok(())
724+ /// # }
719725 /// ```
720726 pub fn with_max_retries ( mut self , max_retries : i32 ) -> Self {
721727 self . max_retries = max_retries;
@@ -737,13 +743,16 @@ where
737743 /// use hammerwork::Worker;
738744 /// use std::time::Duration;
739745 /// # use std::sync::Arc;
740- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
746+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
747+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
741748 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
742749 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
743750 ///
744751 /// // Longer delay for API rate limit recovery
745752 /// let api_worker = Worker::new(queue, "api".to_string(), handler)
746753 /// .with_retry_delay(Duration::from_secs(300)); // 5 minutes
754+ /// # Ok(())
755+ /// # }
747756 /// ```
748757 pub fn with_retry_delay ( mut self , delay : Duration ) -> Self {
749758 self . retry_delay = delay;
@@ -769,7 +778,8 @@ where
769778 /// use hammerwork::{Worker, retry::RetryStrategy};
770779 /// use std::time::Duration;
771780 /// # use std::sync::Arc;
772- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
781+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
782+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
773783 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
774784 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
775785 ///
@@ -778,8 +788,10 @@ where
778788 /// .with_default_retry_strategy(RetryStrategy::exponential(
779789 /// Duration::from_secs(1),
780790 /// 2.0,
781- /// Some(Duration::from_minutes (10))
791+ /// Some(Duration::from_secs (10 * 60 ))
782792 /// ));
793+ /// # Ok(())
794+ /// # }
783795 /// ```
784796 pub fn with_default_retry_strategy ( mut self , strategy : RetryStrategy ) -> Self {
785797 self . default_retry_strategy = Some ( strategy) ;
@@ -801,13 +813,16 @@ where
801813 /// use hammerwork::Worker;
802814 /// use std::time::Duration;
803815 /// # use std::sync::Arc;
804- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
816+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
817+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
805818 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
806819 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
807820 ///
808821 /// // Set 5 minute default timeout for all jobs
809822 /// let worker = Worker::new(queue, "processing".to_string(), handler)
810823 /// .with_default_timeout(Duration::from_secs(300));
824+ /// # Ok(())
825+ /// # }
811826 /// ```
812827 pub fn with_default_timeout ( mut self , timeout : Duration ) -> Self {
813828 self . default_timeout = Some ( timeout) ;
@@ -886,12 +901,15 @@ where
886901 /// ```rust,no_run
887902 /// use hammerwork::Worker;
888903 /// # use std::sync::Arc;
889- /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await.unwrap();
904+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
905+ /// # let pool = sqlx::PgPool::connect("postgresql://localhost/test").await?;
890906 /// # let queue = Arc::new(hammerwork::JobQueue::new(pool));
891907 /// # let handler: hammerwork::worker::JobHandler = Arc::new(|job| Box::pin(async move { Ok(()) }));
892908 ///
893909 /// let worker = Worker::new(queue, "batch_queue".to_string(), handler)
894910 /// .with_batch_processing_enabled(true);
911+ /// # Ok(())
912+ /// # }
895913 /// ```
896914 pub fn with_batch_processing_enabled ( mut self , enabled : bool ) -> Self {
897915 self . batch_processing_enabled = enabled;
0 commit comments