Files
wehub-resource-sync 498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:17 +08:00

55 lines
1.3 KiB
Go

package message
import (
"time"
"github.com/milvus-io/milvus/pkg/v3/proto/messagespb"
)
type (
TxnState = messagespb.TxnState
TxnID int64
)
const (
TxnStateInFlight TxnState = messagespb.TxnState_TxnInFlight
TxnStateOnCommit TxnState = messagespb.TxnState_TxnOnCommit
TxnStateCommitted TxnState = messagespb.TxnState_TxnCommitted
TxnStateOnRollback TxnState = messagespb.TxnState_TxnOnRollback
TxnStateRollbacked TxnState = messagespb.TxnState_TxnRollbacked
NonTxnID = TxnID(-1)
// TxnKeepaliveInfinite is the infinite keepalive duration.
// If the keepalive is infinite, the txn will never be expired.
TxnKeepaliveInfinite = -1 * time.Second
)
// NewTxnContextFromProto generates TxnContext from proto message.
func NewTxnContextFromProto(proto *messagespb.TxnContext) *TxnContext {
if proto == nil {
return nil
}
return &TxnContext{
TxnID: TxnID(proto.TxnId),
Keepalive: time.Duration(proto.KeepaliveMilliseconds) * time.Millisecond,
}
}
// TxnContext is the transaction context for message.
type TxnContext struct {
TxnID TxnID
Keepalive time.Duration
}
// IntoProto converts TxnContext to proto message.
func (t *TxnContext) IntoProto() *messagespb.TxnContext {
if t == nil {
return nil
}
return &messagespb.TxnContext{
TxnId: int64(t.TxnID),
KeepaliveMilliseconds: t.Keepalive.Milliseconds(),
}
}