github.com/matrixorigin/matrixone@v1.2.0/pkg/txn/storage/memorystorage/storage.go (about) 1 // Copyright 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 memorystorage 16 17 import ( 18 "context" 19 20 "github.com/matrixorigin/matrixone/pkg/common/moerr" 21 "github.com/matrixorigin/matrixone/pkg/pb/timestamp" 22 "github.com/matrixorigin/matrixone/pkg/pb/txn" 23 "github.com/matrixorigin/matrixone/pkg/txn/storage" 24 ) 25 26 type Storage struct { 27 handler Handler 28 } 29 30 func New( 31 handler Handler, 32 ) (*Storage, error) { 33 s := &Storage{ 34 handler: handler, 35 } 36 return s, nil 37 } 38 39 var _ storage.TxnStorage = new(Storage) 40 41 func (s *Storage) Commit(ctx context.Context, txnMeta txn.TxnMeta) (timestamp.Timestamp, error) { 42 return s.handler.HandleCommit(ctx, txnMeta) 43 } 44 45 func (s *Storage) Committing(ctx context.Context, txnMeta txn.TxnMeta) error { 46 return s.handler.HandleCommitting(ctx, txnMeta) 47 } 48 49 func (s *Storage) Prepare(ctx context.Context, txnMeta txn.TxnMeta) (timestamp.Timestamp, error) { 50 return s.handler.HandlePrepare(ctx, txnMeta) 51 } 52 53 func (s *Storage) Rollback(ctx context.Context, txnMeta txn.TxnMeta) error { 54 return s.handler.HandleRollback(ctx, txnMeta) 55 } 56 57 func (s *Storage) StartRecovery(ctx context.Context, ch chan txn.TxnMeta) { 58 s.handler.HandleStartRecovery(ctx, ch) 59 } 60 61 func (s *Storage) Start() error { 62 return nil 63 } 64 65 func (s *Storage) Close(ctx context.Context) error { 66 return s.handler.HandleClose(ctx) 67 } 68 69 func (s *Storage) Destroy(ctx context.Context) error { 70 return s.handler.HandleDestroy(ctx) 71 } 72 73 func (s *Storage) Debug(context.Context, txn.TxnMeta, uint32, []byte) ([]byte, error) { 74 return nil, moerr.NewNotSupportedNoCtx("MemoryStorage not support debug method") 75 }