grafana/pkg
Arve Knudsen f7ad580356
pkg/login: Check errors (#19714)
* pkg/login: Check errors
* pkg/login: Introduce "login" logger

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2019-10-09 12:57:44 +02:00
..
api pkg/api: Check errors (#19657) 2019-10-08 18:57:53 +02:00
bus Codestyle: Fix govet issues (#17178) 2019-06-04 22:00:05 +02:00
cmd CLI: Fix version selection for plugin install (#19498) 2019-09-30 15:34:09 +02:00
components backend: null.Float NaN -> null for json marshal (#18284) 2019-08-06 12:28:48 -04: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 Metrics: Adds setting for turning off total stats metrics (#19142) 2019-09-17 09:32:24 +02:00
login pkg/login: Check errors (#19714) 2019-10-09 12:57:44 +02:00
middleware LDAP: Add API endpoint to debug user mapping from LDAP (#18833) 2019-09-03 18:34:44 +01:00
models API: Add createdAt field to /api/users/:id (#19475) 2019-09-28 12:12:33 +01:00
plugins API: added dashboardId and slug in response after import (#19692) 2019-10-08 17:47:18 +02:00
registry add functionality to override service in registry 2018-10-30 13:37:30 +01:00
services Don't truncate IPv6 addresses (#19573) 2019-10-09 08:58:45 +02:00
setting Upgrade grafana-plugin-model (#19438) 2019-09-30 15:16:04 +02:00
tsdb Don't truncate IPv6 addresses (#19573) 2019-10-09 08:58:45 +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.