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.

branch.go 3.6 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 branch
  18. import (
  19. "fmt"
  20. )
  21. type BranchType int8
  22. type BranchStatus int8
  23. const (
  24. BranchTypeAT BranchType = 0
  25. BranchTypeTCC BranchType = 1
  26. BranchTypeSAGA BranchType = 2
  27. BranchTypeXA BranchType = 3
  28. )
  29. const (
  30. /**
  31. * The BranchStatus_Unknown.
  32. * description:BranchStatus_Unknown branch status.
  33. */
  34. BranchStatusUnknown = BranchStatus(0)
  35. /**
  36. * The BranchStatus_Registered.
  37. * description:BranchStatus_Registered to TC.
  38. */
  39. BranchStatusRegistered = BranchStatus(1)
  40. /**
  41. * The Phase one done.
  42. * description:Branch logic is successfully done at phase one.
  43. */
  44. BranchStatusPhaseoneDone = BranchStatus(2)
  45. /**
  46. * The Phase one failed.
  47. * description:Branch logic is failed at phase one.
  48. */
  49. BranchStatusPhaseoneFailed = BranchStatus(3)
  50. /**
  51. * The Phase one timeout.
  52. * description:Branch logic is NOT reported for a timeout.
  53. */
  54. BranchStatusPhaseoneTimeout = BranchStatus(4)
  55. /**
  56. * The Phase two committed.
  57. * description:Commit logic is successfully done at phase two.
  58. */
  59. BranchStatusPhasetwoCommitted = BranchStatus(5)
  60. /**
  61. * The Phase two commit failed retryable.
  62. * description:Commit logic is failed but retryable.
  63. */
  64. BranchStatusPhasetwoCommitFailedRetryable = BranchStatus(6)
  65. /**
  66. * The Phase two commit failed unretryable.
  67. * description:Commit logic is failed and NOT retryable.
  68. */
  69. BranchStatusPhasetwoCommitFailedUnretryable = BranchStatus(7)
  70. /**
  71. * The Phase two rollbacked.
  72. * description:Rollback logic is successfully done at phase two.
  73. */
  74. BranchStatusPhasetwoRollbacked = BranchStatus(8)
  75. /**
  76. * The Phase two rollback failed retryable.
  77. * description:Rollback logic is failed but retryable.
  78. */
  79. BranchStatusPhasetwoRollbackFailedRetryable = BranchStatus(9)
  80. /**
  81. * The Phase two rollback failed unretryable.
  82. * description:Rollback logic is failed but NOT retryable.
  83. */
  84. BranchStatusPhasetwoRollbackFailedUnretryable = BranchStatus(10)
  85. )
  86. func (s BranchStatus) String() string {
  87. switch s {
  88. case BranchStatusUnknown:
  89. return "Unknown"
  90. case BranchStatusRegistered:
  91. return "Registered"
  92. case BranchStatusPhaseoneDone:
  93. return "PhaseoneDone"
  94. case BranchStatusPhaseoneFailed:
  95. return "PhaseoneFailed"
  96. case BranchStatusPhaseoneTimeout:
  97. return "PhaseoneTimeout"
  98. case BranchStatusPhasetwoCommitted:
  99. return "PhasetwoCommitted"
  100. case BranchStatusPhasetwoCommitFailedRetryable:
  101. return "PhasetwoCommitFailedRetryable"
  102. case BranchStatusPhasetwoCommitFailedUnretryable:
  103. return "CommitFailedUnretryable"
  104. case BranchStatusPhasetwoRollbacked:
  105. return "PhasetwoRollbacked"
  106. case BranchStatusPhasetwoRollbackFailedRetryable:
  107. return "RollbackFailedRetryable"
  108. case BranchStatusPhasetwoRollbackFailedUnretryable:
  109. return "RollbackFailedUnretryable"
  110. default:
  111. return fmt.Sprintf("%d", s)
  112. }
  113. }