Class: Quark::MdkProtocol::SharedContext
- Inherits:
-
Object
- Object
- Quark::MdkProtocol::SharedContext
- Extended by:
- DatawireQuarkCore::Static
- Defined in:
- lib/mdk_protocol.rb
Constant Summary
Constants included from DatawireQuarkCore::Static
DatawireQuarkCore::Static::Unassigned
Instance Attribute Summary collapse
-
#_lastEntry ⇒ Object
Returns the value of attribute _lastEntry.
-
#clock ⇒ Object
Returns the value of attribute clock.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#traceId ⇒ Object
Returns the value of attribute traceId.
Class Method Summary collapse
Instance Method Summary collapse
- #__init_fields__ ⇒ Object
- #_getClass ⇒ Object
- #_getField(name) ⇒ Object
- #_setField(name, value) ⇒ Object
- #clockStr(pfx) ⇒ Object
-
#copy ⇒ Object
Return a copy of a SharedContext.
-
#finish_span ⇒ Object
Return a SharedContext one level higher in causality.
-
#initialize ⇒ SharedContext
constructor
A new instance of SharedContext.
- #key ⇒ Object
-
#start_span ⇒ Object
Return a SharedContext one level deeper in causality.
-
#tick ⇒ Object
Tick the clock at our current causality level.
- #toString ⇒ Object
-
#withTraceId(traceId) ⇒ Object
Set the traceId for this SharedContext.
Methods included from DatawireQuarkCore::Static
_lazy_statics, static, unlazy_statics
Constructor Details
#initialize ⇒ SharedContext
Returns a new instance of SharedContext.
380 381 382 383 384 385 386 |
# File 'lib/mdk_protocol.rb', line 380 def initialize() super() (self)._lastEntry = (self).clock.enter() nil end |
Instance Attribute Details
#_lastEntry ⇒ Object
Returns the value of attribute _lastEntry.
373 374 375 |
# File 'lib/mdk_protocol.rb', line 373 def _lastEntry @_lastEntry end |
#clock ⇒ Object
Returns the value of attribute clock.
373 374 375 |
# File 'lib/mdk_protocol.rb', line 373 def clock @clock end |
#environment ⇒ Object
Returns the value of attribute environment.
373 374 375 |
# File 'lib/mdk_protocol.rb', line 373 def environment @environment end |
#properties ⇒ Object
Returns the value of attribute properties.
373 374 375 |
# File 'lib/mdk_protocol.rb', line 373 def properties @properties end |
#traceId ⇒ Object
Returns the value of attribute traceId.
373 374 375 |
# File 'lib/mdk_protocol.rb', line 373 def traceId @traceId end |
Class Method Details
.decode(encoded) ⇒ Object
402 403 404 405 406 407 |
# File 'lib/mdk_protocol.rb', line 402 def self.decode(encoded) return ::DatawireQuarkCore.cast(::Quark.mdk_protocol.Serializable.decodeClassName("mdk_protocol.SharedContext", encoded)) { ::Quark.mdk_protocol.SharedContext } nil end |
Instance Method Details
#__init_fields__ ⇒ Object
539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/mdk_protocol.rb', line 539 def __init_fields__() super self.traceId = ::Quark.quark.concurrent.Context.runtime().uuid() self.clock = ::Quark.mdk_protocol.LamportClock.new() self.properties = {} self.environment = ::Quark.mdk_protocol.OperationalEnvironment.new() self._lastEntry = 0 nil end |
#_getClass ⇒ Object
489 490 491 492 493 494 |
# File 'lib/mdk_protocol.rb', line 489 def _getClass() return "mdk_protocol.SharedContext" nil end |
#_getField(name) ⇒ Object
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/mdk_protocol.rb', line 496 def _getField(name) if ((name) == ("traceId")) return (self).traceId end if ((name) == ("clock")) return (self).clock end if ((name) == ("properties")) return (self).properties end if ((name) == ("environment")) return (self).environment end if ((name) == ("_lastEntry")) return (self)._lastEntry end return nil nil end |
#_setField(name, value) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/mdk_protocol.rb', line 518 def _setField(name, value) if ((name) == ("traceId")) (self).traceId = ::DatawireQuarkCore.cast(value) { ::String } end if ((name) == ("clock")) (self).clock = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_protocol.LamportClock } end if ((name) == ("properties")) (self).properties = ::DatawireQuarkCore.cast(value) { ::Hash } end if ((name) == ("environment")) (self).environment = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_protocol.OperationalEnvironment } end if ((name) == ("_lastEntry")) (self)._lastEntry = ::DatawireQuarkCore.cast(value) { ::Integer } end nil end |
#clockStr(pfx) ⇒ Object
409 410 411 412 413 414 415 416 417 418 |
# File 'lib/mdk_protocol.rb', line 409 def clockStr(pfx) cs = "" if (((self).clock) != (nil)) cs = (pfx) + ((self).clock.key()) end return cs nil end |
#copy ⇒ Object
Return a copy of a SharedContext.
482 483 484 485 486 487 |
# File 'lib/mdk_protocol.rb', line 482 def copy() return ::Quark.mdk_protocol.SharedContext.decode(self.encode()) nil end |
#finish_span ⇒ Object
Return a SharedContext one level higher in causality. In practice, most callers should probably stop using this context, and the new one, after calling this method.
NOTE WELL: THIS RETURNS A NEW SharedContext RATHER THAN MODIFYING THIS ONE. It is NOT SUPPORTED to modify the causality level of a SharedContext in place.
470 471 472 473 474 475 476 477 |
# File 'lib/mdk_protocol.rb', line 470 def finish_span() newContext = ::Quark.mdk_protocol.SharedContext.decode(self.encode()) (newContext)._lastEntry = (newContext).clock.leave((newContext)._lastEntry) return newContext nil end |
#key ⇒ Object
420 421 422 423 424 425 |
# File 'lib/mdk_protocol.rb', line 420 def key() return ((self).traceId) + (self.clockStr(":")) nil end |
#start_span ⇒ Object
Return a SharedContext one level deeper in causality.
NOTE WELL: THIS RETURNS A NEW SharedContext RATHER THAN MODIFYING THIS ONE. It is NOT SUPPORTED to modify the causality level of a SharedContext in place.
452 453 454 455 456 457 458 459 460 |
# File 'lib/mdk_protocol.rb', line 452 def start_span() self.tick() newContext = ::Quark.mdk_protocol.SharedContext.decode(self.encode()) (newContext)._lastEntry = (newContext).clock.enter() return newContext nil end |
#tick ⇒ Object
Tick the clock at our current causality level.
438 439 440 441 442 443 |
# File 'lib/mdk_protocol.rb', line 438 def tick() (self).clock.tick() nil end |
#toString ⇒ Object
427 428 429 430 431 432 |
# File 'lib/mdk_protocol.rb', line 427 def toString() return ((("<SCTX t:") + ((self).traceId)) + (self.clockStr(" c:"))) + (">") nil end |
#withTraceId(traceId) ⇒ Object
Set the traceId for this SharedContext.
394 395 396 397 398 399 400 |
# File 'lib/mdk_protocol.rb', line 394 def withTraceId(traceId) (self).traceId = traceId return self nil end |