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.
@@ -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
- # The driver never follows {#leader_hint} on its own: the address may not be
29
- # reachable from this client, a new connection must authenticate again, and
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?
@@ -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}`. This driver does not follow " \
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). Wait and try again."
122
+ "leader has no address configured)."
124
123
  end
125
- message += " The open session transaction is over: it cannot continue on another node." if txn_open
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)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module TriCoreDB
4
4
  # The version of this gem. Distinct from {Frame::VERSION}, the wire format.
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
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.1.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-09-16 00:00:00.000000000 Z
11
+ date: 2026-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest