Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7e742763
Commit
7e742763
authored
Mar 08, 2019
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renames distcache -> remotecache
parent
66e71b66
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
45 additions
and
32 deletions
+45
-32
conf/defaults.ini
+1
-1
conf/sample.ini
+11
-0
pkg/cmd/grafana-server/server.go
+1
-1
pkg/infra/remotecache/database_storage.go
+1
-1
pkg/infra/remotecache/database_storage_test.go
+1
-1
pkg/infra/remotecache/memcached_storage.go
+2
-2
pkg/infra/remotecache/memcached_storage_integration_test.go
+2
-2
pkg/infra/remotecache/redis_storage.go
+2
-2
pkg/infra/remotecache/redis_storage_integration_test.go
+2
-2
pkg/infra/remotecache/remotecache.go
+11
-9
pkg/infra/remotecache/remotecache_test.go
+5
-5
pkg/setting/setting.go
+4
-4
scripts/circle-test-cache-servers.sh
+2
-2
No files found.
conf/defaults.ini
View file @
7e742763
...
...
@@ -107,7 +107,7 @@ path = grafana.db
cache_mode
=
private
#################################### Cache server #############################
[
cache_server
]
[
remote_cache
]
# Either "redis", "memcached" or "database" default is "database"
type
=
database
...
...
conf/sample.ini
View file @
7e742763
...
...
@@ -102,6 +102,17 @@ log_queries =
# For "sqlite3" only. cache mode setting used for connecting to the database. (private, shared)
;cache_mode = private
#################################### Cache server #############################
[remote_cache]
# Either "redis", "memcached" or "database" default is "database"
;type = database
# cache connectionstring options
# database: will use Grafana primary database.
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana`
# memcache: 127.0.0.1:11211
;connstr =
#################################### Session ####################################
[session]
# Either "memory", "file", "redis", "mysql", "postgres", default is "file"
...
...
pkg/cmd/grafana-server/server.go
View file @
7e742763
...
...
@@ -28,8 +28,8 @@ import (
// self registering services
_
"github.com/grafana/grafana/pkg/extensions"
_
"github.com/grafana/grafana/pkg/infra/distcache"
_
"github.com/grafana/grafana/pkg/infra/metrics"
_
"github.com/grafana/grafana/pkg/infra/remotecache"
_
"github.com/grafana/grafana/pkg/infra/serverlock"
_
"github.com/grafana/grafana/pkg/infra/tracing"
_
"github.com/grafana/grafana/pkg/infra/usagestats"
...
...
pkg/infra/
dist
cache/database_storage.go
→
pkg/infra/
remote
cache/database_storage.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"context"
...
...
pkg/infra/
dist
cache/database_storage_test.go
→
pkg/infra/
remote
cache/database_storage_test.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"testing"
...
...
pkg/infra/
dist
cache/memcached_storage.go
→
pkg/infra/
remote
cache/memcached_storage.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"time"
...
...
@@ -11,7 +11,7 @@ type memcachedStorage struct {
c
*
memcache
.
Client
}
func
newMemcachedStorage
(
opts
*
setting
.
CacheOpt
s
)
*
memcachedStorage
{
func
newMemcachedStorage
(
opts
*
setting
.
RemoteCacheOption
s
)
*
memcachedStorage
{
return
&
memcachedStorage
{
c
:
memcache
.
New
(
opts
.
ConnStr
),
}
...
...
pkg/infra/
dist
cache/memcached_storage_integration_test.go
→
pkg/infra/
remote
cache/memcached_storage_integration_test.go
View file @
7e742763
// +build memcached
package
dist
cache
package
remote
cache
import
(
"testing"
...
...
@@ -9,6 +9,6 @@ import (
)
func
TestMemcachedCacheStorage
(
t
*
testing
.
T
)
{
opts
:=
&
setting
.
CacheOpt
s
{
Name
:
"memcached"
,
ConnStr
:
"localhost:11211"
}
opts
:=
&
setting
.
RemoteCacheOption
s
{
Name
:
"memcached"
,
ConnStr
:
"localhost:11211"
}
runTestsForClient
(
t
,
createTestClient
(
t
,
opts
,
nil
))
}
pkg/infra/
dist
cache/redis_storage.go
→
pkg/infra/
remote
cache/redis_storage.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"time"
...
...
@@ -11,7 +11,7 @@ type redisStorage struct {
c
*
redis
.
Client
}
func
newRedisStorage
(
opts
*
setting
.
CacheOpt
s
)
*
redisStorage
{
func
newRedisStorage
(
opts
*
setting
.
RemoteCacheOption
s
)
*
redisStorage
{
opt
:=
&
redis
.
Options
{
Network
:
"tcp"
,
Addr
:
opts
.
ConnStr
,
...
...
pkg/infra/
dist
cache/redis_storage_integration_test.go
→
pkg/infra/
remote
cache/redis_storage_integration_test.go
View file @
7e742763
// +build redis
package
dist
cache
package
remote
cache
import
(
"testing"
...
...
@@ -10,6 +10,6 @@ import (
func
TestRedisCacheStorage
(
t
*
testing
.
T
)
{
opts
:=
&
setting
.
CacheOpt
s
{
Name
:
"redis"
,
ConnStr
:
"localhost:6379"
}
opts
:=
&
setting
.
RemoteCacheOption
s
{
Name
:
"redis"
,
ConnStr
:
"localhost:6379"
}
runTestsForClient
(
t
,
createTestClient
(
t
,
opts
,
nil
))
}
pkg/infra/
distcache/dist
cache.go
→
pkg/infra/
remotecache/remote
cache.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"bytes"
...
...
@@ -20,7 +20,7 @@ var (
)
func
init
()
{
registry
.
RegisterService
(
&
Distributed
Cache
{})
registry
.
RegisterService
(
&
Remote
Cache
{})
}
// CacheStorage allows the caller to set, get and delete items in the cache.
...
...
@@ -38,8 +38,8 @@ type CacheStorage interface {
Delete
(
key
string
)
error
}
//
Distributed
Cache allows Grafana to cache data outside its own process
type
Distributed
Cache
struct
{
//
Remote
Cache allows Grafana to cache data outside its own process
type
Remote
Cache
struct
{
log
log
.
Logger
Client
CacheStorage
SQLStore
*
sqlstore
.
SqlStore
`inject:""`
...
...
@@ -47,15 +47,17 @@ type DistributedCache struct {
}
// Init initializes the service
func
(
ds
*
Distributed
Cache
)
Init
()
error
{
ds
.
log
=
log
.
New
(
"
distributed.cach
e"
)
func
(
ds
*
Remote
Cache
)
Init
()
error
{
ds
.
log
=
log
.
New
(
"
cache.remot
e"
)
ds
.
Client
=
createClient
(
ds
.
Cfg
.
CacheOptions
,
ds
.
SQLStore
)
ds
.
Client
=
createClient
(
ds
.
Cfg
.
Remote
CacheOptions
,
ds
.
SQLStore
)
return
nil
}
func
(
ds
*
DistributedCache
)
Run
(
ctx
context
.
Context
)
error
{
// Run start the backend processes for cache clients
func
(
ds
*
RemoteCache
)
Run
(
ctx
context
.
Context
)
error
{
//create new interface if more clients need GC jobs
backgroundjob
,
ok
:=
ds
.
Client
.
(
registry
.
BackgroundService
)
if
ok
{
return
backgroundjob
.
Run
(
ctx
)
...
...
@@ -65,7 +67,7 @@ func (ds *DistributedCache) Run(ctx context.Context) error {
return
ctx
.
Err
()
}
func
createClient
(
opts
*
setting
.
CacheOpt
s
,
sqlstore
*
sqlstore
.
SqlStore
)
CacheStorage
{
func
createClient
(
opts
*
setting
.
RemoteCacheOption
s
,
sqlstore
*
sqlstore
.
SqlStore
)
CacheStorage
{
if
opts
.
Name
==
"redis"
{
return
newRedisStorage
(
opts
)
}
...
...
pkg/infra/
distcache/dist
cache_test.go
→
pkg/infra/
remotecache/remote
cache_test.go
View file @
7e742763
package
dist
cache
package
remote
cache
import
(
"testing"
...
...
@@ -19,13 +19,13 @@ func init() {
Register
(
CacheableStruct
{})
}
func
createTestClient
(
t
*
testing
.
T
,
opts
*
setting
.
CacheOpt
s
,
sqlstore
*
sqlstore
.
SqlStore
)
CacheStorage
{
func
createTestClient
(
t
*
testing
.
T
,
opts
*
setting
.
RemoteCacheOption
s
,
sqlstore
*
sqlstore
.
SqlStore
)
CacheStorage
{
t
.
Helper
()
dc
:=
&
Distributed
Cache
{
dc
:=
&
Remote
Cache
{
SQLStore
:
sqlstore
,
Cfg
:
&
setting
.
Cfg
{
CacheOptions
:
opts
,
Remote
CacheOptions
:
opts
,
},
}
...
...
@@ -44,7 +44,7 @@ func TestCachedBasedOnConfig(t *testing.T) {
HomePath
:
"../../../"
,
})
client
:=
createTestClient
(
t
,
cfg
.
CacheOptions
,
sqlstore
.
InitTestDB
(
t
))
client
:=
createTestClient
(
t
,
cfg
.
Remote
CacheOptions
,
sqlstore
.
InitTestDB
(
t
))
runTestsForClient
(
t
,
client
)
}
...
...
pkg/setting/setting.go
View file @
7e742763
...
...
@@ -242,7 +242,7 @@ type Cfg struct {
EditorsCanOwn
bool
// DistributedCache
CacheOptions
*
CacheOpt
s
RemoteCacheOptions
*
RemoteCacheOption
s
}
type
CommandLineArgs
struct
{
...
...
@@ -782,8 +782,8 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
enterprise
:=
iniFile
.
Section
(
"enterprise"
)
cfg
.
EnterpriseLicensePath
=
enterprise
.
Key
(
"license_path"
)
.
MustString
(
filepath
.
Join
(
cfg
.
DataPath
,
"license.jwt"
))
cacheServer
:=
iniFile
.
Section
(
"
cache_server
"
)
cfg
.
CacheOptions
=
&
CacheOpt
s
{
cacheServer
:=
iniFile
.
Section
(
"
remote_cache
"
)
cfg
.
RemoteCacheOptions
=
&
RemoteCacheOption
s
{
Name
:
cacheServer
.
Key
(
"type"
)
.
MustString
(
"database"
),
ConnStr
:
cacheServer
.
Key
(
"connstr"
)
.
MustString
(
""
),
}
...
...
@@ -791,7 +791,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
return
nil
}
type
CacheOpt
s
struct
{
type
RemoteCacheOption
s
struct
{
Name
string
ConnStr
string
}
...
...
scripts/circle-test-cache-servers.sh
View file @
7e742763
...
...
@@ -13,6 +13,6 @@ function exit_if_fail {
echo
"running redis and memcache tests"
#set -e
#time for d in $(go list ./pkg/...); do
time
exit_if_fail go
test
-tags
=
redis ./pkg/infra/
dist
cache/...
time
exit_if_fail go
test
-tags
=
memcached ./pkg/infra/
dist
cache/...
time
exit_if_fail go
test
-tags
=
redis ./pkg/infra/
remote
cache/...
time
exit_if_fail go
test
-tags
=
memcached ./pkg/infra/
remote
cache/...
#done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment