github.com/matrixorigin/matrixone@v1.2.0/pkg/bootstrap/upgrade.go (about) 1 // Copyright 2023 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 bootstrap 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/bootstrap/versions/v1_2_0" 19 ) 20 21 // initUpgrade all versions need create a upgrade handle in pkg/bootstrap/versions 22 // package. And register the upgrade logic into handles. 23 func (s *service) initUpgrade() { 24 s.handles = append(s.handles, v1_2_0.Handler) 25 //s.handles = append(s.handles, v1_2_1.Handler) 26 } 27 28 func (s *service) getFinalVersionHandle() VersionHandle { 29 return s.handles[len(s.handles)-1] 30 } 31 32 // GetFinalVersion Get mo final version 33 func (s *service) GetFinalVersion() string { 34 return s.handles[len(s.handles)-1].Metadata().Version 35 } 36 37 func (s *service) GetFinalVersionOffset() int32 { 38 return int32(s.handles[len(s.handles)-1].Metadata().VersionOffset) 39 } 40 41 func (s *service) getVersionHandle(version string) VersionHandle { 42 for _, h := range s.handles { 43 if h.Metadata().Version == version { 44 return h 45 } 46 } 47 panic("missing upgrade handle for version: " + version) 48 }