/
options.go
1092 lines (902 loc) · 33.9 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package client
import (
"errors"
"io"
"math"
"runtime"
"time"
"github.com/m3db/m3/src/dbnode/encoding"
"github.com/m3db/m3/src/dbnode/encoding/m3tsz"
"github.com/m3db/m3/src/dbnode/encoding/proto"
"github.com/m3db/m3/src/dbnode/environment"
"github.com/m3db/m3/src/dbnode/generated/thrift/rpc"
"github.com/m3db/m3/src/dbnode/namespace"
nchannel "github.com/m3db/m3/src/dbnode/network/server/tchannelthrift/node/channel"
m3dbruntime "github.com/m3db/m3/src/dbnode/runtime"
"github.com/m3db/m3/src/dbnode/storage/index"
"github.com/m3db/m3/src/dbnode/topology"
"github.com/m3db/m3/src/x/clock"
"github.com/m3db/m3/src/x/context"
"github.com/m3db/m3/src/x/ident"
"github.com/m3db/m3/src/x/instrument"
"github.com/m3db/m3/src/x/pool"
xretry "github.com/m3db/m3/src/x/retry"
"github.com/m3db/m3/src/x/sampler"
"github.com/m3db/m3/src/x/serialize"
xsync "github.com/m3db/m3/src/x/sync"
"github.com/uber/tchannel-go"
"github.com/uber/tchannel-go/thrift"
)
const (
// DefaultWriteBatchSize is the default write and write tagged batch size.
DefaultWriteBatchSize = 128
// defaultWriteConsistencyLevel is the default write consistency level
defaultWriteConsistencyLevel = m3dbruntime.DefaultWriteConsistencyLevel
// defaultReadConsistencyLevel is the default read consistency level
defaultReadConsistencyLevel = m3dbruntime.DefaultReadConsistencyLevel
// defaultBootstrapConsistencyLevel is the default bootstrap consistency level
defaultBootstrapConsistencyLevel = m3dbruntime.DefaultBootstrapConsistencyLevel
// defaultMaxConnectionCount is the default max connection count
defaultMaxConnectionCount = 32
// defaultMinConnectionCount is the default min connection count
defaultMinConnectionCount = 2
// defaultHostConnectTimeout is the default host connection timeout
defaultHostConnectTimeout = 5 * time.Second
// defaultClusterConnectTimeout is the default cluster connect timeout
defaultClusterConnectTimeout = 20 * time.Second
// defaultClusterConnectConsistencyLevel is the default cluster connect consistency level
defaultClusterConnectConsistencyLevel = topology.ConnectConsistencyLevelAny
// defaultWriteRequestTimeout is the default write request timeout
defaultWriteRequestTimeout = 10 * time.Second
// defaultFetchRequestTimeout is the default fetch request timeout
defaultFetchRequestTimeout = 15 * time.Second
// defaultTruncateRequestTimeout is the default truncate request timeout
defaultTruncateRequestTimeout = 60 * time.Second
// defaultWriteShardsInitializing is the default write to shards intializing value
defaultWriteShardsInitializing = true
// defaultShardsLeavingCountTowardsConsistency is the default shards leaving count towards consistency
defaultShardsLeavingCountTowardsConsistency = false
// defaultIdentifierPoolSize is the default identifier pool size
defaultIdentifierPoolSize = 8192
// defaultWriteOpPoolSize is the default write op pool size
defaultWriteOpPoolSize = 65536
// defaultWriteTaggedOpPoolSize is the default write tagged op pool size
defaultWriteTaggedOpPoolSize = 65536
// defaultFetchBatchOpPoolSize is the default fetch op pool size
defaultFetchBatchOpPoolSize = 1024
// defaultFetchBatchSize is the default fetch batch size
defaultFetchBatchSize = 128
// defaultCheckedBytesWrapperPoolSize is the default checkedBytesWrapperPoolSize
defaultCheckedBytesWrapperPoolSize = 65536
// defaultHostQueueOpsFlushSize is the default host queue ops flush size
defaultHostQueueOpsFlushSize = 128
// defaultHostQueueOpsFlushInterval is the default host queue flush interval
defaultHostQueueOpsFlushInterval = 5 * time.Millisecond
// defaultHostQueueOpsArrayPoolSize is the default host queue ops array pool size
defaultHostQueueOpsArrayPoolSize = 8
// defaultHostQueueEmitsHealthStatus is false
defaultHostQueueEmitsHealthStatus = true
// defaultBackgroundConnectInterval is the default background connect interval
defaultBackgroundConnectInterval = 4 * time.Second
// defaultBackgroundConnectStutter is the default background connect stutter
defaultBackgroundConnectStutter = 2 * time.Second
// defaultBackgroundHealthCheckInterval is the default background health check interval
defaultBackgroundHealthCheckInterval = 4 * time.Second
// defaultBackgroundHealthCheckStutter is the default background health check stutter
defaultBackgroundHealthCheckStutter = 2 * time.Second
// defaultBackgroundHealthCheckFailLimit is the default background health failure
// limit before connection is deemed unhealth
defaultBackgroundHealthCheckFailLimit = 4
// defaultBackgroundHealthCheckFailThrottleFactor is the default throttle factor to
// apply when calculating how long to wait between a failed health check and a
// retry attempt. It is applied by multiplying against the host connect
// timeout to produce a throttle sleep value.
defaultBackgroundHealthCheckFailThrottleFactor = 0.5
// defaultSeriesIteratorPoolSize is the default size of the series iterator pools
defaultSeriesIteratorPoolSize = 65536
// defaultTagEncoderPoolSize is the default size of the tag encoder pool.
defaultTagEncoderPoolSize = 4096
// defaultTagDecoderPoolSize is the default size of the tag decoder pool.
defaultTagDecoderPoolSize = 4096
// defaultFetchSeriesBlocksMaxBlockRetries is the default max retries for fetch series blocks
// from a single peer
defaultFetchSeriesBlocksMaxBlockRetries = 2
// defaultFetchSeriesBlocksBatchSize is the default fetch series blocks batch size
defaultFetchSeriesBlocksBatchSize = 4096
// defaultFetchSeriesBlocksMetadataBatchTimeout is the default series blocks metadata fetch timeout
defaultFetchSeriesBlocksMetadataBatchTimeout = 60 * time.Second
// defaultFetchSeriesBlocksMetadataBatchTimeout is the default series blocks contents fetch timeout
defaultFetchSeriesBlocksBatchTimeout = 60 * time.Second
// defaultAsyncWriteMaxConcurrency is the default maximum concurrency for async writes.
defaultAsyncWriteMaxConcurrency = 4096
// defaultUseV2BatchAPIs is the default setting for whether the v2 version of the batch APIs should
// be used.
defaultUseV2BatchAPIs = false
)
var (
// defaultIdentifierPoolBytesPoolSizes is the default bytes pool sizes for the identifier pool
defaultIdentifierPoolBytesPoolSizes = []pool.Bucket{
{Capacity: 256, Count: defaultIdentifierPoolSize},
}
// defaultFetchSeriesBlocksBatchConcurrency is the default fetch series blocks in batch parallel concurrency limit
defaultFetchSeriesBlocksBatchConcurrency = int(math.Max(1, float64(runtime.NumCPU())/2))
// defaultSeriesIteratorArrayPoolBuckets is the default pool buckets for the series iterator array pool
defaultSeriesIteratorArrayPoolBuckets = []pool.Bucket{}
// defaulWriteRetrier is the default write retrier for write attempts
defaultWriteRetrier = xretry.NewRetrier(
xretry.NewOptions().
SetInitialBackoff(500 * time.Millisecond).
SetBackoffFactor(3).
SetMaxRetries(2).
SetJitter(true))
// defaultFetchRetrier is the default fetch retrier for fetch attempts
defaultFetchRetrier = xretry.NewRetrier(
xretry.NewOptions().
SetInitialBackoff(500 * time.Millisecond).
SetBackoffFactor(2).
SetMaxRetries(3).
SetJitter(true))
// defaultStreamBlocksRetrier is the default retrier for streaming blocks
defaultStreamBlocksRetrier = xretry.NewRetrier(
xretry.NewOptions().
SetBackoffFactor(2).
SetMaxRetries(3).
SetInitialBackoff(2 * time.Second).
SetJitter(true),
)
// defaultChannelOptions are default tchannel channel options.
defaultChannelOptions = &tchannel.ChannelOptions{
MaxIdleTime: 5 * time.Minute,
IdleCheckInterval: 5 * time.Minute,
}
errNoTopologyInitializerSet = errors.New("no topology initializer set")
errNoReaderIteratorAllocateSet = errors.New("no reader iterator allocator set, encoding not set")
)
type options struct {
runtimeOptsMgr m3dbruntime.OptionsManager
clockOpts clock.Options
instrumentOpts instrument.Options
logErrorSampleRate sampler.Rate
topologyInitializer topology.Initializer
readConsistencyLevel topology.ReadConsistencyLevel
writeConsistencyLevel topology.ConsistencyLevel
bootstrapConsistencyLevel topology.ReadConsistencyLevel
channelOptions *tchannel.ChannelOptions
maxConnectionCount int
minConnectionCount int
hostConnectTimeout time.Duration
clusterConnectTimeout time.Duration
clusterConnectConsistencyLevel topology.ConnectConsistencyLevel
writeRequestTimeout time.Duration
fetchRequestTimeout time.Duration
truncateRequestTimeout time.Duration
backgroundConnectInterval time.Duration
backgroundConnectStutter time.Duration
backgroundHealthCheckInterval time.Duration
backgroundHealthCheckStutter time.Duration
backgroundHealthCheckFailLimit int
backgroundHealthCheckFailThrottleFactor float64
tagEncoderOpts serialize.TagEncoderOptions
tagEncoderPoolSize int
tagDecoderOpts serialize.TagDecoderOptions
tagDecoderPoolSize int
writeRetrier xretry.Retrier
fetchRetrier xretry.Retrier
streamBlocksRetrier xretry.Retrier
writeShardsInitializing bool
shardsLeavingCountTowardsConsistency bool
newConnectionFn NewConnectionFn
readerIteratorAllocate encoding.ReaderIteratorAllocate
writeOperationPoolSize int
writeTaggedOperationPoolSize int
fetchBatchOpPoolSize int
writeBatchSize int
fetchBatchSize int
identifierPool ident.Pool
hostQueueOpsFlushSize int
hostQueueOpsFlushInterval time.Duration
hostQueueOpsArrayPoolSize int
hostQueueEmitsHealthStatus bool
seriesIteratorPoolSize int
seriesIteratorArrayPoolBuckets []pool.Bucket
checkedBytesWrapperPoolSize int
contextPool context.Pool
origin topology.Host
fetchSeriesBlocksMaxBlockRetries int
fetchSeriesBlocksBatchSize int
fetchSeriesBlocksMetadataBatchTimeout time.Duration
fetchSeriesBlocksBatchTimeout time.Duration
fetchSeriesBlocksBatchConcurrency int
schemaRegistry namespace.SchemaRegistry
isProtoEnabled bool
asyncTopologyInitializers []topology.Initializer
asyncWriteWorkerPool xsync.PooledWorkerPool
asyncWriteMaxConcurrency int
useV2BatchAPIs bool
iterationOptions index.IterationOptions
writeTimestampOffset time.Duration
namespaceInitializer namespace.Initializer
}
// NewOptions creates a new set of client options with defaults
func NewOptions() Options {
return newOptions()
}
// NewAdminOptions creates a new set of administration client options with defaults
func NewAdminOptions() AdminOptions {
return newOptions()
}
// NewOptionsForAsyncClusters returns a slice of Options, where each is the set of client
// for a given async client.
func NewOptionsForAsyncClusters(opts Options, topoInits []topology.Initializer, overrides []environment.ClientOverrides) []Options {
result := make([]Options, 0, len(opts.AsyncTopologyInitializers()))
for i, topoInit := range topoInits {
options := opts.SetTopologyInitializer(topoInit)
if overrides[i].HostQueueFlushInterval != nil {
options = options.SetHostQueueOpsFlushInterval(*overrides[i].HostQueueFlushInterval)
}
if overrides[i].TargetHostQueueFlushSize != nil {
options = options.SetHostQueueOpsFlushSize(*overrides[i].TargetHostQueueFlushSize)
}
result = append(result, options)
}
return result
}
func defaultNewConnectionFn(
channelName string, address string, clientOpts Options,
) (PooledChannel, rpc.TChanNode, error) {
// NB(r): Keep ref to a local channel options since it's actually modified
// by TChannel itself to set defaults.
var opts *tchannel.ChannelOptions
if chanOpts := clientOpts.ChannelOptions(); chanOpts != nil {
immutableOpts := *chanOpts
opts = &immutableOpts
}
channel, err := tchannel.NewChannel(channelName, opts)
if err != nil {
return nil, nil, err
}
endpoint := &thrift.ClientOptions{HostPort: address}
thriftClient := thrift.NewClient(channel, nchannel.ChannelName, endpoint)
client := rpc.NewTChanNodeClient(thriftClient)
return channel, client, nil
}
func newOptions() *options {
buckets := defaultIdentifierPoolBytesPoolSizes
bytesPool := pool.NewCheckedBytesPool(buckets, nil,
func(sizes []pool.Bucket) pool.BytesPool {
return pool.NewBytesPool(sizes, nil)
})
bytesPool.Init()
poolOpts := pool.NewObjectPoolOptions().
SetSize(defaultIdentifierPoolSize)
idPool := ident.NewPool(bytesPool, ident.PoolOptions{
IDPoolOptions: poolOpts,
TagsPoolOptions: poolOpts,
TagsIteratorPoolOptions: poolOpts,
})
contextPool := context.NewPool(context.NewOptions().
SetContextPoolOptions(poolOpts).
SetFinalizerPoolOptions(poolOpts))
opts := &options{
clockOpts: clock.NewOptions(),
instrumentOpts: instrument.NewOptions(),
channelOptions: defaultChannelOptions,
writeConsistencyLevel: defaultWriteConsistencyLevel,
readConsistencyLevel: defaultReadConsistencyLevel,
bootstrapConsistencyLevel: defaultBootstrapConsistencyLevel,
maxConnectionCount: defaultMaxConnectionCount,
minConnectionCount: defaultMinConnectionCount,
hostConnectTimeout: defaultHostConnectTimeout,
clusterConnectTimeout: defaultClusterConnectTimeout,
clusterConnectConsistencyLevel: defaultClusterConnectConsistencyLevel,
writeRequestTimeout: defaultWriteRequestTimeout,
fetchRequestTimeout: defaultFetchRequestTimeout,
truncateRequestTimeout: defaultTruncateRequestTimeout,
backgroundConnectInterval: defaultBackgroundConnectInterval,
backgroundConnectStutter: defaultBackgroundConnectStutter,
backgroundHealthCheckInterval: defaultBackgroundHealthCheckInterval,
backgroundHealthCheckStutter: defaultBackgroundHealthCheckStutter,
backgroundHealthCheckFailLimit: defaultBackgroundHealthCheckFailLimit,
backgroundHealthCheckFailThrottleFactor: defaultBackgroundHealthCheckFailThrottleFactor,
writeRetrier: defaultWriteRetrier,
fetchRetrier: defaultFetchRetrier,
writeShardsInitializing: defaultWriteShardsInitializing,
shardsLeavingCountTowardsConsistency: defaultShardsLeavingCountTowardsConsistency,
tagEncoderPoolSize: defaultTagEncoderPoolSize,
tagEncoderOpts: serialize.NewTagEncoderOptions(),
tagDecoderPoolSize: defaultTagDecoderPoolSize,
tagDecoderOpts: serialize.NewTagDecoderOptions(serialize.TagDecoderOptionsConfig{}),
streamBlocksRetrier: defaultStreamBlocksRetrier,
newConnectionFn: defaultNewConnectionFn,
writeOperationPoolSize: defaultWriteOpPoolSize,
writeTaggedOperationPoolSize: defaultWriteTaggedOpPoolSize,
fetchBatchOpPoolSize: defaultFetchBatchOpPoolSize,
writeBatchSize: DefaultWriteBatchSize,
fetchBatchSize: defaultFetchBatchSize,
identifierPool: idPool,
hostQueueOpsFlushSize: defaultHostQueueOpsFlushSize,
hostQueueOpsFlushInterval: defaultHostQueueOpsFlushInterval,
hostQueueOpsArrayPoolSize: defaultHostQueueOpsArrayPoolSize,
hostQueueEmitsHealthStatus: defaultHostQueueEmitsHealthStatus,
seriesIteratorPoolSize: defaultSeriesIteratorPoolSize,
seriesIteratorArrayPoolBuckets: defaultSeriesIteratorArrayPoolBuckets,
checkedBytesWrapperPoolSize: defaultCheckedBytesWrapperPoolSize,
contextPool: contextPool,
fetchSeriesBlocksMaxBlockRetries: defaultFetchSeriesBlocksMaxBlockRetries,
fetchSeriesBlocksBatchSize: defaultFetchSeriesBlocksBatchSize,
fetchSeriesBlocksMetadataBatchTimeout: defaultFetchSeriesBlocksMetadataBatchTimeout,
fetchSeriesBlocksBatchTimeout: defaultFetchSeriesBlocksBatchTimeout,
fetchSeriesBlocksBatchConcurrency: defaultFetchSeriesBlocksBatchConcurrency,
schemaRegistry: namespace.NewSchemaRegistry(false, nil),
asyncTopologyInitializers: []topology.Initializer{},
asyncWriteMaxConcurrency: defaultAsyncWriteMaxConcurrency,
useV2BatchAPIs: defaultUseV2BatchAPIs,
}
return opts.SetEncodingM3TSZ().(*options)
}
func validate(opts *options) error {
if opts.topologyInitializer == nil {
return errNoTopologyInitializerSet
}
if opts.readerIteratorAllocate == nil {
return errNoReaderIteratorAllocateSet
}
if err := topology.ValidateConsistencyLevel(
opts.writeConsistencyLevel,
); err != nil {
return err
}
if err := topology.ValidateReadConsistencyLevel(
opts.readConsistencyLevel,
); err != nil {
return err
}
if err := topology.ValidateReadConsistencyLevel(
opts.bootstrapConsistencyLevel,
); err != nil {
return err
}
if err := topology.ValidateConnectConsistencyLevel(
opts.clusterConnectConsistencyLevel,
); err != nil {
return err
}
return opts.logErrorSampleRate.Validate()
}
func (o *options) Validate() error {
return validate(o)
}
func (o *options) SetEncodingM3TSZ() Options {
opts := *o
opts.readerIteratorAllocate = func(r io.Reader, _ namespace.SchemaDescr) encoding.ReaderIterator {
return m3tsz.NewReaderIterator(r, m3tsz.DefaultIntOptimizationEnabled, encoding.NewOptions())
}
opts.isProtoEnabled = false
return &opts
}
func (o *options) SetEncodingProto(encodingOpts encoding.Options) Options {
opts := *o
opts.readerIteratorAllocate = func(r io.Reader, descr namespace.SchemaDescr) encoding.ReaderIterator {
return proto.NewIterator(r, descr, encodingOpts)
}
opts.isProtoEnabled = true
return &opts
}
func (o *options) IsSetEncodingProto() bool {
return o.isProtoEnabled
}
func (o *options) SetRuntimeOptionsManager(value m3dbruntime.OptionsManager) Options {
opts := *o
opts.runtimeOptsMgr = value
return &opts
}
func (o *options) RuntimeOptionsManager() m3dbruntime.OptionsManager {
return o.runtimeOptsMgr
}
func (o *options) SetClockOptions(value clock.Options) Options {
opts := *o
opts.clockOpts = value
return &opts
}
func (o *options) ClockOptions() clock.Options {
return o.clockOpts
}
func (o *options) SetInstrumentOptions(value instrument.Options) Options {
opts := *o
opts.instrumentOpts = value
return &opts
}
func (o *options) InstrumentOptions() instrument.Options {
return o.instrumentOpts
}
func (o *options) SetLogErrorSampleRate(value sampler.Rate) Options {
opts := *o
opts.logErrorSampleRate = value
return &opts
}
func (o *options) LogErrorSampleRate() sampler.Rate {
return o.logErrorSampleRate
}
func (o *options) SetTopologyInitializer(value topology.Initializer) Options {
opts := *o
opts.topologyInitializer = value
return &opts
}
func (o *options) TopologyInitializer() topology.Initializer {
return o.topologyInitializer
}
func (o *options) SetReadConsistencyLevel(value topology.ReadConsistencyLevel) Options {
opts := *o
opts.readConsistencyLevel = value
return &opts
}
func (o *options) ReadConsistencyLevel() topology.ReadConsistencyLevel {
return o.readConsistencyLevel
}
func (o *options) SetWriteConsistencyLevel(value topology.ConsistencyLevel) Options {
opts := *o
opts.writeConsistencyLevel = value
return &opts
}
func (o *options) WriteConsistencyLevel() topology.ConsistencyLevel {
return o.writeConsistencyLevel
}
func (o *options) SetBootstrapConsistencyLevel(value topology.ReadConsistencyLevel) AdminOptions {
opts := *o
opts.bootstrapConsistencyLevel = value
return &opts
}
func (o *options) BootstrapConsistencyLevel() topology.ReadConsistencyLevel {
return o.bootstrapConsistencyLevel
}
func (o *options) SetChannelOptions(value *tchannel.ChannelOptions) Options {
opts := *o
opts.channelOptions = value
return &opts
}
func (o *options) ChannelOptions() *tchannel.ChannelOptions {
return o.channelOptions
}
func (o *options) SetMaxConnectionCount(value int) Options {
opts := *o
opts.maxConnectionCount = value
return &opts
}
func (o *options) MaxConnectionCount() int {
return o.maxConnectionCount
}
func (o *options) SetMinConnectionCount(value int) Options {
opts := *o
opts.minConnectionCount = value
return &opts
}
func (o *options) MinConnectionCount() int {
return o.minConnectionCount
}
func (o *options) SetHostConnectTimeout(value time.Duration) Options {
opts := *o
opts.hostConnectTimeout = value
return &opts
}
func (o *options) HostConnectTimeout() time.Duration {
return o.hostConnectTimeout
}
func (o *options) SetClusterConnectTimeout(value time.Duration) Options {
opts := *o
opts.clusterConnectTimeout = value
return &opts
}
func (o *options) ClusterConnectTimeout() time.Duration {
return o.clusterConnectTimeout
}
func (o *options) SetClusterConnectConsistencyLevel(value topology.ConnectConsistencyLevel) Options {
opts := *o
opts.clusterConnectConsistencyLevel = value
return &opts
}
func (o *options) ClusterConnectConsistencyLevel() topology.ConnectConsistencyLevel {
return o.clusterConnectConsistencyLevel
}
func (o *options) SetWriteRequestTimeout(value time.Duration) Options {
opts := *o
opts.writeRequestTimeout = value
return &opts
}
func (o *options) WriteRequestTimeout() time.Duration {
return o.writeRequestTimeout
}
func (o *options) SetFetchRequestTimeout(value time.Duration) Options {
opts := *o
opts.fetchRequestTimeout = value
return &opts
}
func (o *options) FetchRequestTimeout() time.Duration {
return o.fetchRequestTimeout
}
func (o *options) SetTruncateRequestTimeout(value time.Duration) Options {
opts := *o
opts.truncateRequestTimeout = value
return &opts
}
func (o *options) TruncateRequestTimeout() time.Duration {
return o.truncateRequestTimeout
}
func (o *options) SetBackgroundConnectInterval(value time.Duration) Options {
opts := *o
opts.backgroundConnectInterval = value
return &opts
}
func (o *options) BackgroundConnectInterval() time.Duration {
return o.writeRequestTimeout
}
func (o *options) SetBackgroundConnectStutter(value time.Duration) Options {
opts := *o
opts.backgroundConnectStutter = value
return &opts
}
func (o *options) BackgroundConnectStutter() time.Duration {
return o.backgroundConnectStutter
}
func (o *options) SetBackgroundHealthCheckInterval(value time.Duration) Options {
opts := *o
opts.backgroundHealthCheckInterval = value
return &opts
}
func (o *options) BackgroundHealthCheckInterval() time.Duration {
return o.backgroundHealthCheckInterval
}
func (o *options) SetBackgroundHealthCheckStutter(value time.Duration) Options {
opts := *o
opts.backgroundHealthCheckStutter = value
return &opts
}
func (o *options) BackgroundHealthCheckStutter() time.Duration {
return o.backgroundHealthCheckStutter
}
func (o *options) SetBackgroundHealthCheckFailLimit(value int) Options {
opts := *o
opts.backgroundHealthCheckFailLimit = value
return &opts
}
func (o *options) BackgroundHealthCheckFailLimit() int {
return o.backgroundHealthCheckFailLimit
}
func (o *options) SetBackgroundHealthCheckFailThrottleFactor(value float64) Options {
opts := *o
opts.backgroundHealthCheckFailThrottleFactor = value
return &opts
}
func (o *options) BackgroundHealthCheckFailThrottleFactor() float64 {
return o.backgroundHealthCheckFailThrottleFactor
}
func (o *options) SetWriteRetrier(value xretry.Retrier) Options {
opts := *o
opts.writeRetrier = value
return &opts
}
func (o *options) WriteRetrier() xretry.Retrier {
return o.writeRetrier
}
func (o *options) SetFetchRetrier(value xretry.Retrier) Options {
opts := *o
opts.fetchRetrier = value
return &opts
}
func (o *options) FetchRetrier() xretry.Retrier {
return o.fetchRetrier
}
func (o *options) SetWriteShardsInitializing(value bool) Options {
opts := *o
opts.writeShardsInitializing = value
return &opts
}
func (o *options) WriteShardsInitializing() bool {
return o.writeShardsInitializing
}
func (o *options) SetShardsLeavingCountTowardsConsistency(value bool) Options {
opts := *o
opts.shardsLeavingCountTowardsConsistency = value
return &opts
}
func (o *options) ShardsLeavingCountTowardsConsistency() bool {
return o.shardsLeavingCountTowardsConsistency
}
func (o *options) SetTagEncoderOptions(value serialize.TagEncoderOptions) Options {
opts := *o
opts.tagEncoderOpts = value
return &opts
}
func (o *options) TagEncoderOptions() serialize.TagEncoderOptions {
return o.tagEncoderOpts
}
func (o *options) SetTagEncoderPoolSize(value int) Options {
opts := *o
opts.tagEncoderPoolSize = value
return &opts
}
func (o *options) TagEncoderPoolSize() int {
return o.tagEncoderPoolSize
}
func (o *options) SetTagDecoderOptions(value serialize.TagDecoderOptions) Options {
opts := *o
opts.tagDecoderOpts = value
return &opts
}
func (o *options) TagDecoderOptions() serialize.TagDecoderOptions {
return o.tagDecoderOpts
}
func (o *options) SetTagDecoderPoolSize(value int) Options {
opts := *o
opts.tagDecoderPoolSize = value
return &opts
}
func (o *options) TagDecoderPoolSize() int {
return o.tagDecoderPoolSize
}
func (o *options) SetStreamBlocksRetrier(value xretry.Retrier) AdminOptions {
opts := *o
opts.streamBlocksRetrier = value
return &opts
}
func (o *options) StreamBlocksRetrier() xretry.Retrier {
return o.streamBlocksRetrier
}
func (o *options) SetNewConnectionFn(value NewConnectionFn) AdminOptions {
opts := *o
opts.newConnectionFn = value
return &opts
}
func (o *options) NewConnectionFn() NewConnectionFn {
return o.newConnectionFn
}
func (o *options) SetWriteOpPoolSize(value int) Options {
opts := *o
opts.writeOperationPoolSize = value
return &opts
}
func (o *options) WriteOpPoolSize() int {
return o.writeOperationPoolSize
}
func (o *options) SetWriteTaggedOpPoolSize(value int) Options {
opts := *o
opts.writeTaggedOperationPoolSize = value
return &opts
}
func (o *options) WriteTaggedOpPoolSize() int {
return o.writeTaggedOperationPoolSize
}
func (o *options) SetFetchBatchOpPoolSize(value int) Options {
opts := *o
opts.fetchBatchOpPoolSize = value
return &opts
}
func (o *options) FetchBatchOpPoolSize() int {
return o.fetchBatchOpPoolSize
}
func (o *options) SetContextPool(value context.Pool) Options {
opts := *o
opts.contextPool = value
return &opts
}
func (o *options) ContextPool() context.Pool {
return o.contextPool
}
func (o *options) SetWriteBatchSize(value int) Options {
opts := *o
opts.writeBatchSize = value
return &opts
}
func (o *options) WriteBatchSize() int {
return o.writeBatchSize
}
func (o *options) SetFetchBatchSize(value int) Options {
opts := *o
opts.fetchBatchSize = value
return &opts
}
func (o *options) FetchBatchSize() int {
return o.fetchBatchSize
}
func (o *options) SetIdentifierPool(value ident.Pool) Options {
opts := *o
opts.identifierPool = value
return &opts
}
func (o *options) IdentifierPool() ident.Pool {
return o.identifierPool
}
func (o *options) SetCheckedBytesWrapperPoolSize(value int) Options {
opts := *o
opts.checkedBytesWrapperPoolSize = value
return &opts
}
func (o *options) CheckedBytesWrapperPoolSize() int {
return o.checkedBytesWrapperPoolSize
}
func (o *options) SetHostQueueOpsFlushSize(value int) Options {
opts := *o
opts.hostQueueOpsFlushSize = value
return &opts
}
func (o *options) HostQueueOpsFlushSize() int {
return o.hostQueueOpsFlushSize
}
func (o *options) SetHostQueueOpsFlushInterval(value time.Duration) Options {
opts := *o
opts.hostQueueOpsFlushInterval = value
return &opts
}
func (o *options) HostQueueOpsFlushInterval() time.Duration {
return o.hostQueueOpsFlushInterval
}
func (o *options) SetHostQueueOpsArrayPoolSize(value int) Options {
opts := *o
opts.hostQueueOpsArrayPoolSize = value
return &opts
}
func (o *options) HostQueueOpsArrayPoolSize() int {
return o.hostQueueOpsArrayPoolSize
}
func (o *options) SetHostQueueEmitsHealthStatus(value bool) Options {
opts := *o
opts.hostQueueEmitsHealthStatus = value
return &opts
}
func (o *options) HostQueueEmitsHealthStatus() bool {
return o.hostQueueEmitsHealthStatus
}
func (o *options) SetSeriesIteratorPoolSize(value int) Options {
opts := *o
opts.seriesIteratorPoolSize = value
return &opts
}
func (o *options) SeriesIteratorPoolSize() int {
return o.seriesIteratorPoolSize
}
func (o *options) SetSeriesIteratorArrayPoolBuckets(value []pool.Bucket) Options {
opts := *o
opts.seriesIteratorArrayPoolBuckets = value
return &opts
}
func (o *options) SeriesIteratorArrayPoolBuckets() []pool.Bucket {
return o.seriesIteratorArrayPoolBuckets
}
func (o *options) SetReaderIteratorAllocate(value encoding.ReaderIteratorAllocate) Options {
opts := *o
opts.readerIteratorAllocate = value
return &opts
}
func (o *options) ReaderIteratorAllocate() encoding.ReaderIteratorAllocate {
return o.readerIteratorAllocate
}
func (o *options) SetSchemaRegistry(registry namespace.SchemaRegistry) AdminOptions {
opts := *o
opts.schemaRegistry = registry
return &opts
}
func (o *options) SchemaRegistry() namespace.SchemaRegistry {
return o.schemaRegistry
}
func (o *options) SetOrigin(value topology.Host) AdminOptions {
opts := *o
opts.origin = value
return &opts
}
func (o *options) Origin() topology.Host {
return o.origin
}
func (o *options) SetFetchSeriesBlocksMaxBlockRetries(value int) AdminOptions {
opts := *o
opts.fetchSeriesBlocksMaxBlockRetries = value
return &opts
}
func (o *options) FetchSeriesBlocksMaxBlockRetries() int {
return o.fetchSeriesBlocksMaxBlockRetries
}
func (o *options) SetFetchSeriesBlocksBatchSize(value int) AdminOptions {
opts := *o
opts.fetchSeriesBlocksBatchSize = value
return &opts
}
func (o *options) FetchSeriesBlocksBatchSize() int {
return o.fetchSeriesBlocksBatchSize
}
func (o *options) SetFetchSeriesBlocksMetadataBatchTimeout(value time.Duration) AdminOptions {
opts := *o
opts.fetchSeriesBlocksMetadataBatchTimeout = value
return &opts
}
func (o *options) FetchSeriesBlocksMetadataBatchTimeout() time.Duration {