processor.go 850 B

123456789101112131415161718192021222324252627
  1. package backends
  2. import (
  3. "github.com/flashmob/go-guerrilla/envelope"
  4. )
  5. // Our processor is defined as something that processes the envelope and returns a result and error
  6. type Processor interface {
  7. Process(*envelope.Envelope) (BackendResult, error)
  8. }
  9. // Signature of DoFunc
  10. type ProcessorFunc func(*envelope.Envelope) (BackendResult, error)
  11. // Make ProcessorFunc will satisfy the Processor interface
  12. func (f ProcessorFunc) Process(e *envelope.Envelope) (BackendResult, error) {
  13. return f(e)
  14. }
  15. // DefaultProcessor is a undecorated worker that does nothing
  16. // Notice MockClient has no knowledge of the other decorators that have orthogonal concerns.
  17. type DefaultProcessor struct{}
  18. // do nothing except return the result
  19. func (w DefaultProcessor) Process(e *envelope.Envelope) (BackendResult, error) {
  20. return NewBackendResult("200 OK"), nil
  21. }