Skip to content
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: New file structure #166

Closed
adamryman opened this issue Mar 29, 2017 · 4 comments
Closed

Proposal: New file structure #166

adamryman opened this issue Mar 29, 2017 · 4 comments
Labels

Comments

@adamryman
Copy link
Member

Current:

.
├── docs
├── generated
│   ├── cli
│   │   └── handlers
│   └── client
│       ├── grpc
│       └── http
├── handlers
│   └── server
├── middlewares
├── NAME-cli-client
└── NAME-server

New:

.
├── docs
├── handlers
├── middlewares
├── NAME-cli-client
├── NAME-server
└── svc
    ├── cli
    │   └── handlers
    └── client
        ├── grpc
        └── http

Reasons:

  1. handlers/server/ is from the time when there were multiple directories in handlers.
  2. svc is the name of the package that gets created inside generated. svc is distinctive and the documentation can mention this is where generated code lives.
  3. Shorter to get to handlers. Plus package handler can be renamed to handlers to match directory.

In addition, rename

handlers/server/server_handler.go -> handlers/handlers.go
generated/cli/handlers/client_handler.go -> svc/cli/handlers/handlers.go

NAME-cli-client/client_main.go -> NAME-cli-client/main.go
NAME-server/server_main.go -> NAME-server/main.go
@zaquestion
Copy link
Member

👍 In favor of the proposed with a few possible tweaks

Seems like cli implies client and we could drop that suffix

NAME-cli

Not sure how I feel about svc replacing generated, makes sense to match the package, but feels like we are missing the descriptive nature of the folder name. Granted this folder will be in the import path for http/grpc clients. I think the rest of the folder structure is straightforward enough that svc should be self explanatory and a peak inside should clear up any wonder.

I'm still generally in favor of keeping code thats overwritten on each run of truss split off to discourage editing it. For the sake of this proposal however, I think its worth mentioning that we could ditch that model.
Consider

.
├── docs
├── handlers
├── middlewares
├── NAME-cli
    ├── cli
    │   └── handlers
├── NAME-server
├── client
    ├── grpc
    └── http

We could decorate the files with something like what protoc does and even place readmes in the folders.

// Code generated by protoc-gen-go.
// source: service.proto
// DO NOT EDIT!

Again just getting the idea out, I'm not really sure about this approach.
Would yield imports like

import "github.com/tunelab/project/project-service/client/http"

vs (looking at it, actually svc seems pretty o-kay)

import "github.com/tunelab/project/project-service/generated/client/http"
import "github.com/tunelab/project/project-service/svc/client/http"

@adamryman
Copy link
Member Author

@zaquestion, per in person discussion:

NAME-cli

👍

Otherwise svc seems like a pretty good name, and there are files in there that we would need to put somewhere anyways. So I am gonna go with that.

As for the

// Code generated by truss.
// Rerunning truss will overwrite this file.
// DO NOT EDIT!

I think I can sneak that into the right places.

@adamryman
Copy link
Member Author

Per in person:
@zaquestion @hasIan

NAME-cli-client -> NAME

@adamryman
Copy link
Member Author

Moving NAME and NAME-server into a cmd directory.

.
├── cmd
│   ├── NAME
│   └── NAME-server
├── handlers
├── middlewares
└── svc
    ├── cli
    │   └── handlers
    └── client
        ├── grpc
        └── http

adamryman added a commit to adamryman/truss that referenced this issue Mar 29, 2017
Update integration tests with new generated file structure

Update documentation for new file structure

Resolve metaverse#166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants