Skip to content

Conversation

@traeak
Copy link
Contributor

@traeak traeak commented Oct 21, 2025

This gives the API access to the RemapConfig url_mapping during TSRemapNewInstance calls. This contains both the assigned stragies pointer and a pointer to the loaded strategy factory.

This modifies the strategies ts API from the previous PR.

API is:

valid during TSRemapNewInstance:

TSStrategy TSRemapNextHopStrategyFind(const char *name);
TSStrategy TSRemapNextHopStrategyGet();
void TSRemapNextHopStrategySet(TSStrategy strategy);

valid during remap (the Find call is changed):

TSStrategy TSHttpTxnNextHopStrategyFind(TSHttpTxn txnp, const char *name);
TSStrategy TSHttpTxnNextHopStrategyGet(TSHttpTxn txnp);
void TSHttpTxnNextHopStrategySet(TSHttpTxn txnp, TSStrategy strategy);

with utility function to get the strategy name (returns "null" if nullptr strategy):

char const *TSNextHopStrategyNameGet(TSStrategy strategy);

The header_rewrite and regex_remap plugins are modified to look up named strategies during TSRemapNewInstance instead of performing strategy factory lookups during each transaction remap hook.

@traeak traeak self-assigned this Oct 21, 2025
@traeak traeak force-pushed the strategy_init branch 2 times, most recently from fd6730e to 7e032e6 Compare October 27, 2025 12:44
@traeak traeak changed the title add strategies api for getting a strategy during remap plugin init Add to API to get a strategy duringTSRemapNewInstance Oct 28, 2025
@traeak traeak marked this pull request as ready for review October 28, 2025 19:45
@traeak traeak changed the title Add to API to get a strategy duringTSRemapNewInstance Add to API to get a strategy during TSRemapNewInstance Oct 28, 2025
@traeak traeak force-pushed the strategy_init branch 3 times, most recently from ada93a4 to 00c8021 Compare November 5, 2025 13:29
@traeak traeak requested a review from Copilot November 5, 2025 18:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the next-hop strategy API to separate transaction-level and remap-level strategy operations, introducing new TSRemap* functions for use during TSRemapNewInstance. The API functions have been renamed for consistency and clarity.

  • Renamed TSHttpNextHopStrategyNameGet to TSNextHopStrategyNameGet
  • Renamed TSHttpTxnNextHopNamedStrategyGet to TSHttpTxnNextHopStrategyFind
  • Added new TSRemap* API functions for strategy operations during remap rule loading

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/proxy/http/remap/RemapConfig.cc Sets up url_mapping::instance for TSRemap* API access and assigns strategyFactory to new mappings
src/api/InkAPI.cc Implements new TSRemap* functions and renames existing API functions
plugins/regex_remap/regex_remap.cc Updates to use new TSRemapNextHopStrategyFind API during initialization
plugins/lua/ts_lua_http.cc Updates function calls to use renamed API functions
plugins/header_rewrite/operators.h Changes internal storage from Value to explicit strategy pointer
plugins/header_rewrite/operators.cc Refactors to use TSRemapNextHopStrategyFind during initialization and removes runtime hook
plugins/header_rewrite/conditions.cc Updates to use renamed TSNextHopStrategyNameGet function
include/ts/ts.h Updates API documentation and function declarations
include/proxy/http/remap/UrlMapping.h Adds strategyFactory pointer and static instance pointer to url_mapping
doc/developer-guide/api/functions/*.en.rst Adds/updates documentation for new and renamed API functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant