You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

constant.go 3.2 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package tm
  18. import "seata.apache.org/seata-go/pkg/protocol/message"
  19. type TransactionManager interface {
  20. // Begin a new global transaction.
  21. Begin(applicationId, transactionServiceGroup, name string, timeout int64) (string, error)
  22. // Commit Global commit.
  23. Commit(xid string) (message.GlobalStatus, error)
  24. // Rollback Global rollback.
  25. Rollback(xid string) (message.GlobalStatus, error)
  26. // GetStatus Get current status of the give transaction.
  27. GetStatus(xid string) (message.GlobalStatus, error)
  28. // GlobalReport Global report.
  29. GlobalReport(xid string, globalStatus message.GlobalStatus) (message.GlobalStatus, error)
  30. }
  31. // GlobalTransactionRole Identifies whether a global transaction is beginNewGtx or participates in something else
  32. type GlobalTransactionRole int8
  33. const (
  34. UnKnow = GlobalTransactionRole(0)
  35. Launcher = GlobalTransactionRole(1)
  36. Participant = GlobalTransactionRole(2)
  37. )
  38. func (role GlobalTransactionRole) String() string {
  39. switch role {
  40. case UnKnow:
  41. return "UnKnow"
  42. case Launcher:
  43. return "Launcher"
  44. case Participant:
  45. return "Participant"
  46. }
  47. return "UnKnow"
  48. }
  49. // Propagation Used to identify the spread of the global transaction enumerated types
  50. type Propagation int8
  51. const (
  52. // Required
  53. // The default propagation.
  54. // If transaction is existing, execute with current transaction,
  55. // else execute with beginNewGtx transaction.
  56. Required = Propagation(0)
  57. // RequiresNew
  58. // If transaction is existing, suspend it, and then execute business with beginNewGtx transaction.
  59. RequiresNew = Propagation(1)
  60. // NotSupported
  61. // If transaction is existing, suspend it, and then execute business without transaction.
  62. NotSupported = Propagation(2)
  63. // Supports
  64. // If transaction is not existing, execute without global transaction,
  65. // else execute business with current transaction.
  66. Supports = Propagation(3)
  67. // Never
  68. // If transaction is existing, throw exception,
  69. // else execute business without transaction.
  70. Never = Propagation(4)
  71. // Mandatory
  72. // If transaction is not existing, throw exception,
  73. // else execute business with current transaction.
  74. Mandatory = Propagation(5)
  75. )
  76. func (p Propagation) String() string {
  77. switch p {
  78. case Required:
  79. return "Required"
  80. case RequiresNew:
  81. return "RequiresNew"
  82. case NotSupported:
  83. return "NotSupported"
  84. case Supports:
  85. return "Supports"
  86. case Never:
  87. return "Never"
  88. case Mandatory:
  89. return "Mandatory"
  90. }
  91. return "UnKnow"
  92. }