Skip to content

Commit

Permalink
Docs: Document backend package hierarchy model (grafana#31930)
Browse files Browse the repository at this point in the history
* Docs: Document backend package hierarchy model

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 authored and ryantxu committed Mar 30, 2021
1 parent 110e005 commit 6a8344b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contribute/architecture/backend/package-hierarchy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Package hierarchy

The Go package hierarchy in Grafana should be organized logically (Ben Johnson's
[article](https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1) served as inspiration), according to the
following principles:

* Domain types and interfaces should be in "root" packages (not necessarily at the very top, of the hierarchy, but
logical roots)
* Sub-packages should depend on roots - sub-packages here typically contain implementations, for example of services

## Practical example

The `pkg/plugins` package contains plugin domain types, for example `DataPlugin`, and also interfaces
such as `RequestHandler`. Then you have the `pkg/plugins/managers` subpackage, which contains concrete implementations
such as the service `PluginManager`. The subpackage `pkg/plugins/backendplugin/coreplugin` contains `plugins.DataPlugin`
implementations.

0 comments on commit 6a8344b

Please sign in to comment.