github.com/matrixorigin/matrixone@v0.7.0/pkg/cnservice/options.go (about) 1 // Copyright 2021 - 2022 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 cnservice 16 17 import ( 18 "context" 19 20 "github.com/matrixorigin/matrixone/pkg/common/morpc" 21 "github.com/matrixorigin/matrixone/pkg/fileservice" 22 "github.com/matrixorigin/matrixone/pkg/taskservice" 23 "github.com/matrixorigin/matrixone/pkg/txn/client" 24 "github.com/matrixorigin/matrixone/pkg/vm/engine" 25 "go.uber.org/zap" 26 ) 27 28 // Option option to create cn service 29 type Option func(*service) 30 31 // WithLogger setup cn service's logger 32 func WithLogger(logger *zap.Logger) Option { 33 return func(s *service) { 34 s.logger = logger 35 } 36 } 37 38 // WithTaskStorageFactory setup the special task strorage factory 39 func WithTaskStorageFactory(factory taskservice.TaskStorageFactory) Option { 40 return func(s *service) { 41 s.task.storageFactory = factory 42 } 43 } 44 45 // WithMessageHandle setup message handle 46 func WithMessageHandle(f func(ctx context.Context, 47 message morpc.Message, 48 cs morpc.ClientSession, 49 engine engine.Engine, 50 fs fileservice.FileService, 51 cli client.TxnClient, 52 mAcquirer func() morpc.Message, 53 getClusterDetails engine.GetClusterDetailsFunc) error) Option { 54 return func(s *service) { 55 s.requestHandler = f 56 } 57 }