Skip to content

Provide more general Transport interface for all transports#26

Merged
myleshorton merged 6 commits intomainfrom
myles/transport-interface-refactor
Dec 18, 2025
Merged

Provide more general Transport interface for all transports#26
myleshorton merged 6 commits intomainfrom
myles/transport-interface-refactor

Conversation

@myleshorton
Copy link
Contributor

This pull request refactors the transport mechanism in the kindling library to provide a more flexible and extensible way to manage HTTP transports. The main change is the introduction of a new Transport interface, replacing the previous round tripper generator approach. This allows users to add, replace, and manage custom transports more easily. The PR also updates the race transport logic to support the new interface and adds comprehensive tests for the new functionality.

Key changes include:

Transport Abstraction and API Changes

  • Introduced a new Transport interface, replacing the previous round tripper generator pattern. The kindling struct now maintains a slice of Transport objects, and all relevant methods and options have been updated to use this new abstraction. (kindling.go, race_transport.go) [1] [2] [3] [4]
  • Added a new WithTransport functional option to allow users to add custom transports when creating a kindling instance. (kindling.go, README.md) [1] [2]

Replace Transport Functionality

  • Replaced the ReplaceRoundTripGenerator method with ReplaceTransport, enabling users to replace an existing transport by name. Updated all internal usages and added error handling for missing transports. (kindling.go, kindling_test.go) [1] [2] [3]

Race Transport Refactor

  • Updated the race transport logic to work with the new Transport interface, including handling of body size limits and improved request cloning. (race_transport.go) [1] [2] [3] [4] [5] [6] [7] [8]

Test Enhancements

  • Added and refactored tests to cover the new ReplaceTransport method and the updated transport logic, ensuring correct behavior for adding, replacing, and error handling of transports. (kindling_test.go, race_transport_test.go) [1] [2] [3] [4]

Cleanup and Minor Improvements

  • Removed unused imports and legacy code related to the old round tripper generator approach. (kindling.go) [1] [2]

These changes make the transport layer in kindling more modular and easier to extend with custom behaviors.

@myleshorton myleshorton merged commit 9b6393d into main Dec 18, 2025
1 check passed
@myleshorton myleshorton deleted the myles/transport-interface-refactor branch December 18, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants