github.com/matrixorigin/matrixone@v1.2.0/pkg/util/status/txn_client.go (about) 1 // Copyright 2021 -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 status 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/pb/timestamp" 19 "github.com/matrixorigin/matrixone/pkg/txn/client" 20 ) 21 22 type TxnClientStatus struct { 23 // indicate whether the CN can provide service normally. 24 // 0 means paused, 1 means normal. 25 State int `json:"state"` 26 // number of user active transactions. 27 UserTxnNum int `json:"user_txn_num"` 28 // all active txns 29 ActiveTxns []string `json:"active_txns"` 30 ActiveTxnCount int `json:"active_txn_count"` 31 // FIFO queue for ready to active txn 32 WaitActiveTxns []string `json:"wait_active_txns"` 33 WaitActiveTxnCount int `json:"wait_active_txn_count"` 34 // LatestTS is the latest TS for the txn client. 35 LatestTS timestamp.Timestamp `json:"latest_ts"` 36 } 37 38 func (s *TxnClientStatus) fill(txnClient client.TxnClient) { 39 if txnClient == nil { 40 return 41 } 42 st := txnClient.GetState() 43 s.State = st.State 44 s.UserTxnNum = st.Users 45 s.ActiveTxns = st.ActiveTxns 46 s.ActiveTxnCount = len(st.ActiveTxns) 47 s.WaitActiveTxns = st.WaitActiveTxns 48 s.WaitActiveTxnCount = len(st.WaitActiveTxns) 49 s.LatestTS = st.LatestTS 50 }