11package endure
22
33import (
4- "log/slog"
54 "reflect"
65
76 "github.com/roadrunner-server/endure/v2/graph"
87 "github.com/roadrunner-server/errors"
8+ "go.uber.org/zap"
99)
1010
1111func (e * Endure ) resolveCollectorEdges (plugin any ) error {
@@ -20,13 +20,10 @@ func (e *Endure) resolveCollectorEdges(plugin any) error {
2020 if len (res ) > 0 {
2121 for j := 0 ; j < len (res ); j ++ {
2222 e .graph .AddEdge (graph .CollectsConnection , res [j ].Plugin (), plugin )
23- /*
24- Here we need to init the
25- */
2623 e .log .Debug ("collects edge found" ,
27- slog . Any ("method" , res [j ].Method ()),
28- slog . Any ("src" , e .graph .VertexById (res [j ].Plugin ()).ID ().String ()),
29- slog . Any ("dest" , e .graph .VertexById (plugin ).ID ().String ()))
24+ zap . String ("method" , res [j ].Method ()),
25+ zap . String ("src" , e .graph .VertexById (res [j ].Plugin ()).ID ().String ()),
26+ zap . String ("dest" , e .graph .VertexById (plugin ).ID ().String ()))
3027 }
3128 }
3229 }
@@ -35,7 +32,7 @@ func (e *Endure) resolveCollectorEdges(plugin any) error {
3532}
3633
3734// resolveEdges adds edges between the vertices
38- // At this point, we know all plugins, and all provides values
35+ // At this point, we know all plugins and all ' provides' values
3936func (e * Endure ) resolveEdges () error {
4037 vertices := e .graph .Vertices ()
4138
@@ -51,8 +48,8 @@ func (e *Endure) resolveEdges() error {
5148 if isPrimitive (initMethod .Type .In (j ).String ()) {
5249 e .log .Error (
5350 "primitive type in the function parameters" ,
54- slog .String ("plugin" , vertices [i ].ID ().String ()),
55- slog .String ("type" , initMethod .Type .In (j ).String ()),
51+ zap .String ("plugin" , vertices [i ].ID ().String ()),
52+ zap .String ("type" , initMethod .Type .In (j ).String ()),
5653 )
5754
5855 return errors .E ("Init method should not receive primitive types (like string, int, etc). It should receive only interfaces" )
@@ -81,22 +78,22 @@ func (e *Endure) resolveEdges() error {
8178 // log
8279 e .log .Debug (
8380 "init edge found" ,
84- slog .Any ("src" , e .graph .VertexById (res [k ].Plugin ()).ID ().String ()),
85- slog .Any ("dest" , e .graph .VertexById (vertex .Plugin ()).ID ().String ()),
81+ zap .Any ("src" , e .graph .VertexById (res [k ].Plugin ()).ID ().String ()),
82+ zap .Any ("dest" , e .graph .VertexById (vertex .Plugin ()).ID ().String ()),
8683 )
8784 }
8885 }
8986 }
9087
91- // we should have here exact the same number of the deps implementing every particular arg
88+ // we should have here exactly the same number of the deps implementing every particular arg
9289 if count != len (args [1 :]) {
9390 // if there are no plugins that implement Init deps, remove this vertex from the tree
9491 del := e .graph .Remove (vertices [i ].Plugin ())
9592 for k := 0 ; k < len (del ); k ++ {
9693 e .registar .Remove (del [k ].Plugin ())
9794 e .log .Debug (
9895 "plugin disabled, not enough Init dependencies" ,
99- slog .String ("name" , del [k ].ID ().String ()),
96+ zap .String ("name" , del [k ].ID ().String ()),
10097 )
10198 }
10299
@@ -117,8 +114,8 @@ func (e *Endure) resolveEdges() error {
117114
118115 e .graph .TopologicalSort ()
119116
120- // notify user about the disabled plugins
121- // after topological sorting we remove all plugins with indegree > 0, because there are no edges to them
117+ // to notify user about the disabled plugins
118+ // after topological sorting, we remove all plugins with indegree > 0, because there are no edges to them
122119 if len (e .graph .TopologicalOrder ()) != len (e .graph .Vertices ()) {
123120 tpl := e .graph .TopologicalOrder ()
124121 vrt := e .graph .Vertices ()
@@ -130,7 +127,7 @@ func (e *Endure) resolveEdges() error {
130127
131128 for _ , v := range vrt {
132129 if _ , ok := tmpM [v .ID ().String ()]; ! ok {
133- e .log .Warn ("topological sort, plugin disabled" , slog .String ("plugin" , v .ID ().String ()))
130+ e .log .Warn ("topological sort, plugin disabled" , zap .String ("plugin" , v .ID ().String ()))
134131 }
135132 }
136133 }
0 commit comments