filter.go 741 B

1234567891011121314151617181920
  1. package filter
  2. // Filter represents anything that can be used to filter given generic type T.
  3. //
  4. // Implement this interface with caution. While it is generic, it
  5. // is intended to be introspectable so query handlers can perform various
  6. // optimizations. These optimizations include:
  7. // - Routing a query to the most optimal cache
  8. // - Querying backing data stores efficiently (e.g. translation to SQL)
  9. //
  10. // Custom implementations of this interface outside of this package should not
  11. // expect to receive these benefits. Passing a custom implementation to a
  12. // handler may in errors.
  13. type Filter[T any] interface {
  14. String() string
  15. // Matches is the canonical in-Go function for determining if T
  16. // matches a filter.
  17. Matches(T) bool
  18. }