66 @echo " Installation:"
77 @echo " install Install the package"
88 @echo " install-dev Install with development dependencies"
9+ @echo " install-examples Install example dependencies (e.g., pyarrow)"
910 @echo " "
1011 @echo " Quick Test Commands:"
1112 @echo " test-quick Run quick validation tests (~30s)"
4344 @echo " build Build distribution packages"
4445 @echo " clean Clean build artifacts"
4546 @echo " "
47+ @echo " Examples:"
48+ @echo " example-streaming Run streaming basic example"
49+ @echo " example-export-csv Run CSV export example"
50+ @echo " example-export-parquet Run Parquet export example"
51+ @echo " example-realtime Run real-time processing example"
52+ @echo " example-metrics Run metrics collection example"
53+ @echo " example-non-blocking Run non-blocking demo"
54+ @echo " example-context Run context manager safety demo"
55+ @echo " example-fastapi Run FastAPI example app"
56+ @echo " examples-all Run all examples sequentially"
57+ @echo " "
4658 @echo " Environment variables:"
4759 @echo " CASSANDRA_CONTACT_POINTS Cassandra contact points (default: localhost)"
4860 @echo " SKIP_INTEGRATION_TESTS=1 Skip integration tests"
@@ -56,6 +68,10 @@ install-dev:
5668 pip install -r requirements-lint.txt
5769 pre-commit install
5870
71+ install-examples :
72+ @echo " Installing example dependencies..."
73+ pip install -r examples/requirements.txt
74+
5975# Environment setup
6076CONTAINER_RUNTIME ?= $(shell command -v podman >/dev/null 2>&1 && echo podman || echo docker)
6177CASSANDRA_CONTACT_POINTS ?= 127.0.0.1
@@ -322,3 +338,89 @@ clean:
322338
323339clean-all : clean cassandra-stop
324340 @echo " All cleaned up"
341+
342+ # Example targets
343+ .PHONY : example-streaming example-export-csv example-export-parquet example-realtime example-metrics example-non-blocking example-context example-fastapi examples-all
344+
345+ # Ensure examples can connect to Cassandra
346+ EXAMPLES_ENV = CASSANDRA_CONTACT_POINTS=$(CASSANDRA_CONTACT_POINTS )
347+
348+ example-streaming : cassandra-wait
349+ @echo " === Running Streaming Basic Example ==="
350+ @echo " This example demonstrates memory-efficient streaming of large result sets"
351+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
352+ @$(EXAMPLES_ENV ) python examples/streaming_basic.py
353+
354+ example-export-csv : cassandra-wait
355+ @echo " === Running CSV Export Example ==="
356+ @echo " This example exports a large Cassandra table to CSV format"
357+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
358+ @echo " Output will be saved to ./exports/ directory"
359+ @$(EXAMPLES_ENV ) python examples/export_large_table.py
360+
361+ example-export-parquet : cassandra-wait
362+ @echo " === Running Parquet Export Example ==="
363+ @echo " This example exports Cassandra tables to Parquet format with streaming"
364+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
365+ @echo " Output will be saved to ./parquet_exports/ directory"
366+ @echo " Installing pyarrow if needed..."
367+ @pip install pyarrow > /dev/null 2>&1 || echo " PyArrow already installed"
368+ @$(EXAMPLES_ENV ) python examples/export_to_parquet.py
369+
370+ example-realtime : cassandra-wait
371+ @echo " === Running Real-time Processing Example ==="
372+ @echo " This example demonstrates real-time streaming analytics on sensor data"
373+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
374+ @$(EXAMPLES_ENV ) python examples/realtime_processing.py
375+
376+ example-metrics : cassandra-wait
377+ @echo " === Running Metrics Collection Examples ==="
378+ @echo " Running simple metrics example..."
379+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
380+ @$(EXAMPLES_ENV ) python examples/metrics_simple.py
381+ @echo " "
382+ @echo " Running advanced metrics example..."
383+ @$(EXAMPLES_ENV ) python examples/metrics_example.py
384+
385+ example-non-blocking : cassandra-wait
386+ @echo " === Running Non-Blocking Streaming Demo ==="
387+ @echo " This demonstrates that streaming doesn't block the event loop"
388+ @echo " Watch for heartbeat indicators showing continuous operation!"
389+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
390+ @$(EXAMPLES_ENV ) python examples/streaming_non_blocking_demo.py
391+
392+ example-context : cassandra-wait
393+ @echo " === Running Context Manager Safety Demo ==="
394+ @echo " This demonstrates proper resource management with context managers"
395+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
396+ @$(EXAMPLES_ENV ) python examples/context_manager_safety_demo.py
397+
398+ example-fastapi :
399+ @echo " === Running FastAPI Example App ==="
400+ @echo " This starts a full REST API with async Cassandra integration"
401+ @echo " The app includes Docker Compose for easy setup"
402+ @echo " See examples/fastapi_app/README.md for details"
403+ @cd examples/fastapi_app && $(MAKE ) run
404+
405+ examples-all : cassandra-wait
406+ @echo " === Running All Examples ==="
407+ @echo " This will run each example in sequence"
408+ @echo " Contact points: $( CASSANDRA_CONTACT_POINTS) "
409+ @echo " "
410+ @$(MAKE ) example-streaming
411+ @echo " \n----------------------------------------\n"
412+ @$(MAKE ) example-export-csv
413+ @echo " \n----------------------------------------\n"
414+ @$(MAKE ) example-export-parquet
415+ @echo " \n----------------------------------------\n"
416+ @$(MAKE ) example-realtime
417+ @echo " \n----------------------------------------\n"
418+ @$(MAKE ) example-metrics
419+ @echo " \n----------------------------------------\n"
420+ @$(MAKE ) example-non-blocking
421+ @echo " \n----------------------------------------\n"
422+ @$(MAKE ) example-context
423+ @echo " \n✅ All examples completed!"
424+ @echo " "
425+ @echo " Note: FastAPI example not included as it starts a server"
426+ @echo " Run 'make example-fastapi' separately to start the FastAPI app"
0 commit comments