Skip to content

Conversation

@SolidWallOfCode
Copy link
Member

@SolidWallOfCode SolidWallOfCode commented May 23, 2018

Updated based on feedback

  • include/ts for C API headers.
  • include/tscpp for C++ API headers (link with libtscpp.so)
  • include/tsutil for C++ utility headers (link with libtsutil.so)

lib/ts is moved to lib/tscore which builds the libtscore library. A new directory, "lib/tsutil", is created for "dual use" utility C++ headers which builds libtsutil. These are headers used in the TS core and intended to be available to plugins. The goal of this restructuring is to unify include paths for core, internal plugins, and external plugins. That in turn enables exporting the dual use utility headers such as TextView.h. With the include paths the same, secondary includes will work as expected.

This only moves the installed version of TextView.h to include/tsutil as a demonstration and to validate the feasibility of making the move. This current structure is the result of many discussions on this PR, the mailing list, and the IRC channel.

UPDATE

All references to "atscppapi" have been changed to "tscpp". This includes the library name and the internal library namespace. The "README` file in this PR has been updated to reflect the re-arrangement.

  • ts/... : C API functions.
  • tscpp/... : C++ API functions.
  • tsutil/... : Internally used utilities not dependent on TS specifically.
  • tscore/... : Internal use only libraries.

These paths become the same for core and plugins so that internal plugins have less of a privileged position over external plugins and serve as better examples for plugin developers.

lib/ts was split into libtscore and libtsutil so that the dual use headers were in a separate library than the purely core headers. This was recommended by both @bryancall and @dragon512.

Key issues to handle for exporting dual use C++ headers -

  • The include path for a given header (e.g. TextView.h) must be the same between the core and a plugin because of headers including other headers.
  • Care must be taken to not impose core based requirements on plugins (e.g., not using assert at all).
  • I would like to minimize the number of -I include options on the compiler line. Relatedly, having include paths that have semantic meaning would help ease the pain of them being longer.
  • Avoid having "magic" or other "don't really include this" headers. Dual use headers need to not drag in other entangled headers. Let's not be Boost.

@SolidWallOfCode SolidWallOfCode added this to the 8.0.0 milestone May 23, 2018
@SolidWallOfCode SolidWallOfCode self-assigned this May 23, 2018
zwoop
zwoop previously requested changes May 23, 2018
Copy link
Contributor

@zwoop zwoop left a comment

Choose a reason for hiding this comment

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

Also, bigger question: How does this fit in with the existing (public) C++ APIs? It feels like we ought to have one set of includes / directory for all C++ level include files.

@@ -0,0 +1,17 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

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

I don' like the top-level directory name "src" here. To me, when I see that, it implies that all source code goes in src/. Seeing that all under src/ is API, maybe shuffle things up?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: When I see /src I initially expect non-header source files there (implementations). I see this proposes subtrees under /src expressly for different categories of header files.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to look forward to a future where the source files are moved under this location. E.g. "It provides scope for, over the lifetime of 8.0, restructuring more of the source code in to less insane places". When we don't do that, we get stuck. I was hoping to plan ahead for once and not forbid anything that's not immediately useful.

@@ -0,0 +1,17 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should continue the pattern of using includes for new Makefile (and keep working on fixing the existing ones). As an example, see how it's done in the plugins/ tree. This still preserves the Makefile modularity (one Makefile per "level"), but allows for much better parallelism.

@SolidWallOfCode
Copy link
Member Author

I disagree about having all of the C++ headers in a single directory. Bryan and I touched on this in our IRC discussion and I've become more convinced that splitting is the correctly approach. Among many other reasons, one issue is "I've included header leif.h. Do I need to link to a library too?". In the proposed scheme, if the header is in src/api/core, you don't. If it is in src/api/tscpp you do and the library is libatscppapi.so.

@bryancall
Copy link
Contributor

bryancall commented May 23, 2018

This doesn't fall with the standard way of laying out source code. Normally external headers go into an include directory at the top level (e.g. include/ts & include/tscpp). Also, I agree with @zwoop about having all the C++ headers in one directory. Users shouldn't have to figure out what directory the header is in and what lib to link with. There should only be one include directory and one library.

@dragon512
Copy link
Contributor

The standard way to layout headers is to have you stuff under a directory so you have to say

#include "dir/header"
This proposal means we have a clear

#include "api/tscpp/header.h"
#include "api/ts/ts.h"
#include "ts/ts.h"

and all you have in our build for include path is ./src

the dev package/ install move headers under a include directory with the same source layout

@bryancall
Copy link
Contributor

bryancall commented May 23, 2018

What I would propose would be:

lib/cppapi/include/atscppap moves to include/tscpp and would be installed at /usr/local/include/tscpp
proxy/api/ts moves to include/ts and would be installed at /usr/local/include/ts

Rename lib/ts to lib/ats so it doesn't conflict with the external api directory.

There would be one library for cpp APIs (e.g. TextView & Url) would change to:
/usr/local/lib/libtscpp.so

And this is how you would include headers:

#include "ats/ink_time.h" - internal C
#include "ats/Regex.h" - internal C++
#include "ts/ts.h" - exetrnal C API
#include "tscpp/TextView.h" - external C++ (also used internally)
#include "tscpp/Url.h" - external C++ API

@dragon512
Copy link
Contributor

So the current release (which @bryancall makes a great point on as we are about to release) I am good with @bryancall proposal. I still believe that it will be better long term to move code under src/

@bryancall
Copy link
Contributor

bryancall commented May 23, 2018

@dragon512 I agree long term moving most of the code under src/ is a good idea.

It makes me nervous when I wanted to branch last week and people are wanting to get stuff in last minute. We need to have a better plan and discuss it appropriately. Either we do a big push on moving things around before 9.0.0 or do it gradually after 8.0.0 is branched.

I would be in favor or one big push on moving things around right before 9.0.0 to make it easier on LTS maintainers.

@SolidWallOfCode
Copy link
Member Author

The goal of the way this PR was set up was precisely to provide for gradual movement during the 8.0 lifetime. The net effect of this PR is to create some directories and move 3-4 header files. That is as minimally disruptive as possible, IMHO, to achieve the stated goal.

"There would be one library for cpp APIs (e.g. TextView & Url)"

That is not possible without some major restructuring. At minimum almost everything would have to link with libtsutil and libtscpp instead of just the former. We would also be linking in the pure CPPAPI code which is currently not anywhere in the core. Even if were willing to do that, then it be much better to not have that code talk back through the C API but directly interact with the core. If this is a real problem then we should put the dual use headers in the C API directory because the linkage for them for a plugin is identical to that of the C API.

I am fine with using a top level include as suggested.

@SolidWallOfCode
Copy link
Member Author

I think we should change lib/ts to lib/tsutil so that libtsutil.so is compiled in lib/tsutil. Then we can just directly export headers from there to install/include/tsutil in parallel with include/ts and include/tscpp. In addition to distinguishing based on linkage, this would also separate pure utility classes in tsutil from API related classes in tscpp and ts.

@SolidWallOfCode SolidWallOfCode changed the title Create src/api to hold external API headers. Unify include paths for headers between core, internal plugins, and external plugins. May 24, 2018
@SolidWallOfCode SolidWallOfCode force-pushed the export-tslib-headers branch 5 times, most recently from 1eda495 to 9983f66 Compare May 25, 2018 13:54
@zwoop zwoop modified the milestones: 8.0.0, 9.0.0 Jun 6, 2018
@SolidWallOfCode SolidWallOfCode modified the milestones: 9.0.0, 8.0.0 Jun 6, 2018
@SolidWallOfCode SolidWallOfCode force-pushed the export-tslib-headers branch 2 times, most recently from a43db8c to 4f11b57 Compare June 7, 2018 16:42
@SolidWallOfCode
Copy link
Member Author

I updated the main comment. As noted I had two people push for putting the dual use headers in a separate library. I named that "libtsutil" because it's the utility library. The former "libtsutil" was moved to "libtscore" and put in "lib/core". Plugins don't need to link with "libtsutil" as that is pulled in by the traffic_server binary but it can be used to do linkage verification during build rather than after installation.

SolidWallOfCode pushed a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 6, 2018
SolidWallOfCode pushed a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 6, 2018
@bryancall
Copy link
Contributor

bryancall commented Sep 10, 2018

I still think it is a bad idea to split up the C++ API into to directories. I am -0 on this.

@bryancall bryancall dismissed their stale review September 10, 2018 16:51

lost interest

SolidWallOfCode pushed a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 11, 2018
SolidWallOfCode pushed a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 11, 2018
Copy link
Contributor

@zwoop zwoop left a comment

Choose a reason for hiding this comment

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

Ship it.

@SolidWallOfCode SolidWallOfCode merged commit 079a402 into apache:master Sep 11, 2018
@bryancall
Copy link
Contributor

@SolidWallOfCode This doesn't cleanly cherry pick to 8.0.x. If you want it in 8.0.0 you will need to make a PR off the 8.0.x branch.

SolidWallOfCode added a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 11, 2018
SolidWallOfCode added a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 11, 2018
zwoop pushed a commit that referenced this pull request Sep 12, 2018
jrushford added a commit to jrushford/trafficserver that referenced this pull request Sep 13, 2018
SolidWallOfCode added a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 13, 2018
SolidWallOfCode added a commit to SolidWallOfCode/trafficserver that referenced this pull request Sep 13, 2018
bryancall pushed a commit that referenced this pull request Sep 13, 2018
asfgit pushed a commit that referenced this pull request Sep 13, 2018
bryancall pushed a commit to bryancall/trafficserver that referenced this pull request Sep 18, 2018
(cherry picked from commit 1026969)
(cherry picked from commit 667ef7c)
maskit added a commit to maskit/trafficserver that referenced this pull request Sep 21, 2018
Revmoval of TESTS line on apache#3724 was incomplete.
maskit added a commit to maskit/trafficserver that referenced this pull request Sep 21, 2018
Removal of TESTS line on apache#3724 was incomplete.
maskit added a commit that referenced this pull request Sep 24, 2018
Removal of TESTS line on #3724 was incomplete.
masaori335 pushed a commit to masaori335/trafficserver that referenced this pull request Apr 27, 2020
* asf/8.0.x: (22 commits)
  Updated Changelog
  Follow up for apache#3724 - fix out of tree builds.
  Runroot: Fix a issue caused by restructured headers
  Corrects path in multiple documents
  header_rewrite: Removes deprecated %{CLIENT-IP} condition
  Updated Changelog
  Clarifies code comment for DL_Emergency
  heap use after free
  Adds redirect actions settings, returns by default
  Updated Changelog
  Fix link error on macOS
  Fixed error getting h2 HEADERS frame after stream is closed
  Disable the HttpSM half open logic if the underlying transport is TLS
  Fix inconsistent links in docs.
  Corrects IPv4 multicast ip address check
  PR apache#3724: Backport to ATS 8. Cherry-pick from 079a402
  Updated Changelog
  Remove unneeded aio header file
  Updated Changelog
  Update to changelog generation tool to not require milestone to be closed
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants