-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(server): add server readme with initial coding guidelines (#2720)
- Loading branch information
1 parent
e85da3b
commit 17393fa
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Server architecture and coding guidelines | ||
|
||
## Basic code organization rules | ||
|
||
### 1. Resources | ||
|
||
- `resource_name` must be singular. **snake_case** for filenames, **CamelCaseUpperFirst** for struct names. | ||
- Resource package names must be in **singular**. | ||
- Resource files must be named `{resource_name}_entities.go` and `{resource_name}_repository.go` | ||
> This format makes it easy to fuzzy search files | ||
- `{resource_name}_entities.go` must contain only one "main" entity and zero or more sub-entities (i.e. [demoresource](https://github.com/kubeshop/tracetest/blob/main/server/config/demoresource/demo_resource.go)) | ||
- Resource packages can have one or more "main" entities, each living on its own file. For example, the `transactions` package could have `transaction_entities.go` and `transaction_runs_entities.go` | ||
- Resource packages can have "subpackages". All the same rules apply. The package must **NOT** be prefixed with the parent package (i.e. `test/trigger` is good, `test/testtrigger` is bad), with the exception of generic names (i.e. `test/util` should be `test/testutil`) | ||
|
||
Example tests resource package: | ||
|
||
``` | ||
test/ | ||
trigger/ | ||
trigger_entities.go | ||
http_entities.go | ||
test_repository.go | ||
test_entities.go | ||
test_run_repository.go | ||
test_run_entities.go | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters