Skip to content

Move generated schemas into sub-folders #1024

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

Merged
merged 1 commit into from
Jun 27, 2018

Conversation

roncohen
Copy link
Contributor

@roncohen roncohen commented Jun 25, 2018

This moves generated schemas into their own sub-folders in their respective processors.

This is extracted from the work on intake v2.

Right now, I think it's nice to have auto-generated and human-generated source code separately.

In the future for intake v2, we'll need to validate entities like errors and transactions separate from the payload, which means we'll need to have the schemas separate for the individual entities.

When we add the individual schemas (errors, transactions) in the future, we'd be putting even more auto-generated files in the same directories as the human-generated code, if we didn't have a sub-folder for it.

I went ahead and gave the schema constants names (const PayloadSchema) instead of using the Schema() method, because we'll need to have more schemas in the package in the future.

@roncohen
Copy link
Contributor Author

rebased and updated tests

@@ -4,6 +4,7 @@ import (
"testing"

er "github.com/elastic/apm-server/processor/error"
generatedschemas "github.com/elastic/apm-server/processor/error/generated-schemas"
Copy link
Contributor

Choose a reason for hiding this comment

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

Pleas use schema over schemas - as Rakyll's post points out package names should not be plural but singular.

I am not a huge fan of having generated-schemas in the path. The package name is schemas, the import path ends with generated-schemas and it needs to be overwritten with generatedschemas - if not absolutely necessary I'd rather avoid that.
How about either

  • getting rid of generated and just use schema
  • or use generated/schema folder structure to have a cleaner import. This would also allow to add further generated files in the future if necessary.

{"sourcemaps/payload.json", "processor/sourcemap/schema.go", "sourcemapSchema", "sourcemap"},
{"errors/payload.json", "processor/error/generated-schemas/payload.go", "PayloadSchema"},
{"transactions/payload.json", "processor/transaction/generated-schemas/payload.go", "PayloadSchema"},
{"sourcemaps/payload.json", "processor/sourcemap/generated-schemas/payload.go", "SourcemapSchema"},
Copy link
Contributor

Choose a reason for hiding this comment

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

The name SourcemapSchema is not consistent - please also change to PayloadSchema.

@roncohen roncohen force-pushed the move-generated-schemas branch from 6ea8c8c to bff5e83 Compare June 27, 2018 12:34
@roncohen
Copy link
Contributor Author

thanks @simitt! Updated and rebased.

@simitt
Copy link
Contributor

simitt commented Jun 27, 2018

jenkins, retest this please

@roncohen
Copy link
Contributor Author

jenkins, retest this please

@roncohen roncohen merged commit 64f0b32 into elastic:master Jun 27, 2018
@roncohen roncohen deleted the move-generated-schemas branch June 28, 2018 07:22
simitt pushed a commit to simitt/apm-server that referenced this pull request Jul 4, 2018
@simitt simitt mentioned this pull request Jul 4, 2018
simitt pushed a commit to simitt/apm-server that referenced this pull request Jul 4, 2018
simitt pushed a commit that referenced this pull request Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants