This is an automated email from the ASF dual-hosted git repository. bnolsen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 23781107c8 move ts/parentselectdef.h contents into ts/apidefs.h (#11047) 23781107c8 is described below commit 23781107c8c08c563c4cb2d1beba1da176497c80 Author: Brian Olsen <brian_ols...@comcast.com> AuthorDate: Wed Feb 7 17:53:27 2024 -0700 move ts/parentselectdef.h contents into ts/apidefs.h (#11047) --- .../functions/TSHttpTxnResponseActionGet.en.rst | 44 ++++++++++++++ .../functions/TSHttpTxnResponseActionSet.en.rst | 48 +++++++++++++++ include/proxy/http/HttpTransact.h | 2 +- .../proxy/http/remap/NextHopSelectionStrategy.h | 2 +- include/ts/apidefs.h.in | 24 ++++++++ include/ts/parentselectdefs.h | 71 ---------------------- include/ts/ts.h | 1 - src/api/CMakeLists.txt | 6 +- src/proxy/http/HttpTransact.cc | 1 - 9 files changed, 120 insertions(+), 79 deletions(-) diff --git a/doc/developer-guide/api/functions/TSHttpTxnResponseActionGet.en.rst b/doc/developer-guide/api/functions/TSHttpTxnResponseActionGet.en.rst new file mode 100644 index 0000000000..ca8d94a943 --- /dev/null +++ b/doc/developer-guide/api/functions/TSHttpTxnResponseActionGet.en.rst @@ -0,0 +1,44 @@ +.. Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright + ownership. The ASF licenses this file to you under the Apache + License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + +.. include:: ../../../common.defs + +.. default-domain:: c + +TSHttpTxnResponseActionGet +************************** + +Synopsis +======== + +.. code-block:: cpp + + #include <ts/ts.h> + +.. function:: void TSHttpTxnResponseActionGet(TSHttpTxn txnp, TSResponseAction *action) + +Description +=========== + +Gets the ResponseAction set by a plugin. + +The action is an out-param and must point to a valid location + +The returned action.hostname must not be modified, and is owned by some plugi +n if not null. + +The action members will always be zero, if no plugin has called TSHttpTxnResp +onseActionSet. diff --git a/doc/developer-guide/api/functions/TSHttpTxnResponseActionSet.en.rst b/doc/developer-guide/api/functions/TSHttpTxnResponseActionSet.en.rst new file mode 100644 index 0000000000..e7d426ea52 --- /dev/null +++ b/doc/developer-guide/api/functions/TSHttpTxnResponseActionSet.en.rst @@ -0,0 +1,48 @@ +.. Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright + ownership. The ASF licenses this file to you under the Apache + License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + +.. include:: ../../../common.defs + +.. default-domain:: c + +TSHttpTxnResponseActionSet +************************** + +Synopsis +======== + +.. code-block:: cpp + + #include <ts/ts.h> + +.. function:: void TSHttpTxnResponseActionSet(TSHttpTxn txnp, TSResponseAction *action) + +Description +=========== + +Takes a ResponseAction and sets it as the behavior for finding the +next parent. + +Be aware ATS will never change this outside a plugin. +Therefore, plugins which set the ResponseAction to retry +must also un-set it after the subsequent success or failure, +or ATS will retry forever! + +The passed *action must not be null, and is copied and may be +destroyed after this call returns. + +Callers must maintain owernship of action.hostname, +and its lifetime must exceed the transaction. diff --git a/include/proxy/http/HttpTransact.h b/include/proxy/http/HttpTransact.h index c089dde2ce..d4029eabb8 100644 --- a/include/proxy/http/HttpTransact.h +++ b/include/proxy/http/HttpTransact.h @@ -37,8 +37,8 @@ #include "iocore/eventsystem/ConfigProcessor.h" #include "proxy/Transform.h" #include "proxy/Milestones.h" +#include "ts/apidefs.h" #include "ts/remap.h" -#include "ts/parentselectdefs.h" #include "proxy/http/remap/RemapPluginInfo.h" #include "proxy/http/remap/UrlMapping.h" #include "records/RecHttp.h" diff --git a/include/proxy/http/remap/NextHopSelectionStrategy.h b/include/proxy/http/remap/NextHopSelectionStrategy.h index f6f3cc4d15..eca82d2a43 100644 --- a/include/proxy/http/remap/NextHopSelectionStrategy.h +++ b/include/proxy/http/remap/NextHopSelectionStrategy.h @@ -26,7 +26,7 @@ #include <utility> -#include "ts/parentselectdefs.h" +#include "ts/apidefs.h" #include "proxy/ParentSelection.h" #include "proxy/http/HttpTransact.h" diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in index 9c9ae73823..bcf401699d 100644 --- a/include/ts/apidefs.h.in +++ b/include/ts/apidefs.h.in @@ -43,6 +43,7 @@ */ #include <cstdint> +#include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> @@ -1534,6 +1535,29 @@ char const TS_VERSION_STRING[] = "@TS_VERSION_STRING@"; TS_TXN_TYPE_TR_PASS_TUNNEL, } TSTxnType; + /// Exposed for custom parent selection behavior. + /// + /// This can used in association with TS_EVENT_HTTP_OS_DNS. + /// Plugins may set this to indicate how to retry. + /// If handled false: + /// then no plugin set it and Core will proceed to do its own thing. + /// If handled true: + /// core will not do any parent processing, markdown, or anything else, + /// but will use the values in this for whether to use the existing + /// response or make another request + struct TSResponseAction { + char const *hostname; ///< host for next request (must be null terminated?) + size_t hostname_len; ///< host len for next request (not including null) + in_port_t port; ///< port for next request + bool fail; + bool is_retry; + bool nextHopExists; + bool responseIsRetryable; + bool goDirect; + bool parentIsProxy; + bool no_cache; + }; + } // end namespace c } // end namespace tsapi diff --git a/include/ts/parentselectdefs.h b/include/ts/parentselectdefs.h deleted file mode 100644 index d6f7a9d37a..0000000000 --- a/include/ts/parentselectdefs.h +++ /dev/null @@ -1,71 +0,0 @@ -/** @file - - Traffic Server SDK API header file - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - @section developers Developers - - NextHop plugin interface. - - */ - -#pragma once - -#include <string.h> -#include <netinet/in.h> - -namespace tsapi -{ -namespace c -{ - - // Plugins may set this to indicate how to retry. - // - // If handled is false, then no plugin set it, and Core will proceed to do its own thing. - // - // If handled is true, core will not do any parent processing, markdown, or anything else, - // but will use the values in this for whether to use the existing response or make another request, - // and what that request should look like. - // - // See the API functions which take this for ownership requirements of pointers, like hostname. - // - // hostname is the hostname to use for the next request. It must be null-terminated. - // hostname_len is the length of hostname, not including the terminating null. - // - struct TSResponseAction { - // TODO this shouldn't be necessary - plugins should manipulate the response as they see fit, - // core shouldn't "know" if it was a "success" or "failure," only the response or retry data/action. - // But for now, core needs to know, for reasons. - const char *hostname; - size_t hostname_len; - in_port_t port; - bool fail; - bool is_retry; - bool nextHopExists; - bool responseIsRetryable; - bool goDirect; - bool parentIsProxy; - bool no_cache; - }; - -} // end namespace c -} // end namespace tsapi - -using namespace ::tsapi::c; diff --git a/include/ts/ts.h b/include/ts/ts.h index d414bd39f8..a51e3c77b6 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -37,7 +37,6 @@ #include "tsutil/DbgCtl.h" #include "ts/apidefs.h" -#include "ts/parentselectdefs.h" class DiagsConfigState; diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index 0cbed24df7..fcc7cc1985 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -19,10 +19,8 @@ add_library(tsapi SHARED InkAPI.cc InkIOCoreAPI.cc) add_library(ts::tsapi ALIAS tsapi) -set(TSAPI_PUBLIC_HEADERS - ${PROJECT_SOURCE_DIR}/include/ts/ts.h ${PROJECT_SOURCE_DIR}/include/ts/remap.h - ${PROJECT_SOURCE_DIR}/include/ts/TsException.h ${PROJECT_SOURCE_DIR}/include/ts/parentselectdefs.h - ${PROJECT_SOURCE_DIR}/include/ts/parentselectdefs.h ${PROJECT_BINARY_DIR}/include/ts/apidefs.h +set(TSAPI_PUBLIC_HEADERS ${PROJECT_SOURCE_DIR}/include/ts/ts.h ${PROJECT_SOURCE_DIR}/include/ts/remap.h + ${PROJECT_SOURCE_DIR}/include/ts/TsException.h ${PROJECT_BINARY_DIR}/include/ts/apidefs.h ) target_link_libraries(tsapi PRIVATE libswoc::libswoc yaml-cpp::yaml-cpp PCRE::PCRE OpenSSL::SSL) diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc index f472313487..68551c5356 100644 --- a/src/proxy/http/HttpTransact.cc +++ b/src/proxy/http/HttpTransact.cc @@ -24,7 +24,6 @@ #include "tscore/ink_inet.h" #include "tsutil/ts_bw_format.h" -#include "ts/parentselectdefs.h" #include "tscore/ink_platform.h" #include <strings.h>