github.com/sethvargo/go-limiter@v1.0.0/noopstore/store.go (about) 1 // Package noopstore defines a storage system for limiting that always allows 2 // requests. It's an empty store useful for testing or development. 3 package noopstore 4 5 import ( 6 "context" 7 "time" 8 9 "github.com/sethvargo/go-limiter" 10 ) 11 12 var _ limiter.Store = (*store)(nil) 13 14 type store struct{} 15 16 func New() (limiter.Store, error) { 17 return &store{}, nil 18 } 19 20 // Take always allows the request. 21 func (s *store) Take(_ context.Context, _ string) (uint64, uint64, uint64, bool, error) { 22 return 0, 0, 0, true, nil 23 } 24 25 // Get does nothing. 26 func (s *store) Get(_ context.Context, _ string) (uint64, uint64, error) { 27 return 0, 0, nil 28 } 29 30 // Set does nothing. 31 func (s *store) Set(_ context.Context, _ string, _ uint64, _ time.Duration) error { 32 return nil 33 } 34 35 // Burst does nothing. 36 func (s *store) Burst(_ context.Context, _ string, _ uint64) error { 37 return nil 38 } 39 40 // Close does nothing. 41 func (s *store) Close(_ context.Context) error { 42 return nil 43 }