github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/db/checkpoint/option.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 checkpoint
    16  
    17  import "time"
    18  
    19  type Option func(*runner)
    20  
    21  func WithObserver(o Observer) Option {
    22  	return func(r *runner) {
    23  		r.observers.add(o)
    24  	}
    25  }
    26  
    27  func WithCollectInterval(interval time.Duration) Option {
    28  	return func(r *runner) {
    29  		r.options.collectInterval = interval
    30  	}
    31  }
    32  
    33  func WithFlushInterval(interval time.Duration) Option {
    34  	return func(r *runner) {
    35  		r.options.maxFlushInterval = interval
    36  	}
    37  }
    38  
    39  func WithMinCount(count int) Option {
    40  	return func(r *runner) {
    41  		r.options.minCount = count
    42  	}
    43  }
    44  
    45  func WithMinIncrementalInterval(interval time.Duration) Option {
    46  	return func(r *runner) {
    47  		r.options.minIncrementalInterval = interval
    48  	}
    49  }
    50  
    51  func WithGlobalMinCount(count int) Option {
    52  	return func(r *runner) {
    53  		r.options.globalMinCount = count
    54  	}
    55  }
    56  
    57  func WithForceFlushTimeout(to time.Duration) Option {
    58  	return func(r *runner) {
    59  		r.options.forceFlushTimeout = to
    60  	}
    61  }
    62  
    63  func WithForceFlushCheckInterval(interval time.Duration) Option {
    64  	return func(r *runner) {
    65  		r.options.forceFlushCheckInterval = interval
    66  	}
    67  }
    68  
    69  func WithGlobalVersionInterval(interval time.Duration) Option {
    70  	return func(r *runner) {
    71  		r.options.globalVersionInterval = interval
    72  	}
    73  }
    74  
    75  func WithCheckpointBlockRows(rows int) Option {
    76  	return func(r *runner) {
    77  		r.options.checkpointBlockRows = rows
    78  	}
    79  }
    80  
    81  func WithCheckpointSize(size int) Option {
    82  	return func(r *runner) {
    83  		r.options.checkpointSize = size
    84  	}
    85  }
    86  
    87  func WithReserveWALEntryCount(count uint64) Option {
    88  	return func(r *runner) {
    89  		r.options.reservedWALEntryCount = count
    90  	}
    91  }