zeroshade opened a new pull request, #4009:
URL: https://github.com/apache/arrow-adbc/pull/4009

   ## Summary
   
   Implements context.Context support for all Go ADBC methods to enable uniform 
OpenTelemetry instrumentation, cancellation, and deadline propagation 
(addresses #2772).
   
   - Add `DatabaseContext`, `ConnectionContext`, and `StatementContext` 
interfaces that mirror existing interfaces but require `context.Context` for 
all methods
   - Add extension Context interfaces: `PostInitOptionsContext`, 
`GetSetOptionsContext`, `ConnectionGetStatisticsContext`, 
`StatementExecuteSchemaContext`
   - Implement adapter functions (`AsDatabaseContext`, `AsConnectionContext`, 
`AsStatementContext`) to wrap non-context implementations for backward 
compatibility
   - Add `IngestStreamContext` helper for context-aware bulk ingestion
   - Comprehensive test suite (9 tests, all passing)
   
   ## Changes
   
   **New Interfaces** (`go/adbc/adbc.go`):
   - `DatabaseContext` - Database with context support for all operations
   - `ConnectionContext` - Connection with context support for all operations
   - `StatementContext` - Statement with context support for all operations
   - Extension interfaces with context support
   
   **Adapter Implementation** (`go/adbc/context_adapters.go`):
   - Three adapter types that wrap non-context implementations
   - Proper nil handling and double-wrap prevention
   - Context pass-through for methods that already accept context
   - Clear documentation about context limitations for legacy methods
   
   **Tests** (`go/adbc/context_adapters_test.go`):
   - Comprehensive test coverage for all adapters
   - Tests for error handling, nil handling, and context pass-through
   - All tests passing with race detector
   
   **Documentation & Examples**:
   - Updated package documentation explaining Context interfaces
   - Added `IngestStreamContext` helper function
   - Example code demonstrating adapter usage
   
   ## Migration Path
   
   **For Applications:**
   ```go
   // Wrap existing Database to add context support
   db := driver.NewDatabase(opts)
   dbCtx := adbc.AsDatabaseContext(db)
   
   ctx := context.Background()
   conn, err := dbCtx.Open(ctx)
   ```
   
   **For Driver Implementers:**
   - Existing drivers work unchanged via adapters
   - New drivers should implement Context interfaces directly
   - Gradual migration supported - no breaking changes
   
   ## Test Plan
   
   - [x] All adapter tests passing (9/9)
   - [x] Race detector: PASS
   - [x] Backward compatibility verified (existing tests unchanged)
   - [x] Documentation examples compile
   
   ## Notes
   
   This is the first step toward uniform OpenTelemetry support. Future work 
includes:
   - Updating individual drivers to implement Context interfaces natively
   - Adding context-aware tests to validation suite
   - Enhanced tracing instrumentation using context propagation


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to