Skip to content

Commit

Permalink
docs(server): add server readme with initial coding guidelines (#2720)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored and mathnogueira committed Jun 14, 2023
1 parent e85da3b commit 17393fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions server/README.md
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
```
3 changes: 2 additions & 1 deletion wiki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

## Architecture

1. [Resource Manager](../server/resourcemanager/README.md)
1. [General guidelines](../server/README.md)
2. [Resource Manager](../server/resourcemanager/README.md)

0 comments on commit 17393fa

Please sign in to comment.