summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-01 17:33:47 +0300
committerValery Piashchynski <[email protected]>2020-12-01 17:33:47 +0300
commit3805b875c6498a9697c692c010bc022e8ebd50b0 (patch)
tree00635f6a6e9b1029e302f8e96faa7ab269fb43bd
parent84c8234ec01ad1d5ea5f0a8c7dbca9a3012bcb2b (diff)
golangci linters fix
-rwxr-xr-x.golangci.yml1
-rw-r--r--plugins/gzip/tests/plugin_test.go4
-rw-r--r--plugins/headers/plugin.go5
-rw-r--r--plugins/http/plugin.go10
-rw-r--r--plugins/http/tests/http_test.go25
-rw-r--r--plugins/logger/plugin.go8
-rw-r--r--plugins/metrics/plugin.go8
-rw-r--r--plugins/metrics/tests/metrics_test.go4
-rwxr-xr-xplugins/rpc/plugin.go10
-rw-r--r--plugins/server/plugin.go6
-rw-r--r--plugins/static/tests/static_plugin_test.go8
11 files changed, 46 insertions, 43 deletions
diff --git a/.golangci.yml b/.golangci.yml
index a49abafb..7a49f0c8 100755
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -5,6 +5,7 @@ run:
- plugins/http/tests/rpc_test_old.go
- plugins/http/tests/config_test.go
- plugins/static/tests/static_plugin_test.go
+ - plugins/headers/tests/old.go
linters:
disable-all: true
enable:
diff --git a/plugins/gzip/tests/plugin_test.go b/plugins/gzip/tests/plugin_test.go
index c7f12643..39979895 100644
--- a/plugins/gzip/tests/plugin_test.go
+++ b/plugins/gzip/tests/plugin_test.go
@@ -21,7 +21,7 @@ import (
)
func TestGzipPlugin(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -102,7 +102,7 @@ func headerCheck(t *testing.T) {
}
func TestMiddlewareNotExist(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
diff --git a/plugins/headers/plugin.go b/plugins/headers/plugin.go
index b49575bb..629c0f30 100644
--- a/plugins/headers/plugin.go
+++ b/plugins/headers/plugin.go
@@ -34,7 +34,6 @@ func (s *Plugin) Init(cfg config.Configurer) error {
func (s *Plugin) Middleware(next http.Handler) http.HandlerFunc {
// Define the http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
-
if s.cfg.Headers.Request != nil {
for k, v := range s.cfg.Headers.Request {
r.Header.Add(k, v)
@@ -60,6 +59,10 @@ func (s *Plugin) Middleware(next http.Handler) http.HandlerFunc {
}
}
+func (s *Plugin) Name() string {
+ return PluginName
+}
+
// configure OPTIONS response
func (s *Plugin) preflightRequest(w http.ResponseWriter, r *http.Request) {
headers := w.Header()
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 8e8957bd..79e8aa94 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -27,8 +27,8 @@ import (
)
const (
- // ID contains default service name.
- ServiceName = "http"
+ // PluginName declares plugin name.
+ PluginName = "http"
// EventInitSSL thrown at moment of https initialization. SSL server passed as context.
EventInitSSL = 750
@@ -78,7 +78,7 @@ func (s *Plugin) AddListener(listener util.EventListener) {
// misconfiguration. Services must not be used without proper configuration pushed first.
func (s *Plugin) Init(cfg config.Configurer, log log.Logger, server factory.Server) error {
const op = errors.Op("http Init")
- err := cfg.UnmarshalKey(ServiceName, &s.cfg)
+ err := cfg.UnmarshalKey(PluginName, &s.cfg)
if err != nil {
return errors.E(op, err)
}
@@ -287,7 +287,7 @@ func (s *Plugin) Workers() []roadrunner.WorkerBase {
}
func (s *Plugin) Name() string {
- return ServiceName
+ return PluginName
}
func (s *Plugin) Reset() error {
@@ -298,7 +298,7 @@ func (s *Plugin) Reset() error {
s.pool.Destroy(context.Background())
// re-read the config
- err := s.configurer.UnmarshalKey(ServiceName, &s.cfg)
+ err := s.configurer.UnmarshalKey(PluginName, &s.cfg)
if err != nil {
return errors.E(op, err)
}
diff --git a/plugins/http/tests/http_test.go b/plugins/http/tests/http_test.go
index 73bb53a0..06bf3f5d 100644
--- a/plugins/http/tests/http_test.go
+++ b/plugins/http/tests/http_test.go
@@ -41,7 +41,7 @@ var sslClient = &http.Client{
}
func TestHTTPInit(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -104,7 +104,7 @@ func TestHTTPInit(t *testing.T) {
}
func TestHTTPInformerReset(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -225,7 +225,7 @@ func informerTest(t *testing.T) {
}
func TestSSL(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -353,7 +353,7 @@ func fcgiEcho(t *testing.T) {
}
func TestSSLRedirect(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -439,8 +439,7 @@ func sslRedirect(t *testing.T) {
}
func TestSSLPushPipes(t *testing.T) {
- time.Sleep(time.Second)
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -528,7 +527,7 @@ func sslPush(t *testing.T) {
}
func TestFastCGI_RequestUri(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -612,7 +611,7 @@ func fcgiReqURI(t *testing.T) {
}
func TestH2CUpgrade(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -701,7 +700,7 @@ func h2cUpgrade(t *testing.T) {
}
func TestH2C(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -789,7 +788,7 @@ func h2c(t *testing.T) {
}
func TestHttpMiddleware(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -888,7 +887,7 @@ func middleware(t *testing.T) {
}
func TestHttpEchoErr(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -978,7 +977,7 @@ func echoError(t *testing.T) {
}
func TestHttpEnvVariables(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -1062,7 +1061,7 @@ func envVarsTest(t *testing.T) {
}
func TestHttpBrokenPipes(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
diff --git a/plugins/logger/plugin.go b/plugins/logger/plugin.go
index 2937056c..64b77a64 100644
--- a/plugins/logger/plugin.go
+++ b/plugins/logger/plugin.go
@@ -7,8 +7,8 @@ import (
"go.uber.org/zap"
)
-// ServiceName declares service name.
-const ServiceName = "logs"
+// PluginName declares plugin name.
+const PluginName = "logs"
// ZapLogger manages zap logger.
type ZapLogger struct {
@@ -19,12 +19,12 @@ type ZapLogger struct {
// Init logger service.
func (z *ZapLogger) Init(cfg config.Configurer) error {
- err := cfg.UnmarshalKey(ServiceName, &z.cfg)
+ err := cfg.UnmarshalKey(PluginName, &z.cfg)
if err != nil {
return err
}
- err = cfg.UnmarshalKey(ServiceName, &z.channels)
+ err = cfg.UnmarshalKey(PluginName, &z.channels)
if err != nil {
return err
}
diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go
index 3fd42ee4..c115826b 100644
--- a/plugins/metrics/plugin.go
+++ b/plugins/metrics/plugin.go
@@ -18,8 +18,8 @@ import (
)
const (
- // ID declares public service name.
- ServiceName = "metrics"
+ // PluginName declares plugin name.
+ PluginName = "metrics"
// maxHeaderSize declares max header size for prometheus server
maxHeaderSize = 1024 * 1024 * 100 // 104MB
)
@@ -42,7 +42,7 @@ type Plugin struct {
// Init service.
func (m *Plugin) Init(cfg config.Configurer, log log.Logger) error {
const op = errors.Op("Metrics Init")
- err := cfg.UnmarshalKey(ServiceName, &m.cfg)
+ err := cfg.UnmarshalKey(PluginName, &m.cfg)
if err != nil {
return err
}
@@ -218,7 +218,7 @@ func (m *Plugin) AddStatProvider(name endure.Named, stat metrics.StatProvider) e
// RPC interface satisfaction
func (m *Plugin) Name() string {
- return ServiceName
+ return PluginName
}
// RPC interface satisfaction
diff --git a/plugins/metrics/tests/metrics_test.go b/plugins/metrics/tests/metrics_test.go
index 4709d275..f9014c95 100644
--- a/plugins/metrics/tests/metrics_test.go
+++ b/plugins/metrics/tests/metrics_test.go
@@ -107,7 +107,7 @@ func TestMetricsInit(t *testing.T) {
}
func TestMetricsGaugeCollector(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
if err != nil {
t.Fatal(err)
}
@@ -174,7 +174,7 @@ func TestMetricsGaugeCollector(t *testing.T) {
}
func TestMetricsDifferentRPCCalls(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
if err != nil {
t.Fatal(err)
}
diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go
index 82b30563..24624d91 100755
--- a/plugins/rpc/plugin.go
+++ b/plugins/rpc/plugin.go
@@ -13,8 +13,8 @@ import (
"github.com/spiral/roadrunner/v2/plugins/config"
)
-// ServiceName contains default service name.
-const ServiceName = "RPC"
+// PluginName contains default plugin name.
+const PluginName = "RPC"
type pluggable struct {
service rpc_.RPCer
@@ -34,11 +34,11 @@ type Plugin struct {
// Init rpc service. Must return true if service is enabled.
func (s *Plugin) Init(cfg config.Configurer, log log.Logger) error {
const op = errors.Op("RPC Init")
- if !cfg.Has(ServiceName) {
+ if !cfg.Has(PluginName) {
return errors.E(op, errors.Disabled)
}
- err := cfg.UnmarshalKey(ServiceName, &s.cfg)
+ err := cfg.UnmarshalKey(PluginName, &s.cfg)
if err != nil {
return err
}
@@ -120,7 +120,7 @@ func (s *Plugin) Stop() error {
// Name contains service name.
func (s *Plugin) Name() string {
- return ServiceName
+ return PluginName
}
// Depends declares services to collect for RPC.
diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go
index 3411b007..ea6d42eb 100644
--- a/plugins/server/plugin.go
+++ b/plugins/server/plugin.go
@@ -15,7 +15,7 @@ import (
"github.com/spiral/roadrunner/v2/util"
)
-const ServiceName = "server"
+const PluginName = "server"
// Plugin manages worker
type Plugin struct {
@@ -27,7 +27,7 @@ type Plugin struct {
// Init application provider.
func (server *Plugin) Init(cfg config.Configurer, log log.Logger) error {
const op = errors.Op("Init")
- err := cfg.UnmarshalKey(ServiceName, &server.cfg)
+ err := cfg.UnmarshalKey(PluginName, &server.cfg)
if err != nil {
return errors.E(op, errors.Init, err)
}
@@ -44,7 +44,7 @@ func (server *Plugin) Init(cfg config.Configurer, log log.Logger) error {
// Name contains service name.
func (server *Plugin) Name() string {
- return ServiceName
+ return PluginName
}
func (server *Plugin) Serve() chan error {
diff --git a/plugins/static/tests/static_plugin_test.go b/plugins/static/tests/static_plugin_test.go
index d0403160..528d5eea 100644
--- a/plugins/static/tests/static_plugin_test.go
+++ b/plugins/static/tests/static_plugin_test.go
@@ -25,7 +25,7 @@ import (
)
func TestStaticPlugin(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -133,7 +133,7 @@ func serveStaticSample(t *testing.T) {
}
func TestStaticDisabled(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -206,7 +206,7 @@ func staticDisabled(t *testing.T) {
}
func TestStaticFilesDisabled(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{
@@ -282,7 +282,7 @@ func staticFilesDisabled(t *testing.T) {
}
func TestStaticFilesForbid(t *testing.T) {
- cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.Visualize(endure.StdOut, ""))
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
assert.NoError(t, err)
cfg := &config.Viper{