github.com/matrixorigin/matrixone@v1.2.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/common/mpool" 22 "github.com/matrixorigin/matrixone/pkg/logservice" 23 ) 24 25 var DefaultReadMaxSize = uint64(10) 26 27 type Config struct { 28 ClientMaxCount int 29 GetClientRetryTimeOut time.Duration 30 31 RecordSize int 32 ReadCacheSize int 33 NewClientDuration time.Duration 34 ClientAppendDuration time.Duration 35 TruncateDuration time.Duration 36 // AppendFrequency time.Duration 37 RetryTimeout time.Duration 38 GetTruncateDuration time.Duration 39 ReadDuration time.Duration 40 41 ClientFactory LogServiceClientFactory 42 } 43 44 type LogServiceClientFactory logservice.ClientFactory 45 46 func NewDefaultConfig(clientFactory LogServiceClientFactory) *Config { 47 return &Config{ 48 ClientMaxCount: 100, 49 GetClientRetryTimeOut: time.Second * 3, 50 51 RecordSize: int(mpool.MB * 1), 52 ReadCacheSize: 100, 53 NewClientDuration: time.Second * 3, 54 // AppendFrequency: time.Millisecond * 5, 55 RetryTimeout: time.Minute * 3, 56 ClientAppendDuration: time.Second * 10, 57 TruncateDuration: time.Second * 10, 58 GetTruncateDuration: time.Second * 5, 59 ReadDuration: time.Second * 5, 60 ClientFactory: clientFactory, 61 } 62 } 63 64 func NewTestConfig(ccfg *logservice.ClientConfig) *Config { 65 cfg := &Config{ 66 ClientMaxCount: 10, 67 GetClientRetryTimeOut: time.Second, 68 69 RecordSize: int(mpool.MB * 10), 70 ReadCacheSize: 10, 71 // AppendFrequency: time.Millisecond /1000, 72 RetryTimeout: time.Minute, 73 NewClientDuration: time.Second, 74 ClientAppendDuration: time.Second, 75 TruncateDuration: time.Second, 76 GetTruncateDuration: time.Second, 77 ReadDuration: time.Second, 78 } 79 cfg.ClientFactory = func() (logservice.Client, error) { 80 ctx, cancel := context.WithTimeout(context.Background(), cfg.NewClientDuration) 81 logserviceClient, err := logservice.NewClient(ctx, *ccfg) 82 cancel() 83 return logserviceClient, err 84 } 85 return cfg 86 }