github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/protoc/plugin_registry.go (about)

     1  package protoc
     2  
     3  import "errors"
     4  
     5  // ErrUnknownPlugin is the error returned when a plugin is not known.
     6  var ErrUnknownPlugin = errors.New("unknown plugin")
     7  
     8  // PluginRegistry represents a library of plugin implementations.
     9  type PluginRegistry interface {
    10  	// PluginNames returns a sorted list of plugin names.
    11  	PluginNames() []string
    12  	// LookupPlugin returns the implementation under the given name.  If the
    13  	// plugin is not found, ErrUnknownPlugin is returned.
    14  	LookupPlugin(name string) (Plugin, error)
    15  	// MustRegisterPlugin installs a Plugin implementation under the given name
    16  	// in the global plugin registry.  Panic will occur if the same plugin is
    17  	// registered multiple times.
    18  	MustRegisterPlugin(plugin Plugin) PluginRegistry
    19  	// RegisterPlugin installs a Plugin implementation under the given name.
    20  	// Panic will occur if the same plugin is registered multiple times.  The
    21  	// original PluginRegistry API had only the `MustRegisterPlugin` function
    22  	// that always used the plugin.Name(), the newer `RegisterPlugin` allows one
    23  	// to customize the name.
    24  	RegisterPlugin(name string, plugin Plugin) PluginRegistry
    25  }