-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: repository layout with per-service split #4076
Comments
Thanks @oncilla. Overall, I like the proposal a lot! I'd also add a toplevel
Do you mean
I'd prefer having a
I'd have a toplevel I'd then create
I'd prefer to have a top-level |
Jup, I think that would be reasonable.
I meant at a top level. Originally, I called
This is a bit of an on going debate between pkg vs non-pkg. I honestly don't know the best course of action. pkg is neat for bundling, non-pkg is neat for better import paths.
Right, this will always be the case. The question is more, where do we put the generated code. Should the generated go code for the control-plane go in the
For protobuf, we need to mirror the path of the package definitions in the file paths relative to the proto root..
I think I agree, it makes it also very easy to discover the applications that we provide. |
Ah sorry I misunderstood. I think for protos defined in Does that make sense? |
Jup, I will adjust the proposal accordingly. |
I prefer to have
|
I agree with the sentiment of not having
That is true, but main.go is essentially just initialization and calling out to
In a world where you have multiple modules, I think you would do the following: World 1: root level cmd dir:
The
World 2: cmd per service:
I think both of these models would work well for versioning. |
Then, how about having |
The thing I don't like about this is that you waste the best package name on the binary. |
But such projects usually do not have per app grouped packages. IMO, having top level
and
UPD:
But according to "packages in apps MUST ONLY import third party packages, core , sdk, and other packages in apps" seems like only |
The more important point for me is that wasting this package on the binary leads to worse import paths/package structuring in our code too. Take for example
I don't follow this argument exactly. Where we put the packages and binary definitions does not affect the number of packages and binaries. So, you would get at most some additional But thinking about this, I'm slightly in favor of world 2, where we have a |
IMO, it is also a good sign that switching between world 2 and world 1 simply is a matter of moving the main packages around. This points to the fact that the concerns are properly separated and the package boundaries are sane. |
From those two options I would also choose world 2. My point was that, while looking at other projects, |
Regarding Some more (at most) half serious bike-shedding points: I find the name "core" a bit strong; cross-cutting utilities like logging, metrics, and tracing are not core to SCION. And the other one, "sdk", to me carries the negative implication that it will bring everything and the kitchen sink -- we want to use libraries, not tool kits. 😉 |
Reading through this discussion after a long time. I concur with @edganiukov's last comment; of these two options, I would prefer world 2 (weak preference). Also, I stand by my previous comment, the split between My suggestion would be to combine/replace
Instead of |
Okay, let's do the following:
I don't think we need the app sub directory after all. |
Restructure the whole repository layout to a more streamlined layout. This commit focuses on the go code. Other code will be considered eventually. The overall structure was discussed in scionproto#4076. Each service and cli tools gets a top-level directory. Packages that are shared across multiple applications are grouped in the `private` directory. This should indicate that these packages are not intended to be used by external parties, and that semantic versioning will not apply to these packages. Developer tools are grouped in the `tools` directory. Code that is intended for use by third external parties is grouped in the `pkg` directory. Here we should strive for a stable package API that does not change too often. To smoothen transition, the following gist has all the metadata of the move: https://gist.github.com/oncilla/96bdabb00359fdb4436a7a50d57d3cf3 You can use [go-imports.sh](https://gist.github.com/oncilla/96bdabb00359fdb4436a7a50d57d3cf3#file-go-imports-sh) to fix the imports. [shuffle.yml](https://gist.github.com/oncilla/96bdabb00359fdb4436a7a50d57d3cf3#file-shuffle-yml) lists all the moved packages and their targets. GitOrigin-RevId: 1a49e3871a65a4bbeac515ada78f7208a85d7558
Repository layout has been changed in #4163 🎉 Thank you all for the valuable input. I hope the layout can be stable in the future and we do not have to do a shuffle again. I have created a gist with all the packages that were moved and their target location shuffle.yml
|
Status: WIP
Problems
The repository layout has grown organically. There have been various previous attempts at trying to get some better structure into the project. So far they have been to no avail. By now, we have at least three different epochs of "repo layout" designs.
E.g.,
go/lib
vsgo/pkg/<service>/<subpackages>
vsgo/lib/infra/modules
vsgo/cs/<subpackages>
The current structure has various disadvantages:
lib
frompkg
without a clear guidance what should be where.lib
andpkg
. Currently, there even is an import cycle betweenlib
andpkg
making things even worse.Goals and Non-Goals
Goals:
Non-Goals:
Proposed Layout
The idea is to group all code that belongs to a service/tool together, irrespective of the language that it is implemented in.
Proposed structure:
Import Rules:
These rules will be enforced by a linter.
Automated Reposhuffle:
Changing the repository layout will be done automated, I have a prototype application that is capable of moving the packages and updating the bazel build files for go.
Because our python code is very limited, this will probably be done by hand.
Automated patching of downstreams
A output of the reposhuffle application will be a go-patch file such that our downstream dependents can easily update their code with our changes.
State
Currently, this proposal has not been agreed upon. We welcome feedback and ideas regarding the repository layout. Also, the open questions need to be addressed first.
Open Questions
control-service
vsscion
, or is it okay to stick them all underapplications
?I don't think it is necessary at this point
Do we want to bundle
apps/<supporting-packages>
under a sub-directory likeapps/pkg/<supporting-packages>
?The drawback of not bundling them is that they "pollute" the applications directory.
The advantage is a cleaner import path.
Given that we move the main packages to top-level
cmd
, I don't see a good reason to do it.Should the generated go protobuf code be located in
proto/
orcore/proto
proto
, the go code for the control plane would be located atproto/scion/control_plane
. This leads to the import pathgithub.aaakk.us.kg/scionproto/scion/proto/scion/control_plane
which is not very nice.core/proto/
we could choose it to be located atcore/proto/control_plane
. This would lead to the import pathgithub.aaakk.us.kg/scionproto/scion/core/proto/control_plane
.Generated code should be moved in the appropriate package. For control plane, it will go to
core/proto/control_plane
Instead of having a
cmd
-dir per application, we could also have a top-levelcmd
-dir. The application logic would still live inapplications/<application-name>
though. This might also work nicely in a multi-module repo.cmd
could act as the module that defines what versions are currently used and compatible with each other.I adapted the proposal to follow this style.
The text was updated successfully, but these errors were encountered: