tricoredb 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -1
- data/README.md +201 -6
- data/lib/tricoredb/builders.rb +142 -0
- data/lib/tricoredb/client.rb +1307 -30
- data/lib/tricoredb/errors.rb +7 -3
- data/lib/tricoredb/response.rb +10 -5
- data/lib/tricoredb/version.rb +1 -1
- metadata +2 -2
data/lib/tricoredb/errors.rb
CHANGED
|
@@ -4,6 +4,11 @@ module TriCoreDB
|
|
|
4
4
|
# The code a not-leader refusal carries in `diagnostics.error_code`.
|
|
5
5
|
NOT_LEADER = "not_leader"
|
|
6
6
|
|
|
7
|
+
# The code of a request a follower handed to the leader and lost the answer
|
|
8
|
+
# to, or one the leader could not confirm. It may or may not have been
|
|
9
|
+
# applied, so the client never sends it again.
|
|
10
|
+
OUTCOME_UNKNOWN = "outcome_unknown"
|
|
11
|
+
|
|
7
12
|
# Base class for every failure raised by this gem.
|
|
8
13
|
#
|
|
9
14
|
# Branch on {#code}, never on the message: the message is prose the server is
|
|
@@ -25,9 +30,8 @@ module TriCoreDB
|
|
|
25
30
|
|
|
26
31
|
# Whether the request was right but reached a node that is not the leader.
|
|
27
32
|
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
# an open session transaction cannot move to another node at all.
|
|
33
|
+
# Unless `follow_leader: false` was passed to {Client.connect}, the client
|
|
34
|
+
# has already sent the request again before raising this.
|
|
31
35
|
#
|
|
32
36
|
# @return [Boolean]
|
|
33
37
|
def redirect?
|
data/lib/tricoredb/response.rb
CHANGED
|
@@ -111,18 +111,23 @@ module TriCoreDB
|
|
|
111
111
|
#
|
|
112
112
|
# @param txn_open [Boolean] whether a session transaction was open on the connection
|
|
113
113
|
# @return [ServerError]
|
|
114
|
-
def to_error(txn_open = false)
|
|
114
|
+
def to_error(txn_open = false, retried: 0)
|
|
115
115
|
text = arm("Message") || (arm?("Json") ? JSON.generate(arm("Json")) : nil) || "request failed"
|
|
116
116
|
message = "#{text} (server status: #{@status})"
|
|
117
117
|
if redirect?
|
|
118
118
|
message += if leader_hint
|
|
119
|
-
" [not_leader: the leader serves clients at `#{leader_hint}`.
|
|
120
|
-
"the hint on its own; send the request there."
|
|
119
|
+
" [not_leader: the leader serves clients at `#{leader_hint}`."
|
|
121
120
|
else
|
|
122
121
|
" [not_leader: there is no leader address to name (an election is in progress, or the " \
|
|
123
|
-
"leader has no address configured).
|
|
122
|
+
"leader has no address configured)."
|
|
124
123
|
end
|
|
125
|
-
|
|
124
|
+
if txn_open
|
|
125
|
+
message += " The open session transaction is over: it cannot continue on another node."
|
|
126
|
+
elsif retried.nil?
|
|
127
|
+
message += " Following the leader is off (follow_leader: false): send the request there yourself."
|
|
128
|
+
elsif retried.positive?
|
|
129
|
+
message += " The client sent it again #{retried} time(s) and was refused each time."
|
|
130
|
+
end
|
|
126
131
|
message += "]"
|
|
127
132
|
end
|
|
128
133
|
ServerError.new(message, code: error_code, leader_hint: leader_hint, status: @status, response: self)
|
data/lib/tricoredb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tricoredb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trinesh Kumar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|