Kyle Brandt 49f0f0e89e config: fix connstr for remote_cache (#17675) há 6 anos atrás
..
api 1b1d951495 LDAP: refactoring (#17479) há 6 anos atrás
bus 87760d4fde Codestyle: Fix govet issues (#17178) há 6 anos atrás
cmd 7d68d6ede2 grafana-cli: Fix receiving flags via command line (#17617) há 6 anos atrás
components 912df2e284 gtime: some code style refactoring (#17369) há 6 anos atrás
events de0f04ec3c feat(signup): progress on new sign up and email verification flow, #2353 há 10 anos atrás
extensions d4ef19737e Enterprise: remove gofakeit dep (#17344) há 6 anos atrás
infra 7b70e7db2d AuthProxy: Optimistic lock pattern for remote cache Set (#17485) há 6 anos atrás
login 1b1d951495 LDAP: refactoring (#17479) há 6 anos atrás
middleware bd08d8ce8e middleware: fix Strict-Transport-Security header (#17644) há 6 anos atrás
models c853ef7318 SQLStore: extend `user.SearchUsers` method (#17514) há 6 anos atrás
plugins fb39831df2 Explore: Queries the datasource once per run query and uses DataStreamObserver (#17263) há 6 anos atrás
registry d0c00388e6 add functionality to override service in registry há 7 anos atrás
services 1c08e58605 LDAP: small improvements to various LDAP parts (#17662) há 6 anos atrás
setting 49f0f0e89e config: fix connstr for remote_cache (#17675) há 6 anos atrás
tsdb 6a76a92aff Prometheus: Preallocate data for Prometheus backend response parsing (#17490) há 6 anos atrás
util 151b24b95f CLI: Add command to migrate all datasources to use encrypted password fields (#17118) há 6 anos atrás
ARCHITECTURE.md b98bb48d59 codestyle: styleguide and arch for grafanas backend (#17545) há 6 anos atrás
README.md b98bb48d59 codestyle: styleguide and arch for grafanas backend (#17545) há 6 anos atrás
STYLEGUIDE.md b98bb48d59 codestyle: styleguide and arch for grafanas backend (#17545) há 6 anos atrás

README.md

Grafana backend codebase

The code styleguide and brief description of the architecture

On going refactorings.

These issues are not something we want to address all at once but something we will improve over time. Since Grafana is released at a regular schedule the prefer approuch is to do this in batches. Not only is it easier to review, it also reduces the risk of conflicts when cherry-picking fixes from master to release branches. Changes that spawn multiple locations are therefore prefered in the end of the release cycle since we make fewer patch releases in the end of the cycle.

Global state

Global state makes testing and debugging software harder and its something we want to avoid when possible. Unfortunately, there is quite a lot of global state in Grafana. The way we want to migrate away from this is to use 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

Reduce the use of the init() function

Should only be used 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/components can inject this setting.Cfg struct.

Cfg struct Injection example

Reduce the use of Goconvey

We want to migrated away from using Goconvey and use stdlib testing as its the most common approuch in the GO community and we think it will make it easier for new contributors. Read more about how we want to write tests in the ARCHITECTURE.MD docs.

Sqlstore refactoring

The sqlstore handlers all use a global xorm engine variable. This should be refactored to use the Sqlstore instance.

Avoid global HTTP Handler functions

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

Dependency management

The Grafana project uses Go modules to manage dependencies on external packages. This requires a working Go environment with version 1.11 or greater installed.

All dependencies are vendored in the vendor/ directory.

To add or update a new dependency, use the go get command:

# Pick the latest tagged release.
go get example.com/some/module/pkg

# Pick a specific version.
go get example.com/some/module/pkg@vX.Y.Z

Tidy up the go.mod and go.sum files and copy the new/updated dependency to the vendor/ directory:

# The GO111MODULE variable can be omitted when the code isn't located in GOPATH.
GO111MODULE=on go mod tidy

GO111MODULE=on go mod vendor

You have to commit the changes to go.mod, go.sum and the vendor/ directory before submitting the pull request.