github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/logstore/driver/logservicedriver/options.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package logservicedriver 16 17 import ( 18 "context" 19 "time" 20 21 "github.com/matrixorigin/matrixone/pkg/logservice" 22 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common" 23 ) 24 25 var DefaultReadMaxSize = uint64(10) 26 27 type Config struct { 28 ClientPoolMaxSize int 29 ClientPoolInitSize int 30 GetClientRetryTimeOut time.Duration 31 32 RecordSize int 33 ReadCacheSize int 34 AppenderMaxCount int 35 ReadMaxSize uint64 36 NewRecordSize int 37 NewClientDuration time.Duration 38 ClientAppendDuration time.Duration 39 TruncateDuration time.Duration 40 // AppendFrequency time.Duration 41 RetryTimeout time.Duration 42 GetTruncateDuration time.Duration 43 ReadDuration time.Duration 44 45 ClientFactory LogServiceClientFactory 46 } 47 48 type LogServiceClientFactory logservice.ClientFactory 49 50 func NewDefaultConfig(clientFactory LogServiceClientFactory) *Config { 51 return &Config{ 52 ClientPoolMaxSize: 100, 53 ClientPoolInitSize: 100, 54 GetClientRetryTimeOut: time.Second * 3, 55 56 RecordSize: int(common.K * 16), 57 ReadCacheSize: 100, 58 ReadMaxSize: common.K * 20, 59 AppenderMaxCount: 100, 60 NewRecordSize: int(common.K * 20), 61 NewClientDuration: time.Second * 3, 62 // AppendFrequency: time.Millisecond * 5, 63 RetryTimeout: time.Minute * 3, 64 ClientAppendDuration: time.Second * 10, 65 TruncateDuration: time.Second * 10, 66 GetTruncateDuration: time.Second * 5, 67 ReadDuration: time.Second * 5, 68 ClientFactory: clientFactory, 69 } 70 } 71 72 func NewTestConfig(ccfg *logservice.ClientConfig) *Config { 73 cfg := &Config{ 74 ClientPoolMaxSize: 10, 75 ClientPoolInitSize: 5, 76 GetClientRetryTimeOut: time.Second, 77 78 RecordSize: int(common.M * 10), 79 ReadCacheSize: 10, 80 ReadMaxSize: common.K * 20, 81 AppenderMaxCount: 10, 82 NewRecordSize: int(common.K * 20), 83 // AppendFrequency: time.Millisecond /1000, 84 RetryTimeout: time.Minute, 85 NewClientDuration: time.Second, 86 ClientAppendDuration: time.Second, 87 TruncateDuration: time.Second, 88 GetTruncateDuration: time.Second, 89 ReadDuration: time.Second, 90 } 91 cfg.ClientFactory = func() (logservice.Client, error) { 92 ctx, cancel := context.WithTimeout(context.Background(), cfg.NewClientDuration) 93 logserviceClient, err := logservice.NewClient(ctx, *ccfg) 94 cancel() 95 return logserviceClient, err 96 } 97 return cfg 98 }