getter.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package plugingetter // import "github.com/docker/docker/pkg/plugingetter"
  2. import (
  3. "net"
  4. "time"
  5. "github.com/docker/docker/pkg/plugins"
  6. )
  7. const (
  8. // Lookup doesn't update RefCount
  9. Lookup = 0
  10. // Acquire increments RefCount
  11. Acquire = 1
  12. // Release decrements RefCount
  13. Release = -1
  14. )
  15. // CompatPlugin is an abstraction to handle both v2(new) and v1(legacy) plugins.
  16. type CompatPlugin interface {
  17. Name() string
  18. ScopedPath(string) string
  19. IsV1() bool
  20. PluginWithV1Client
  21. }
  22. // PluginWithV1Client is a plugin that directly utilizes the v1/http plugin client
  23. type PluginWithV1Client interface {
  24. Client() *plugins.Client
  25. }
  26. // PluginAddr is a plugin that exposes the socket address for creating custom clients rather than the built-in `*plugins.Client`
  27. type PluginAddr interface {
  28. Addr() net.Addr
  29. Timeout() time.Duration
  30. Protocol() string
  31. }
  32. // CountedPlugin is a plugin which is reference counted.
  33. type CountedPlugin interface {
  34. Acquire()
  35. Release()
  36. CompatPlugin
  37. }
  38. // PluginGetter is the interface implemented by Store
  39. type PluginGetter interface {
  40. Get(name, capability string, mode int) (CompatPlugin, error)
  41. GetAllByCap(capability string) ([]CompatPlugin, error)
  42. GetAllManagedPluginsByCap(capability string) []CompatPlugin
  43. Handle(capability string, callback func(string, *plugins.Client))
  44. }