proxy.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package logger // import "github.com/docker/docker/daemon/logger"
  2. import (
  3. "errors"
  4. "io"
  5. )
  6. type client interface {
  7. Call(string, interface{}, interface{}) error
  8. Stream(string, interface{}) (io.ReadCloser, error)
  9. }
  10. type logPluginProxy struct {
  11. client
  12. }
  13. type logPluginProxyStartLoggingRequest struct {
  14. File string
  15. Info Info
  16. }
  17. type logPluginProxyStartLoggingResponse struct {
  18. Err string
  19. }
  20. func (pp *logPluginProxy) StartLogging(file string, info Info) (err error) {
  21. var (
  22. req logPluginProxyStartLoggingRequest
  23. ret logPluginProxyStartLoggingResponse
  24. )
  25. req.File = file
  26. req.Info = info
  27. if err = pp.Call("LogDriver.StartLogging", req, &ret); err != nil {
  28. return
  29. }
  30. if ret.Err != "" {
  31. err = errors.New(ret.Err)
  32. }
  33. return
  34. }
  35. type logPluginProxyStopLoggingRequest struct {
  36. File string
  37. }
  38. type logPluginProxyStopLoggingResponse struct {
  39. Err string
  40. }
  41. func (pp *logPluginProxy) StopLogging(file string) (err error) {
  42. var (
  43. req logPluginProxyStopLoggingRequest
  44. ret logPluginProxyStopLoggingResponse
  45. )
  46. req.File = file
  47. if err = pp.Call("LogDriver.StopLogging", req, &ret); err != nil {
  48. return
  49. }
  50. if ret.Err != "" {
  51. err = errors.New(ret.Err)
  52. }
  53. return
  54. }
  55. type logPluginProxyCapabilitiesResponse struct {
  56. Cap Capability
  57. Err string
  58. }
  59. func (pp *logPluginProxy) Capabilities() (cap Capability, err error) {
  60. var ret logPluginProxyCapabilitiesResponse
  61. if err = pp.Call("LogDriver.Capabilities", nil, &ret); err != nil {
  62. return
  63. }
  64. cap = ret.Cap
  65. if ret.Err != "" {
  66. err = errors.New(ret.Err)
  67. }
  68. return
  69. }
  70. type logPluginProxyReadLogsRequest struct {
  71. Info Info
  72. Config ReadConfig
  73. }
  74. func (pp *logPluginProxy) ReadLogs(info Info, config ReadConfig) (stream io.ReadCloser, err error) {
  75. var req logPluginProxyReadLogsRequest
  76. req.Info = info
  77. req.Config = config
  78. return pp.Stream("LogDriver.ReadLogs", req)
  79. }