class Quark::Mdk::MDK

The MDK API consists of two interfaces: MDK and Session. The MDK interface holds globally scoped APIs and state associated with the microservice. The Session interface holds locally scoped APIs and state. A Session must be used sequentially.

The MDK instance is responsible for communicating with foundational services like discovery and tracing.

There will typically be one MDK instance for the entire process, and one instance of the Session object per thread/channel/request depending on how the MDK is integrated and used within the application framework of choice.

A note on versions: service versions indicate API compatibility, not releases of the underlying code. They should be in the form MAJOR.MINOR, e.g. '2.11'. Major versions indicates incompatibility: '1.0' is incompatible with '2.11'. Minor versions indicate backwards compatibility with new features: a client that wants version '1.1' can talk to version '1.1' and '1.2' but not to version '1.0'.

Public Class Methods

new() click to toggle source
# File output/rb/mdk-2.0/lib/mdk.rb, line 109
def initialize()
    self.__init_fields__

    nil
end

Public Instance Methods

__init_fields__() click to toggle source
# File output/rb/mdk-2.0/lib/mdk.rb, line 228
def __init_fields__()
    

    nil
end
derive(encodedContext) click to toggle source

Create a new Session. The given encoded distributed session's properties will be used to configure the new Session, e.g. overrides will be preserved. However, because this is a new Session the timeout will not be copied from the encoded session.

This is intended for use for encoded context received via a broadcast medium (pub/sub, message queues with multiple readers, etc.). If you know only you received the encoded context, e.g. you're coding a server that receives the context from a HTTP request, you should join() instead.

# File output/rb/mdk-2.0/lib/mdk.rb, line 222
def derive(encodedContext)
    raise NotImplementedError, '`MDK.derive` is an abstract method'

    nil
end
join(encodedContext) click to toggle source

Create a new Session and join it to an existing distributed sesion.

This should only ever be done once per an encoded context. That means you should only use it for RPC or similar one-off calls. If you received the encoded context via a broadcast medium (pub/sub, message queues with multiple readers, etc.) you should use childSession() instead.

# File output/rb/mdk-2.0/lib/mdk.rb, line 203
def join(encodedContext)
    raise NotImplementedError, '`MDK.join` is an abstract method'

    nil
end
register(service, version, address) click to toggle source

Registers a service endpoint with the discovery system. This can be called at any point, however registered endpoints will not be advertised to the discovery system until the MDK is started.

# File output/rb/mdk-2.0/lib/mdk.rb, line 150
def register(service, version, address)
    raise NotImplementedError, '`MDK.register` is an abstract method'

    nil
end
session() click to toggle source

Creates a new Session. A Session created in this way will result in a new distributed trace. This should therefore be used primarily by edge services. Intermediary and foundational services should make use of join(encodedContext) in order to preserve distributed traces.

# File output/rb/mdk-2.0/lib/mdk.rb, line 187
def session()
    raise NotImplementedError, '`MDK.session` is an abstract method'

    nil
end
setDefaultDeadline(seconds) click to toggle source

Set the default timeout for MDK sessions.

This is the maximum timeout; if a joined session has a lower timeout that will be used.

# File output/rb/mdk-2.0/lib/mdk.rb, line 163
def setDefaultDeadline(seconds)
    raise NotImplementedError, '`MDK.setDefaultDeadline` is an abstract method'

    nil
end
setDefaultTimeout(seconds) click to toggle source

DEPRECATED, use setDefaultDeadline().

# File output/rb/mdk-2.0/lib/mdk.rb, line 172
def setDefaultTimeout(seconds)
    raise NotImplementedError, '`MDK.setDefaultTimeout` is an abstract method'

    nil
end
start() click to toggle source

Start the MDK. An MDK instance will not communicate with foundational services unless it is started.

# File output/rb/mdk-2.0/lib/mdk.rb, line 123
def start()
    raise NotImplementedError, '`MDK.start` is an abstract method'

    nil
end
stop() click to toggle source

Stop the MDK. When the MDK stops unregisters any service endpoints from the discovery system. This should always be done prior to process exit in order to propogate node shutdowns in realtime rather than waiting for heartbeats to detect node departures.

# File output/rb/mdk-2.0/lib/mdk.rb, line 137
def stop()
    raise NotImplementedError, '`MDK.stop` is an abstract method'

    nil
end