From fcd3f6d160aa155f29fd9850e631f3ba642cdbd9 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Thu, 4 Aug 2022 14:08:59 +0200 Subject: [PATCH] chore: go 1.19, replace interface{} with any Signed-off-by: Valery Piashchynski --- .github/workflows/linux.yml | 2 +- .github/workflows/macOS.yml | 2 +- .github/workflows/windows.yml | 2 +- README.md | 4 +-- docs/endure_arch.drawio | 2 +- examples/sample_1/modules/http/http_layer.go | 6 ++-- examples/sample_1/modules/logger/logger.go | 4 +-- go.mod | 2 +- pkg/container/calculate_deps.go | 8 ++--- pkg/container/container.go | 8 ++--- pkg/container/endure.go | 31 ++++++++++--------- pkg/container/init.go | 4 +-- pkg/container/reflect.go | 6 ++-- pkg/container/register.go | 2 +- pkg/fsm/fsm.go | 4 +-- pkg/graph/graph.go | 2 +- pkg/vertex/vertex.go | 2 +- tests/happy_scenarios/plugin1/plugin1.go | 4 +-- tests/happy_scenarios/plugin2/plugin2.go | 4 +-- tests/happy_scenarios/plugin3/plugin3.go | 4 +-- tests/happy_scenarios/plugin4/plugin4.go | 8 ++--- tests/happy_scenarios/plugin6/plugin6.go | 4 +-- .../plugin2/foo4_value.go | 4 +-- .../collects/collects_get_all_deps/plugin2.go | 8 ++--- .../named/randominterface/plugin2.go | 4 +-- tests/interfaces/named/registers/plugin2.go | 4 +-- .../interfaces/named/registersfail/plugin2.go | 4 +-- tests/interfaces/plugins/plugin2/plugin2.go | 4 +-- tests/interfaces/plugins/plugin5/plugin5.go | 4 +-- tests/interfaces/plugins/plugin6/plugin.go | 4 +-- tests/interfaces/plugins/plugin8/plugin8.go | 8 ++--- tests/issues/issue33/issue33.go | 4 +-- tests/issues/issue54/plugin3/plugin3.go | 4 +-- tests/issues/issue66/plugin3/plugin3.go | 4 +-- .../CyclicDepsCollectsInit/p1/plugin1.go | 4 +-- .../CyclicDepsCollectsInit/p2/plugin2.go | 4 +-- tests/stress/CollectorFuncReturn/foo.go | 4 +-- tests/stress/CyclicDepsCollects/p1/plugin1.go | 4 +-- tests/stress/CyclicDepsCollects/p2/plugin2.go | 4 +-- tests/stress/ServeErr/foo3_serve_error.go | 4 +-- tests/stress/ServeErr/foo4ServeError.go | 4 +-- tests/stress/ServeErr/plugin2.go | 4 +-- tests/stress/ServeRetryErr/plugin3.go | 8 ++--- tests/stress/stress_test.go | 8 +++-- 44 files changed, 110 insertions(+), 109 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a681f1e..07f5dcc 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: true matrix: - go: [ 1.18 ] + go: [ 1.19 ] os: [ ubuntu-latest ] env: GO111MODULE: on diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 175da81..cf6c377 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: true matrix: - go: [ 1.18 ] + go: [ 1.19 ] os: [ macos-latest ] env: GO111MODULE: on diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 01a061a..2b7a832 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: true matrix: - go: [ 1.18 ] + go: [ 1.19 ] os: [ windows-latest ] env: GO111MODULE: on diff --git a/README.md b/README.md index 204d38e..824ee3d 100755 --- a/README.md +++ b/README.md @@ -121,12 +121,12 @@ type ( // Provider declares the ability to provide dependencies to other plugins (OPTIONAL) Provider interface { - Provides() []interface{} + Provides() []any } // Collector declares the ability to accept the plugins which match the provided method signature (OPTIONAL) Collector interface { - Collects() []interface{} + Collects() []any } ) diff --git a/docs/endure_arch.drawio b/docs/endure_arch.drawio index 20d4fc5..52e28ba 100644 --- a/docs/endure_arch.drawio +++ b/docs/endure_arch.drawio @@ -13,7 +13,7 @@ - + diff --git a/examples/sample_1/modules/http/http_layer.go b/examples/sample_1/modules/http/http_layer.go index 4a97ebf..216056d 100755 --- a/examples/sample_1/modules/http/http_layer.go +++ b/examples/sample_1/modules/http/http_layer.go @@ -6,9 +6,9 @@ import ( "time" "github.com/gorilla/mux" - "github.com/rs/cors" "github.com/roadrunner-server/endure/examples/db_http_logger/modules/db" "github.com/roadrunner-server/endure/examples/db_http_logger/modules/logger" + "github.com/rs/cors" ) type Http struct { @@ -100,8 +100,8 @@ func (h *Http) Stop() error { return nil } -func (h *Http) Collects() []interface{} { - return []interface{}{ +func (h *Http) Collects() []any { + return []any{ h.AddMiddleware, } } diff --git a/examples/sample_1/modules/logger/logger.go b/examples/sample_1/modules/logger/logger.go index b0f9b51..63a2a67 100755 --- a/examples/sample_1/modules/logger/logger.go +++ b/examples/sample_1/modules/logger/logger.go @@ -22,8 +22,8 @@ func (l *Logger) Init() error { return nil } -func (l *Logger) Provides() []interface{} { - return []interface{}{ +func (l *Logger) Provides() []any { + return []any{ l.LoggerInstance, } } diff --git a/go.mod b/go.mod index a914b7b..fdbbb55 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/roadrunner-server/endure -go 1.18 +go 1.19 require ( github.com/roadrunner-server/errors v1.1.2 diff --git a/pkg/container/calculate_deps.go b/pkg/container/calculate_deps.go index 0e50b58..e4869fb 100755 --- a/pkg/container/calculate_deps.go +++ b/pkg/container/calculate_deps.go @@ -16,7 +16,7 @@ Adds a provided type via the Provider interface: actual type after FnsProviderToInvoke will be invoked 2. FnsProviderToInvoke --> is the list of the functions to invoke via the reflection to get the actual provided type */ -func (e *Endure) addProviders(vertexID string, vertex interface{}) error { +func (e *Endure) addProviders(vertexID string, vertex any) error { // hot path if _, ok := vertex.(Provider); !ok { return nil @@ -27,7 +27,7 @@ func (e *Endure) addProviders(vertexID string, vertex interface{}) error { } // vertex implements provider -func (e *Endure) implProvidesPath(vertexID string, vrtx interface{}) error { +func (e *Endure) implProvidesPath(vertexID string, vrtx any) error { const op = errors.Op("endure_add_providers") provider := vrtx.(Provider) for _, fn := range provider.Provides() { @@ -125,11 +125,9 @@ structs) in the function parameters list. If we found such vertex we can go by the following paths: 1. Function parameters list contain interfaces 2. Function parameters list contain only structures (easy case) - - */ func (e *Endure) implCollectorPath(vrtx *vertex.Vertex) error { - // vertexID string, vertex interface{} same vertex + // vertexID string, vertex any same vertex const op = errors.Op("endure_impl_collector_path") collector := vrtx.Iface.(Collector) // range Collectors functions diff --git a/pkg/container/container.go b/pkg/container/container.go index d409e97..b82c456 100755 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -50,9 +50,9 @@ type ( // Stop stops the plugins in rev-topological order Stop() error // Register registers one plugin in container - Register(service interface{}) error + Register(service any) error // RegisterAll register set of comma separated plugins in container - RegisterAll(service ...interface{}) error + RegisterAll(service ...any) error // Init initializes all plugins (calling Init function), calculate vertices, invoke Collects and Provided functions if exist Init() error } @@ -60,12 +60,12 @@ type ( // Provider declares the ability to provide service edges of declared types. Provider interface { // Provides function return set of functions which provided dependencies to other plugins - Provides() []interface{} + Provides() []any } // Collector declares the ability to accept the plugins which match the provided method signature. Collector interface { // Collects search for the structures or (and) interfaces in the arguments and provides it for the plugin - Collects() []interface{} + Collects() []any } ) diff --git a/pkg/container/endure.go b/pkg/container/endure.go index bb409b1..51d14a2 100755 --- a/pkg/container/endure.go +++ b/pkg/container/endure.go @@ -64,7 +64,7 @@ type Endure struct { stopTimeout time.Duration // deps is a map with all saved deps - deps map[string]interface{} + deps map[string]any depsOrd []string // disabled is a map with disabled deps disabled map[string]bool @@ -95,16 +95,17 @@ type Options func(endure *Endure) /* NewContainer returns empty endure container Input parameters: logLevel - -1 is the most informative level - DebugLevel --> also turns on pprof endpoint - 0 - InfoLevel defines info log level. - 1 - - 2 - WarnLevel defines warn log level. - 3 - ErrorLevel defines error log level. - 4 - FatalLevel defines fatal log level. - 5 - PanicLevel defines panic log level. - 6 - NoLevel defines an absent log level. - 7 - Disabled disables the logger. - see the endure.Level + + -1 is the most informative level - DebugLevel --> also turns on pprof endpoint + 0 - InfoLevel defines info log level. + 1 - + 2 - WarnLevel defines warn log level. + 3 - ErrorLevel defines error log level. + 4 - FatalLevel defines fatal log level. + 5 - PanicLevel defines panic log level. + 6 - NoLevel defines an absent log level. + 7 - Disabled disables the logger. + see the endure.Level */ func NewContainer(logger *zap.Logger, options ...Options) (*Endure, error) { const op = errors.Op("new_container") @@ -120,7 +121,7 @@ func NewContainer(logger *zap.Logger, options ...Options) (*Endure, error) { output: Empty, disabled: make(map[string]bool), initialized: make(map[string]bool), - deps: make(map[string]interface{}, 5), + deps: make(map[string]any, 5), depsOrd: make([]string, 0, 2), } @@ -235,7 +236,7 @@ func profile() { } // Register registers the dependencies in the Endure graph without invoking any methods -func (e *Endure) Register(vertex interface{}) error { +func (e *Endure) Register(vertex any) error { const op = errors.Op("endure_register") t := reflect.TypeOf(vertex) vertexID := removePointerAsterisk(t.String()) @@ -275,7 +276,7 @@ func (e *Endure) Register(vertex interface{}) error { return nil } -func (e *Endure) reRegister(vertex interface{}) error { +func (e *Endure) reRegister(vertex any) error { const op = errors.Op("endure_register") t := reflect.TypeOf(vertex) vertexID := removePointerAsterisk(t.String()) @@ -293,7 +294,7 @@ func (e *Endure) reRegister(vertex interface{}) error { } // RegisterAll is the helper for the register to register more than one structure in the endure -func (e *Endure) RegisterAll(plugins ...interface{}) error { +func (e *Endure) RegisterAll(plugins ...any) error { const op = errors.Op("endure_register_all") for _, plugin := range plugins { err := e.Register(plugin) diff --git a/pkg/container/init.go b/pkg/container/init.go index 763036f..2a04410 100644 --- a/pkg/container/init.go +++ b/pkg/container/init.go @@ -10,8 +10,7 @@ import ( ) /* - Traverse the DLL in the forward direction - +Traverse the DLL in the forward direction */ func (e *Endure) internalInit(vrtx *vertex.Vertex) error { const op = errors.Op("endure_internal_init") @@ -37,7 +36,6 @@ func (e *Endure) internalInit(vrtx *vertex.Vertex) error { /* Here we also track the Disabled vertices. If the vertex is disabled we should re-calculate the tree - */ func (e *Endure) callInitFn(init reflect.Method, vrtx *vertex.Vertex) error { const op = errors.Op("endure_call_init_fn") diff --git a/pkg/container/reflect.go b/pkg/container/reflect.go index 6ca8c12..cccca66 100755 --- a/pkg/container/reflect.go +++ b/pkg/container/reflect.go @@ -9,7 +9,7 @@ import ( "github.com/roadrunner-server/errors" ) -func providersReturnType(m interface{}) ([]reflect.Type, error) { +func providersReturnType(m any) ([]reflect.Type, error) { const op = errors.Op("endure_providers_return_type") r := reflect.TypeOf(m) if r.Kind() != reflect.Func { @@ -29,7 +29,7 @@ func providersReturnType(m interface{}) ([]reflect.Type, error) { return ret, nil } -func fnIn(m interface{}) ([]reflect.Type, error) { +func fnIn(m any) ([]reflect.Type, error) { const op = errors.Op("fn_in") r := reflect.TypeOf(m) if r.Kind() != reflect.Func { @@ -58,7 +58,7 @@ func functionParameters(r reflect.Method) []reflect.Type { return args } -func getFunctionName(i interface{}) string { +func getFunctionName(i any) string { rawName := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() name := strings.TrimPrefix(filepath.Ext(rawName), ".") diff --git a/pkg/container/register.go b/pkg/container/register.go index 136e07f..16d0462 100644 --- a/pkg/container/register.go +++ b/pkg/container/register.go @@ -4,7 +4,7 @@ import ( "github.com/roadrunner-server/errors" ) -func (e *Endure) register(name string, vrtx interface{}) error { +func (e *Endure) register(name string, vrtx any) error { // check the vertex const op = errors.Op("endure_register") if e.graph.HasVertex(name) { diff --git a/pkg/fsm/fsm.go b/pkg/fsm/fsm.go index 9f9a4c0..8664f1f 100644 --- a/pkg/fsm/fsm.go +++ b/pkg/fsm/fsm.go @@ -15,7 +15,7 @@ type FSM interface { // InitialState sets the initial FSM state InitialState(st State) // Transition used to move from one state to another - Transition(event Event, args ...interface{}) (interface{}, error) + Transition(event Event, args ...any) (any, error) } // NewFSM returns new FSM implementation based on initial state and callbacks to move from one state to another @@ -160,7 +160,7 @@ Event -> Start. Error on other events (Initialize, Stop) Event -> Stop. Error on other events (Start, Initialize) 3. Stopping -> Stopped */ -func (f *FSMImpl) Transition(event Event, args ...interface{}) (interface{}, error) { +func (f *FSMImpl) Transition(event Event, args ...any) (any, error) { f.mutex.Lock() defer f.mutex.Unlock() err := f.recognizer(event) diff --git a/pkg/graph/graph.go b/pkg/graph/graph.go index 51eb589..8264d26 100644 --- a/pkg/graph/graph.go +++ b/pkg/graph/graph.go @@ -201,7 +201,7 @@ func (g *Graph) depthFirstSearch(deps []*vertex.Vertex, tmp map[string]*vertex.V } // AddVertex adds an vertex to the graph with its ID, value and meta information -func (g *Graph) AddVertex(vertexID string, vertexIface interface{}) { +func (g *Graph) AddVertex(vertexID string, vertexIface any) { v := vertex.NewVertex() v.ID = vertexID v.Iface = vertexIface diff --git a/pkg/vertex/vertex.go b/pkg/vertex/vertex.go index 1cc64f0..0156b01 100644 --- a/pkg/vertex/vertex.go +++ b/pkg/vertex/vertex.go @@ -120,7 +120,7 @@ type Vertex struct { // ID of the vertex, currently string representation of the structure fn ID string // Vertex (Registered structure) - Iface interface{} + Iface any // Meta information about current Vertex Meta Meta // Dependencies of the node diff --git a/tests/happy_scenarios/plugin1/plugin1.go b/tests/happy_scenarios/plugin1/plugin1.go index 821bccc..2f2ef87 100755 --- a/tests/happy_scenarios/plugin1/plugin1.go +++ b/tests/happy_scenarios/plugin1/plugin1.go @@ -8,8 +8,8 @@ import ( type S1 struct { } -func (s1 *S1) Collects() []interface{} { - return []interface{}{ +func (s1 *S1) Collects() []any { + return []any{ s1.AddService, } } diff --git a/tests/happy_scenarios/plugin2/plugin2.go b/tests/happy_scenarios/plugin2/plugin2.go index 4cbebc2..cbb21fb 100755 --- a/tests/happy_scenarios/plugin2/plugin2.go +++ b/tests/happy_scenarios/plugin2/plugin2.go @@ -12,8 +12,8 @@ func (s2 *S2) Init(db *plugin4.DB) error { return nil } -func (s2 *S2) Provides() []interface{} { - return []interface{}{s2.CreateDB} +func (s2 *S2) Provides() []any { + return []any{s2.CreateDB} } func (s2 *S2) CreateDB() (*DB, error) { diff --git a/tests/happy_scenarios/plugin3/plugin3.go b/tests/happy_scenarios/plugin3/plugin3.go index eec3c12..d6df09e 100755 --- a/tests/happy_scenarios/plugin3/plugin3.go +++ b/tests/happy_scenarios/plugin3/plugin3.go @@ -8,8 +8,8 @@ import ( type S3 struct { } -func (s3 *S3) Collects() []interface{} { - return []interface{}{ +func (s3 *S3) Collects() []any { + return []any{ s3.SomeOtherDep, } } diff --git a/tests/happy_scenarios/plugin4/plugin4.go b/tests/happy_scenarios/plugin4/plugin4.go index 2643e01..9b60ca9 100755 --- a/tests/happy_scenarios/plugin4/plugin4.go +++ b/tests/happy_scenarios/plugin4/plugin4.go @@ -20,8 +20,8 @@ func (s *S4) Init(foo5 *plugin5.S5, fooWriter plugin6.FooWriter) error { } // But provide some -func (s *S4) Provides() []interface{} { - return []interface{}{ +func (s *S4) Provides() []any { + return []any{ s.CreateAnotherDB, } } @@ -33,8 +33,8 @@ func (s *S4) CreateAnotherDB() (*DB, error) { }, nil } -func (s *S4) Collects() []interface{} { - return []interface{}{ +func (s *S4) Collects() []any { + return []any{ s.AddService, } } diff --git a/tests/happy_scenarios/plugin6/plugin6.go b/tests/happy_scenarios/plugin6/plugin6.go index 530be32..4b0f3cf 100755 --- a/tests/happy_scenarios/plugin6/plugin6.go +++ b/tests/happy_scenarios/plugin6/plugin6.go @@ -25,8 +25,8 @@ func (s *S6Interface) Stop() error { return nil } -func (s *S6Interface) Provides() []interface{} { - return []interface{}{s.ProvideInterface} +func (s *S6Interface) Provides() []any { + return []any{s.ProvideInterface} } func (s *S6Interface) ProvideInterface() FooWriter { diff --git a/tests/happy_scenarios/provided_value_but_need_pointer/plugin2/foo4_value.go b/tests/happy_scenarios/provided_value_but_need_pointer/plugin2/foo4_value.go index 860703e..7739c73 100755 --- a/tests/happy_scenarios/provided_value_but_need_pointer/plugin2/foo4_value.go +++ b/tests/happy_scenarios/provided_value_but_need_pointer/plugin2/foo4_value.go @@ -13,8 +13,8 @@ func (s *Plugin2) Init() error { } // But provide some -func (s *Plugin2) Provides() []interface{} { - return []interface{}{ +func (s *Plugin2) Provides() []any { + return []any{ s.CreateAnotherDB, } } diff --git a/tests/interfaces/collects/collects_get_all_deps/plugin2.go b/tests/interfaces/collects/collects_get_all_deps/plugin2.go index f2a14b1..adfe63c 100644 --- a/tests/interfaces/collects/collects_get_all_deps/plugin2.go +++ b/tests/interfaces/collects/collects_get_all_deps/plugin2.go @@ -3,12 +3,12 @@ package collects_get_all_deps import "github.com/roadrunner-server/errors" type Plugin2 struct { - collectsDeps []interface{} + collectsDeps []any } func (f *Plugin2) Init() error { // should be 2 deps - f.collectsDeps = make([]interface{}, 0, 2) + f.collectsDeps = make([]any, 0, 2) return nil } @@ -24,8 +24,8 @@ func (f *Plugin2) Stop() error { return nil } -func (f *Plugin2) Collects() []interface{} { - return []interface{}{ +func (f *Plugin2) Collects() []any { + return []any{ f.GetSuper, f.GetSuper2, } diff --git a/tests/interfaces/named/randominterface/plugin2.go b/tests/interfaces/named/randominterface/plugin2.go index 0462649..d00c32f 100755 --- a/tests/interfaces/named/randominterface/plugin2.go +++ b/tests/interfaces/named/randominterface/plugin2.go @@ -21,8 +21,8 @@ func (f *Plugin2) Stop() error { } // But provide some -func (f *Plugin2) Provides() []interface{} { - return []interface{}{ +func (f *Plugin2) Provides() []any { + return []any{ f.ProvideDB, } } diff --git a/tests/interfaces/named/registers/plugin2.go b/tests/interfaces/named/registers/plugin2.go index 23355e1..f31f25c 100755 --- a/tests/interfaces/named/registers/plugin2.go +++ b/tests/interfaces/named/registers/plugin2.go @@ -28,8 +28,8 @@ func (f *Plugin2) Stop() error { } // But provide some -func (f *Plugin2) Provides() []interface{} { - return []interface{}{ +func (f *Plugin2) Provides() []any { + return []any{ f.ProvideDB, f.ProvideDB2, } diff --git a/tests/interfaces/named/registersfail/plugin2.go b/tests/interfaces/named/registersfail/plugin2.go index 483a41f..9d0a04d 100755 --- a/tests/interfaces/named/registersfail/plugin2.go +++ b/tests/interfaces/named/registersfail/plugin2.go @@ -24,8 +24,8 @@ func (f *Plugin2) Stop() error { } // But provide some -func (f *Plugin2) Provides() []interface{} { - return []interface{}{ +func (f *Plugin2) Provides() []any { + return []any{ f.ProvideDB, } } diff --git a/tests/interfaces/plugins/plugin2/plugin2.go b/tests/interfaces/plugins/plugin2/plugin2.go index 7b77cdd..a9ac543 100755 --- a/tests/interfaces/plugins/plugin2/plugin2.go +++ b/tests/interfaces/plugins/plugin2/plugin2.go @@ -25,8 +25,8 @@ func (s *Plugin2) Stop() error { return nil } -func (s *Plugin2) Provides() []interface{} { - return []interface{}{s.ProvideInterface} +func (s *Plugin2) Provides() []any { + return []any{s.ProvideInterface} } func (s *Plugin2) ProvideInterface() (FooWriter, error) { diff --git a/tests/interfaces/plugins/plugin5/plugin5.go b/tests/interfaces/plugins/plugin5/plugin5.go index d5d579d..894b3d4 100755 --- a/tests/interfaces/plugins/plugin5/plugin5.go +++ b/tests/interfaces/plugins/plugin5/plugin5.go @@ -30,8 +30,8 @@ func (f9 *Plugin5) Stop() error { return nil } -func (f9 *Plugin5) Collects() []interface{} { - return []interface{}{ +func (f9 *Plugin5) Collects() []any { + return []any{ f9.AddMiddleware, } } diff --git a/tests/interfaces/plugins/plugin6/plugin.go b/tests/interfaces/plugins/plugin6/plugin.go index 801506d..25fbd4c 100644 --- a/tests/interfaces/plugins/plugin6/plugin.go +++ b/tests/interfaces/plugins/plugin6/plugin.go @@ -50,8 +50,8 @@ func (p *Plugin) ProvideWithOutName() (SuperInterface, error) { } // Provides declares factory methods. -func (p *Plugin) Provides() []interface{} { - return []interface{}{ +func (p *Plugin) Provides() []any { + return []any{ p.ProvideWithOutName, p.ProvideWithName, p.ProvideWithInterfaceAndStruct, diff --git a/tests/interfaces/plugins/plugin8/plugin8.go b/tests/interfaces/plugins/plugin8/plugin8.go index 96559c5..77b4437 100644 --- a/tests/interfaces/plugins/plugin8/plugin8.go +++ b/tests/interfaces/plugins/plugin8/plugin8.go @@ -11,12 +11,12 @@ type SomeInterface interface { } type Plugin8 struct { - collectedDeps []interface{} + collectedDeps []any } // No deps func (s *Plugin8) Init() error { - s.collectedDeps = make([]interface{}, 0, 6) + s.collectedDeps = make([]any, 0, 6) return nil } @@ -38,8 +38,8 @@ func (s *Plugin8) Name() string { return "plugin8" } -func (s *Plugin8) Collects() []interface{} { - return []interface{}{ +func (s *Plugin8) Collects() []any { + return []any{ s.SomeCollects, s.SomeCollects2, s.SomeCollects3, diff --git a/tests/issues/issue33/issue33.go b/tests/issues/issue33/issue33.go index 87d390c..a26a709 100755 --- a/tests/issues/issue33/issue33.go +++ b/tests/issues/issue33/issue33.go @@ -19,8 +19,8 @@ func (f *Plugin1) Stop() error { return nil } -func (f *Plugin1) Provides() []interface{} { - return []interface{}{ +func (f *Plugin1) Provides() []any { + return []any{ f, // <- should be a function } } diff --git a/tests/issues/issue54/plugin3/plugin3.go b/tests/issues/issue54/plugin3/plugin3.go index 7f44a5f..bf49fb6 100644 --- a/tests/issues/issue54/plugin3/plugin3.go +++ b/tests/issues/issue54/plugin3/plugin3.go @@ -27,8 +27,8 @@ func (p *Plugin3) Stop() error { return nil } -func (p *Plugin3) Provides() []interface{} { - return []interface{}{ +func (p *Plugin3) Provides() []any { + return []any{ p.AddDB, p.AddDBWithErr, p.OtherType, diff --git a/tests/issues/issue66/plugin3/plugin3.go b/tests/issues/issue66/plugin3/plugin3.go index 094336c..dda66dd 100644 --- a/tests/issues/issue66/plugin3/plugin3.go +++ b/tests/issues/issue66/plugin3/plugin3.go @@ -20,8 +20,8 @@ func (p *Plugin3) Stop() error { return nil } -func (p *Plugin3) Provides() []interface{} { - return []interface{}{ +func (p *Plugin3) Provides() []any { + return []any{ p.ProvidePlugin3DB, } } diff --git a/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p1/plugin1.go b/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p1/plugin1.go index b5821f7..008e69e 100644 --- a/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p1/plugin1.go +++ b/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p1/plugin1.go @@ -20,8 +20,8 @@ func (p1 *Plugin1) Stop() error { return nil } -func (p1 *Plugin1) Collects() []interface{} { - return []interface{}{ +func (p1 *Plugin1) Collects() []any { + return []any{ p1.GetP2, } } diff --git a/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p2/plugin2.go b/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p2/plugin2.go index bde0bdd..ddaf4e3 100644 --- a/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p2/plugin2.go +++ b/tests/stress/CollectorFuncReturn/CyclicDepsCollectsInit/p2/plugin2.go @@ -20,8 +20,8 @@ func (p2 *Plugin2) Stop() error { return nil } -func (p2 *Plugin2) Collects() []interface{} { - return []interface{}{ +func (p2 *Plugin2) Collects() []any { + return []any{ p2.GetP1, } } diff --git a/tests/stress/CollectorFuncReturn/foo.go b/tests/stress/CollectorFuncReturn/foo.go index c957a4c..7d66c6e 100755 --- a/tests/stress/CollectorFuncReturn/foo.go +++ b/tests/stress/CollectorFuncReturn/foo.go @@ -19,8 +19,8 @@ func (f *FooDep) Stop() error { return nil } -func (f *FooDep) Collects() []interface{} { - return []interface{}{ +func (f *FooDep) Collects() []any { + return []any{ f.AddService, } } diff --git a/tests/stress/CyclicDepsCollects/p1/plugin1.go b/tests/stress/CyclicDepsCollects/p1/plugin1.go index b5821f7..008e69e 100644 --- a/tests/stress/CyclicDepsCollects/p1/plugin1.go +++ b/tests/stress/CyclicDepsCollects/p1/plugin1.go @@ -20,8 +20,8 @@ func (p1 *Plugin1) Stop() error { return nil } -func (p1 *Plugin1) Collects() []interface{} { - return []interface{}{ +func (p1 *Plugin1) Collects() []any { + return []any{ p1.GetP2, } } diff --git a/tests/stress/CyclicDepsCollects/p2/plugin2.go b/tests/stress/CyclicDepsCollects/p2/plugin2.go index bde0bdd..ddaf4e3 100644 --- a/tests/stress/CyclicDepsCollects/p2/plugin2.go +++ b/tests/stress/CyclicDepsCollects/p2/plugin2.go @@ -20,8 +20,8 @@ func (p2 *Plugin2) Stop() error { return nil } -func (p2 *Plugin2) Collects() []interface{} { - return []interface{}{ +func (p2 *Plugin2) Collects() []any { + return []any{ p2.GetP1, } } diff --git a/tests/stress/ServeErr/foo3_serve_error.go b/tests/stress/ServeErr/foo3_serve_error.go index 973712b..d2a6940 100755 --- a/tests/stress/ServeErr/foo3_serve_error.go +++ b/tests/stress/ServeErr/foo3_serve_error.go @@ -3,8 +3,8 @@ package ServeErr type S3ServeError struct { } -func (s3 *S3ServeError) Collects() []interface{} { - return []interface{}{ +func (s3 *S3ServeError) Collects() []any { + return []any{ s3.SomeOtherDep, } } diff --git a/tests/stress/ServeErr/foo4ServeError.go b/tests/stress/ServeErr/foo4ServeError.go index c04f800..7e63cf4 100755 --- a/tests/stress/ServeErr/foo4ServeError.go +++ b/tests/stress/ServeErr/foo4ServeError.go @@ -15,8 +15,8 @@ func (s *S4ServeError) Init(s5 *S5) error { } // But provide some -func (s *S4ServeError) Provides() []interface{} { - return []interface{}{ +func (s *S4ServeError) Provides() []any { + return []any{ s.CreateAnotherDB, } } diff --git a/tests/stress/ServeErr/plugin2.go b/tests/stress/ServeErr/plugin2.go index dc2ad5b..67b003d 100755 --- a/tests/stress/ServeErr/plugin2.go +++ b/tests/stress/ServeErr/plugin2.go @@ -10,8 +10,8 @@ func (s2 *S2) Init(db *FOO4DB) error { return nil } -func (s2 *S2) Provides() []interface{} { - return []interface{}{s2.CreateDB} +func (s2 *S2) Provides() []any { + return []any{s2.CreateDB} } func (s2 *S2) CreateDB() (*DB, error) { diff --git a/tests/stress/ServeRetryErr/plugin3.go b/tests/stress/ServeRetryErr/plugin3.go index c2b10ad..51a4d3c 100755 --- a/tests/stress/ServeRetryErr/plugin3.go +++ b/tests/stress/ServeRetryErr/plugin3.go @@ -9,8 +9,8 @@ import ( type S3 struct { } -func (s3 *S3) Collects() []interface{} { - return []interface{}{ +func (s3 *S3) Collects() []any { + return []any{ s3.SomeOtherDep, } } @@ -36,8 +36,8 @@ func (s3 *S3) Stop() error { type S3Init struct { } -func (s3 *S3Init) Collects() []interface{} { - return []interface{}{ +func (s3 *S3Init) Collects() []any { + return []any{ s3.SomeOtherDep, } } diff --git a/tests/stress/stress_test.go b/tests/stress/stress_test.go index ceec426..2f44a56 100755 --- a/tests/stress/stress_test.go +++ b/tests/stress/stress_test.go @@ -58,7 +58,9 @@ func TestEndure_Serve_Err(t *testing.T) { assert.Error(t, err) } -/* The scenario for this test is the following: +/* + The scenario for this test is the following: + time X is 0s 1. After X+1s S2ServeErr produces error in Serve 2. At the same time at X+1s S1Err also produces error in Serve @@ -97,7 +99,9 @@ func TestEndure_Serve_Retry_Err(t *testing.T) { wg.Wait() } -/* The scenario for this test is the following: +/* + The scenario for this test is the following: + time X is 0s 1. After X+1s S2ServeErr produces error in Serve 2. At the same time at X+1s S1Err also produces error in Serve