github.com/m3db/m3@v1.5.0/src/dbnode/storage/limits/permits/options.go (about) 1 // Copyright (c) 2021 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package permits 22 23 import ( 24 "time" 25 26 "github.com/m3db/m3/src/x/instrument" 27 ) 28 29 type options struct { 30 seriesReadManager Manager 31 indexQueryManager Manager 32 } 33 34 // NewOptions return a new set of default permit managers. 35 func NewOptions() Options { 36 // provide some defaults to exercise parallel processing in tests. 37 return &options{ 38 seriesReadManager: NewFixedPermitsManager( 39 100000, 40 100, 41 instrument.NewOptions()), 42 indexQueryManager: NewFixedPermitsManager( 43 8, 44 int64(time.Millisecond*10), 45 instrument.NewOptions()), 46 } 47 } 48 49 // SetSeriesReadPermitsManager sets the series read permits manager. 50 func (o *options) SetSeriesReadPermitsManager(value Manager) Options { 51 opts := *o 52 opts.seriesReadManager = value 53 return &opts 54 } 55 56 // SeriesReadPermitsManager returns the series read permits manager. 57 func (o *options) SeriesReadPermitsManager() Manager { 58 return o.seriesReadManager 59 } 60 61 func (o *options) IndexQueryPermitsManager() Manager { 62 return o.indexQueryManager 63 } 64 65 func (o *options) SetIndexQueryPermitsManager(value Manager) Options { 66 opts := *o 67 opts.indexQueryManager = value 68 return &opts 69 }