grafana/pkg
Arve Knudsen 9843a886f7
pkg/models: Check errors (#19839)
Check errors in pkg/models.
2019-10-22 16:18:36 +02:00
..
api API: Fix logging of dynamic listening port (#19644) 2019-10-22 13:07:43 +02:00
bus pkg/bus: Check errors (#19748) 2019-10-14 17:23:31 +02:00
cmd pkg/cmd: Check errors (#19700) 2019-10-15 16:44:15 +02:00
components pkg/components: Check errors (#19703) 2019-10-10 09:06:55 +02:00
events feat(signup): progress on new sign up and email verification flow, #2353 2015-08-28 15:14:24 +02:00
extensions Enterprise: add dependencies for upcoming features (#18793) 2019-08-30 18:14:32 +02:00
infra pkg/infra: Check errors (#19705) 2019-10-10 16:42:11 +02:00
login pkg/login: Check errors (#19714) 2019-10-09 12:57:44 +02:00
middleware pkg/middleware: Check errors (#19749) 2019-10-15 18:08:06 +02:00
models pkg/models: Check errors (#19839) 2019-10-22 16:18:36 +02:00
plugins pkg/plugins: Only warn if plugins fail to load. Fixes #19846 (#19859) 2019-10-18 14:39:38 +02:00
registry add functionality to override service in registry 2018-10-30 13:37:30 +01:00
services pkg/services: Check errors (#19712) 2019-10-22 14:08:18 +02:00
setting pkg/setting: Check errors (#19838) 2019-10-22 16:17:49 +02:00
tsdb pkg/tsdb: Check errors (#19837) 2019-10-22 16:16:53 +02:00
util Don't truncate IPv6 addresses (#19573) 2019-10-09 08:58:45 +02:00
ARCHITECTURE.md Docs: Minor edits to the README and several md files (#19238) 2019-09-20 00:04:56 +02:00
README.md Docs: Update pkg\README.md (#19615) 2019-10-09 08:04:56 +02:00

Grafana backend codebase

The code should follow the Backend style guide.

Refer to architecture for a description of the backend codebase architecture.

Ongoing refactoring

These issues are not something we want to address all at once but something we will improve incrementally. Since Grafana is released at a regular schedule the preferred approach is to do this in batches. Not only is it easier to review, but it also reduces the risk of conflicts when cherry-picking fixes from master to release branches. Please try to submit changes that span multiple locations at the end of the release cycle. We prefer to wait until the end because we make fewer patch releases at the end of the release cycle, so there are fewer opportunities for complications.

Global state

Global state makes testing and debugging software harder and it's something we want to avoid when possible. Unfortunately, there is quite a lot of global state in Grafana.

We want to migrate away from this by using the inject package to wire up all dependencies either in pkg/cmd/grafana-server/main.go or self-registering using registry.RegisterService ex https://github.com/grafana/grafana/blob/master/pkg/services/cleanup/cleanup.go#L25.

Limit the use of the init() function

Only use the init() function to register services/implementations.

Settings refactoring

The plan is to move all settings to from package level vars in settings package to the setting.Cfg struct. To access the settings, services and components can inject this setting.Cfg struct:

Cfg struct Injection example

Reduce the use of GoConvey

We want to migrate away from using GoConvey. Instead, we want to use stdlib testing, because it's the most common approach in the Go community and we think it will be easier for new contributors. Read more about how we want to write tests in ARCHITECTURE.MD.

Refactor SqlStore

The sqlstore handlers all use a global xorm engine variable. Refactor them to use the SqlStore instance.

Avoid global HTTP handler functions

Refactor HTTP handlers so that the handler methods are on the HttpServer instance or a more detailed handler struct. E.g (AuthHandler). This ensures they get access to HttpServer service dependencies (and Cfg object) and can avoid global state.

Date comparison

Store newly introduced date columns in the database as epochs if they require date comparison. This permits a unified approach for comparing dates against all the supported databases instead of handling dates differently for each database. Also, by comparing epochs, we no longer need error pruning transformations to and from other time zones.

Dependency management

Refer to UPGRADING_DEPENDENCIES.md.