Labeled Interface Invocation

Meresco’s Latest Addition
Meresco has received an important upgrade. With this upgrade the flexibility of DNA configuration greatly improved. Supporting different implementations for the same interface has become even more flexible with Labeled Interface Invocation (LII).

Multiple Implementations For an Interface
DNA makes a distinction between interfaces and implementation, which is a well-known practice.  However, sometimes there are multiple distinct implementations for the same interface.  For example, two Storage components might support the same interface, yet representing distinct storages.  They can have distinct performance properties or represent distinct data sets.  DNA already supports this by supporting multiple implementations for any interface. At configuration time, one branch might use one implementation while another branch uses another. For a step-by-step programmers guide too how this works see Component Configuration with DNA.

Components Choose Their Own Implementations
Labeled Interface Invocation allows components to choose distinctive implementations of the same interface at run-time. This is done by first labeling the implementations during configuration, and then use these labels during the invocation of interfaces.

Suppose we have two storages supporting the interface


Normally, a message to an arbitrary implementation of this interface would look like:


Now suppose that there are two implementations, differing in the way they store and safeguard data. Lets label these implementations “reviews” and “audits”:

    reviewStore = Storage(name="reviews")
    auditStore = Storage(name="audits")

With Labeled Interface Invocation we can now target messages to any of these implementation as follows:


An interesting aspect of the lines above is that the constant labels “reviews” and “audits” can in fact be variables. Thus, labels can also be computed and routing messages to different components can be done on the fly. For example:

    target = ... compute or lookup a label ...

Meresco’s DNA has been stable for about two years. So new DNA features are rare, and we were pleasantly surprised to have found one. As usual, it took a long time, and a lot of thinking, but only a few lines of code; 3 actually. Most code changes are for tests and other components to used LLI. Here is the complete LLI changeset.

Have any questions about this feature or want support to use it your self? Please contact me.

Geef een reactie

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.