gitlab.com/infor-cloud/martian-cloud/tharsis/go-limiter@v0.0.0-20230411193226-3247984d5abc/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 "gitlab.com/infor-cloud/martian-cloud/tharsis/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 func (s *store) TakeMany(_ context.Context, _ string, _ uint64) (uint64, uint64, uint64, bool, error) { 26 return 0, 0, 0, true, nil 27 } 28 29 // Get does nothing. 30 func (s *store) Get(_ context.Context, _ string) (uint64, uint64, error) { 31 return 0, 0, nil 32 } 33 34 // Set does nothing. 35 func (s *store) Set(_ context.Context, _ string, _ uint64, _ time.Duration) error { 36 return nil 37 } 38 39 // Burst does nothing. 40 func (s *store) Burst(_ context.Context, _ string, _ uint64) error { 41 return nil 42 } 43 44 // Close does nothing. 45 func (s *store) Close(_ context.Context) error { 46 return nil 47 }