this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sync

-196
-3
stack/river/test/dune
··· 1 - (executables 2 - (names test_eio_river test_logging test_logging_clean) 3 - (libraries river logs.fmt))
-64
stack/river/test/test_eio_river.ml
··· 1 - (* Test the Eio-based River library *) 2 - 3 - let test_sources = 4 - [ 5 - River.Source.make ~name:"OCaml Planet" ~url:"https://ocaml.org/feed.xml"; 6 - ] 7 - 8 - let main env = 9 - Printf.printf "Testing River library with Eio and Requests...\n"; 10 - 11 - (* Use River.Session.with_session for proper resource management *) 12 - River.Session.with_session env @@ fun session -> 13 - (* Test fetching feeds *) 14 - let feeds = 15 - try 16 - List.map (River.Feed.fetch session) test_sources 17 - with 18 - | Failure msg -> 19 - Printf.printf "Error: %s\n" msg; 20 - [] 21 - | e -> 22 - Printf.printf "Error: %s\n" (Printexc.to_string e); 23 - [] 24 - in 25 - 26 - if feeds <> [] then begin 27 - Printf.printf "Successfully fetched %d feed(s)\n" (List.length feeds); 28 - 29 - (* Get posts from feeds *) 30 - let posts = River.Post.of_feeds feeds in 31 - Printf.printf "Found %d posts\n" (List.length posts); 32 - 33 - (* Show first 3 posts *) 34 - let first_posts = 35 - match posts with 36 - | p1 :: p2 :: p3 :: _ -> [p1; p2; p3] 37 - | ps -> ps 38 - in 39 - 40 - List.iteri (fun i post -> 41 - Printf.printf "\nPost %d:\n" (i + 1); 42 - Printf.printf " Title: %s\n" (River.Post.title post); 43 - Printf.printf " Author: %s\n" (River.Post.author post); 44 - Printf.printf " Date: %s\n" 45 - (match River.Post.date post with 46 - | Some _ -> "Date available" (* Syndic.Date doesn't have to_string *) 47 - | None -> "N/A"); 48 - Printf.printf " Link: %s\n" 49 - (match River.Post.link post with 50 - | Some uri -> Uri.to_string uri 51 - | None -> "N/A") 52 - ) first_posts 53 - end 54 - 55 - let () = 56 - Printf.printf "River library successfully ported to Eio and Requests!\n\n"; 57 - Printf.printf "Key improvements:\n"; 58 - Printf.printf "1. Uses Requests session API with automatic redirect following\n"; 59 - Printf.printf "2. Structured concurrency with Eio switches\n"; 60 - Printf.printf "3. Direct-style code (no monads)\n"; 61 - Printf.printf "4. Automatic resource cleanup\n\n"; 62 - 63 - Eio_main.run @@ fun env -> 64 - main env
-67
stack/river/test/test_logging.ml
··· 1 - (* Test River library with logging enabled *) 2 - 3 - let setup_logging () = 4 - (* Configure logging - set to Debug level to see all logs *) 5 - Logs.set_reporter (Logs_fmt.reporter ()); 6 - Logs.set_level (Some Logs.Debug); 7 - 8 - (* You can also configure specific sources *) 9 - (* For example, to only see info and above for HTTP: *) 10 - (* Logs.Src.set_level (Logs.Src.find "river.http") (Some Logs.Info); *) 11 - 12 - Printf.printf "Logging configured at Debug level\n"; 13 - Printf.printf "Log sources:\n"; 14 - Printf.printf " - river: Main aggregator\n"; 15 - Printf.printf " - river.http: HTTP client operations\n"; 16 - Printf.printf " - river.feed: Feed parsing\n"; 17 - Printf.printf " - river.post: Post processing\n"; 18 - Printf.printf "---\n\n" 19 - 20 - let test_sources = 21 - [ 22 - River.Source.make ~name:"Test Feed" ~url:"https://example.com/feed.xml"; 23 - ] 24 - 25 - let main env = 26 - (* Test with logging *) 27 - Printf.printf "Testing River library with logging...\n\n"; 28 - 29 - (* Use River.Session.with_session for proper resource management *) 30 - River.Session.with_session env @@ fun session -> 31 - (* Demonstrate fetching with logging *) 32 - let feeds = 33 - try 34 - List.map (River.Feed.fetch session) test_sources 35 - with 36 - | Failure msg -> 37 - Printf.printf "Expected error (for demo): %s\n" msg; 38 - [] 39 - | e -> 40 - Printf.printf "Error: %s\n" (Printexc.to_string e); 41 - [] 42 - in 43 - 44 - if feeds <> [] then begin 45 - (* This would show post aggregation logs *) 46 - let posts = River.Post.of_feeds feeds in 47 - Printf.printf "\nFound %d posts\n" (List.length posts); 48 - 49 - (* This would show Atom entry creation logs *) 50 - let _entries = River.Format.Atom.entries_of_posts posts in 51 - Printf.printf "Created Atom entries\n" 52 - end 53 - 54 - let () = 55 - setup_logging (); 56 - 57 - Printf.printf "Starting River with integrated logging...\n\n"; 58 - 59 - Eio_main.run @@ fun env -> 60 - main env; 61 - 62 - Printf.printf "\nRiver library successfully integrated with Logs!\n"; 63 - Printf.printf "\nLog levels used:\n"; 64 - Printf.printf " - Debug: Detailed parsing and processing info\n"; 65 - Printf.printf " - Info: High-level operations (fetching, aggregating)\n"; 66 - Printf.printf " - Warning: Recoverable issues\n"; 67 - Printf.printf " - Error: Failures and exceptions\n"
-46
stack/river/test/test_logging_clean.ml
··· 1 - (* Clean logging example for River library *) 2 - 3 - let setup_logging level = 4 - Logs.set_reporter (Logs_fmt.reporter ()); 5 - Logs.set_level level 6 - 7 - let () = 8 - (* Set up Info level logging for cleaner output *) 9 - setup_logging (Some Logs.Info); 10 - 11 - Printf.printf "=== River Library with Integrated Logging ===\n\n"; 12 - Printf.printf "The River library now includes comprehensive logging:\n\n"; 13 - 14 - Printf.printf "Log Sources:\n"; 15 - Printf.printf " • river - Main aggregator operations\n"; 16 - Printf.printf " • river.http - HTTP client and requests\n"; 17 - Printf.printf " • river.feed - Feed parsing (Atom/RSS)\n"; 18 - Printf.printf " • river.post - Post processing and aggregation\n\n"; 19 - 20 - Printf.printf "Log Levels:\n"; 21 - Printf.printf " • Debug - Detailed parsing, HTTP session creation, post counts\n"; 22 - Printf.printf " • Info - Feed fetching, aggregation operations\n"; 23 - Printf.printf " • Warn - Recoverable issues (not used currently)\n"; 24 - Printf.printf " • Error - Connection failures, parsing errors, timeouts\n\n"; 25 - 26 - Printf.printf "Example Usage:\n"; 27 - Printf.printf " (* Set up logging *)\n"; 28 - Printf.printf " Logs.set_reporter (Logs_fmt.reporter ());\n"; 29 - Printf.printf " Logs.set_level (Some Logs.Info);\n\n"; 30 - 31 - Printf.printf " (* Use River normally - logs will be emitted automatically *)\n"; 32 - Printf.printf " Eio_main.run @@ fun env ->\n"; 33 - Printf.printf " let feed = River.fetch env source in\n"; 34 - Printf.printf " let posts = River.posts [feed] in\n"; 35 - Printf.printf " ...\n\n"; 36 - 37 - Printf.printf "Integration with Requests:\n"; 38 - Printf.printf " River's HTTP module uses the Requests library, which has its own\n"; 39 - Printf.printf " logging under the 'requests.*' namespace. Both libraries use the\n"; 40 - Printf.printf " same Logs infrastructure for consistent logging.\n\n"; 41 - 42 - Printf.printf "Benefits:\n"; 43 - Printf.printf " ✓ Debugging feed parsing issues\n"; 44 - Printf.printf " ✓ Monitoring HTTP performance\n"; 45 - Printf.printf " ✓ Tracking post aggregation\n"; 46 - Printf.printf " ✓ Consistent with Requests library\n"
-16
stack/river/test_river.ml
··· 1 - let test_source = River.{ 2 - name = "Example Feed"; 3 - url = "http://example.com/feed.xml" (* Would fail but shows the API *) 4 - } 5 - 6 - let () = 7 - Printf.printf "River library successfully ported to Eio and Requests!\n"; 8 - Printf.printf "The library now uses:\n"; 9 - Printf.printf "- Eio for async I/O instead of Lwt\n"; 10 - Printf.printf "- Requests for HTTP client instead of Cohttp\n"; 11 - Printf.printf "\n"; 12 - Printf.printf "Example usage:\n"; 13 - Printf.printf " Eio_main.run @@ fun env ->\n"; 14 - Printf.printf " let feed = River.fetch env source in\n"; 15 - Printf.printf " let posts = River.posts [feed] in\n"; 16 - Printf.printf " ...\n"