github.com/m3db/m3@v1.5.0/src/dbnode/storage/bootstrap/result/options.go (about)

     1  // Copyright (c) 2016 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 result
    22  
    23  import (
    24  	"github.com/m3db/m3/src/dbnode/storage/block"
    25  	"github.com/m3db/m3/src/dbnode/storage/series"
    26  	"github.com/m3db/m3/src/x/clock"
    27  	"github.com/m3db/m3/src/x/instrument"
    28  )
    29  
    30  const (
    31  	defaultNewBlocksLen = 2
    32  )
    33  
    34  type options struct {
    35  	clockOpts                 clock.Options
    36  	instrumentOpts            instrument.Options
    37  	blockOpts                 block.Options
    38  	newBlocksLen              int
    39  	seriesCachePolicy         series.CachePolicy
    40  	documentsBuilderAllocator DocumentsBuilderAllocator
    41  }
    42  
    43  // NewOptions creates new bootstrap options
    44  func NewOptions() Options {
    45  	return &options{
    46  		clockOpts:                 clock.NewOptions(),
    47  		instrumentOpts:            instrument.NewOptions(),
    48  		blockOpts:                 block.NewOptions(),
    49  		newBlocksLen:              defaultNewBlocksLen,
    50  		seriesCachePolicy:         series.DefaultCachePolicy,
    51  		documentsBuilderAllocator: NewDefaultDocumentsBuilderAllocator(),
    52  	}
    53  }
    54  
    55  func (o *options) SetClockOptions(value clock.Options) Options {
    56  	opts := *o
    57  	opts.clockOpts = value
    58  	return &opts
    59  }
    60  
    61  func (o *options) ClockOptions() clock.Options {
    62  	return o.clockOpts
    63  }
    64  
    65  func (o *options) SetInstrumentOptions(value instrument.Options) Options {
    66  	opts := *o
    67  	opts.instrumentOpts = value
    68  	return &opts
    69  }
    70  
    71  func (o *options) InstrumentOptions() instrument.Options {
    72  	return o.instrumentOpts
    73  }
    74  
    75  func (o *options) SetDatabaseBlockOptions(value block.Options) Options {
    76  	opts := *o
    77  	opts.blockOpts = value
    78  	return &opts
    79  }
    80  
    81  func (o *options) DatabaseBlockOptions() block.Options {
    82  	return o.blockOpts
    83  }
    84  
    85  func (o *options) SetNewBlocksLen(value int) Options {
    86  	opts := *o
    87  	opts.newBlocksLen = value
    88  	return &opts
    89  }
    90  
    91  func (o *options) NewBlocksLen() int {
    92  	return o.newBlocksLen
    93  }
    94  
    95  func (o *options) SetSeriesCachePolicy(value series.CachePolicy) Options {
    96  	opts := *o
    97  	opts.seriesCachePolicy = value
    98  	return &opts
    99  }
   100  
   101  func (o *options) SeriesCachePolicy() series.CachePolicy {
   102  	return o.seriesCachePolicy
   103  }
   104  
   105  func (o *options) SetIndexDocumentsBuilderAllocator(value DocumentsBuilderAllocator) Options {
   106  	opts := *o
   107  	opts.documentsBuilderAllocator = value
   108  	return &opts
   109  }
   110  
   111  func (o *options) IndexDocumentsBuilderAllocator() DocumentsBuilderAllocator {
   112  	return o.documentsBuilderAllocator
   113  }