github.com/m3db/m3@v1.5.0/src/cmd/tools/dtest/util/seed/options.go (about) 1 // Copyright (c) 2018 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 seed 22 23 import ( 24 "math/rand" 25 "time" 26 27 "github.com/m3db/m3/src/dbnode/integration/generate" 28 "github.com/m3db/m3/src/x/instrument" 29 ) 30 31 const ( 32 defaulNumSeries = 30000 33 defaultMinPointsPerID = 50 34 defaultMaxPointsPerID = 150 35 defaultMeanIDLength = 152.0 36 defaultStddevIDLength = 66.0 37 ) 38 39 type opts struct { 40 generateOpts generate.Options 41 iOpts instrument.Options 42 source rand.Source 43 numIDs int 44 minPointsPerID int 45 maxPointsPerID int 46 idLenMean float64 47 idLenStddev float64 48 } 49 50 // NewOptions returns new options 51 func NewOptions() Options { 52 return &opts{ 53 generateOpts: generate.NewOptions(), 54 iOpts: instrument.NewOptions(), 55 source: rand.NewSource(time.Now().UnixNano()), 56 numIDs: defaulNumSeries, 57 minPointsPerID: defaultMinPointsPerID, 58 maxPointsPerID: defaultMaxPointsPerID, 59 idLenMean: defaultMeanIDLength, 60 idLenStddev: defaultStddevIDLength, 61 } 62 } 63 64 func (o *opts) SetInstrumentOptions(io instrument.Options) Options { 65 o.iOpts = io 66 return o 67 } 68 69 func (o *opts) InstrumentOptions() instrument.Options { 70 return o.iOpts 71 } 72 73 func (o *opts) SetGenerateOptions(op generate.Options) Options { 74 o.generateOpts = op 75 return o 76 } 77 78 func (o *opts) GenerateOptions() generate.Options { 79 return o.generateOpts 80 } 81 82 func (o *opts) SetRandSource(src rand.Source) Options { 83 o.source = src 84 return o 85 } 86 87 func (o *opts) RandSource() rand.Source { 88 return o.source 89 } 90 91 func (o *opts) SetNumIDs(ni int) Options { 92 o.numIDs = ni 93 return o 94 } 95 96 func (o *opts) NumIDs() int { 97 return o.numIDs 98 } 99 100 func (o *opts) SetMinNumPointsPerID(m int) Options { 101 o.minPointsPerID = m 102 return o 103 } 104 105 func (o *opts) MinNumPointsPerID() int { 106 return o.minPointsPerID 107 } 108 109 func (o *opts) SetMaxNumPointsPerID(m int) Options { 110 o.maxPointsPerID = m 111 return o 112 } 113 114 func (o *opts) MaxNumPointsPerID() int { 115 return o.maxPointsPerID 116 } 117 118 func (o *opts) SetIDLengthMean(l float64) Options { 119 o.idLenMean = l 120 return o 121 } 122 123 func (o *opts) IDLengthMean() float64 { 124 return o.idLenMean 125 } 126 127 func (o *opts) SetIDLengthStddev(l float64) Options { 128 o.idLenStddev = l 129 return o 130 } 131 132 func (o *opts) IDLengthStddev() float64 { 133 return o.idLenStddev 134 }