Class: Textus::MCP::Session
- Inherits:
-
Object
- Object
- Textus::MCP::Session
- Defined in:
- lib/textus/mcp/session.rb
Overview
Per-connection state held by the server. Immutable; advance_cursor returns a new instance.
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#manifest_etag ⇒ Object
readonly
Returns the value of attribute manifest_etag.
-
#propose_zone ⇒ Object
readonly
Returns the value of attribute propose_zone.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #advance_cursor(new_cursor) ⇒ Object
- #check_etag!(observed_etag) ⇒ Object
-
#initialize(role:, cursor:, propose_zone:, manifest_etag:) ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(role:, cursor:, propose_zone:, manifest_etag:) ⇒ Session
Returns a new instance of Session.
8 9 10 11 12 13 |
# File 'lib/textus/mcp/session.rb', line 8 def initialize(role:, cursor:, propose_zone:, manifest_etag:) @role = role @cursor = cursor @propose_zone = propose_zone @manifest_etag = manifest_etag end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
6 7 8 |
# File 'lib/textus/mcp/session.rb', line 6 def cursor @cursor end |
#manifest_etag ⇒ Object (readonly)
Returns the value of attribute manifest_etag.
6 7 8 |
# File 'lib/textus/mcp/session.rb', line 6 def manifest_etag @manifest_etag end |
#propose_zone ⇒ Object (readonly)
Returns the value of attribute propose_zone.
6 7 8 |
# File 'lib/textus/mcp/session.rb', line 6 def propose_zone @propose_zone end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/textus/mcp/session.rb', line 6 def role @role end |
Instance Method Details
#advance_cursor(new_cursor) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/textus/mcp/session.rb', line 15 def advance_cursor(new_cursor) self.class.new( role: @role, cursor: new_cursor, propose_zone: @propose_zone, manifest_etag: @manifest_etag ) end |
#check_etag!(observed_etag) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/textus/mcp/session.rb', line 22 def check_etag!(observed_etag) return if observed_etag == @manifest_etag raise ContractDrift.new( "manifest changed (was #{@manifest_etag[0, 8]}, now #{observed_etag[0, 8]}); re-run boot", ) end |