@@ -107,7 +107,11 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
107107 config : config ,
108108 }
109109 initialized = plugin .NewPluginSet ()
110+ required = make (map [string ]struct {})
110111 )
112+ for _ , r := range config .RequiredPlugins {
113+ required [r ] = struct {}{}
114+ }
111115 for _ , p := range plugins {
112116 id := p .URI ()
113117 log .G (ctx ).WithField ("type" , p .Type ).Infof ("loading plugin %q..." , id )
@@ -142,8 +146,12 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
142146 } else {
143147 log .G (ctx ).WithError (err ).Warnf ("failed to load plugin %s" , id )
144148 }
149+ if _ , ok := required [p .ID ]; ok {
150+ return nil , errors .Wrapf (err , "load required plugin %s" , id )
151+ }
145152 continue
146153 }
154+ delete (required , p .ID )
147155 // check for grpc services that should be registered with the server
148156 if src , ok := instance .(plugin.Service ); ok {
149157 grpcServices = append (grpcServices , src )
@@ -153,6 +161,14 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
153161 }
154162 s .plugins = append (s .plugins , result )
155163 }
164+ if len (required ) != 0 {
165+ var missing []string
166+ for id := range required {
167+ missing = append (missing , id )
168+ }
169+ return nil , errors .Errorf ("required plugin %s not included" , missing )
170+ }
171+
156172 // register services after all plugins have been initialized
157173 for _ , service := range grpcServices {
158174 if err := service .Register (grpcServer ); err != nil {
0 commit comments