My agentic slop goes here. Not intended for anyone else!

sync

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