Skip to content

PdcFramework provides scaffolding for distributed system components

License

Notifications You must be signed in to change notification settings

tweakch/PdcFramework

Repository files navigation

PdcFramework 1.0.2

This framework introduces terminology through it's interfaces and classes that help you do your job and do it well.

The power of components

The source code of AirportInfoComponent and AbbreviationExtenderComponent can be found in the Samples.

// receive raw airport data
var info = AirportInfoComponent.Execute("JFK");
// {"delay":"true","IATA":"JFK"...

// directly map results to your classes
var delay = AirportInfoComponent.Execute<AirportInfo>("JFK").Delay;
// true

// string components together
var sequence = PipeConnector.Sequence<AirportInfoComponent, AbbreviationExtenderComponent>();
var example = sequence.Execute("JFK");
// example = {"delay":"true","internationalAirTransportAssociation":"John Fitzgerald Kennedy...

Components as a Service

TL;DR COMPONENTS are atomic units that can be ACTIVE (generate control signals) or PASSIVE (receive control signals).

A COMPONENT (by definition) is a part of a larger entity. An object that fits into an existing machine / ecosystem. What we as programmers do is design these components by describing them in code. That's it.

Passive Components

In system engineering terms, Passive Components are incapable of signal amplification. This means they are just sitting there and do their job. They can be installed / uninstalled but not activated or deactivated.

Passive components consist of a Passive Computation Unit and an Invocation Connector.

Examples for passive components include:

  • Server (in a client/server environment)
  • Databases
  • Caches
  • A knights shield
  • Earths magnetic field

Active Components

An active component is an autonomous, managed, hierarchical software entity that exposes and uses functionalities via services and whose behavior is defined in terms of an internal architecture. [Pokahr & Braubach, 2012]

Active components consist of an Active Computation Process and a Channels Connector.

Just like their Passive counterparts, Active components can be installed and unistalled. But unlike passive components, they need to be activated in order to work. So they have an internal control thread and can receive an external control thread. These threads are only synchronized within the Channels Connector.

Examples for active components include:

  • Client (in a client/server environment)
  • ...
  • ...
  • Bird of Prey cloaking module.
  • Death Star Mk I Superlaser

Composite Components

Active and Passive Components can be linked together by Composition Operators to create a Composite Component. Depending on the nature of these operators, composition can yield either an Active or Passive Compisite.

For sequencing we use

  • Pipe Connectors and
  • Sequencers

For branching we use the

  • Selector Connector

Pipe Connector

A pipe that composes Components C1,...,Cn can call methods in C1,...,Cn in that order and pass the results to subsequent methods.

Sequencer

Does the same as a pipe, but can't pass method results.

Selector Connector

Selectors are Stateful Facades. A Facade is a unified interface to a set of objects. A Stateful Facade behaves depending on the current state of the facade.

This might seem like an anti-pattern, but the statefulness of the Connector is needed to create an Active Composite.

Depending on it's state, the facade determines which sub-component’s methods can be called. So, if a sub-component is active, then the composite will also be active. It can service an endless sequence of inputs and the role of the connector thread is to provide these inputs to the component itself.

The role of roles

TL;DR By combining Components you create Composites that act in a certain way. This "certain way" is described by the COMPOSITE ROLE.

Roles

Since pdc works with databases and webservices to send / receive data from customers, we predefined three roles in this framework for you to use. Of course you can extend these roles or create new ones.

Transmitters

Send data somewhere, Active Only)

asd

Receivers

Receive data from someone, Passive and Active

asd

Transceivers

Receive and transmit data, Active Only)

asd

Component evolution

You should always consider evolving your components. Start simple (by inheriting from the ActiveComponentBase class and take it step by step until you get a set of neat little units that you can use in all your projects.

Let's look at a the Login method for the GeoNamesPostalCodesComponent:

public class GeoNamesPostalCodesComponent : ActiveComponentBase
{
    // constructor omitted...

    public static object Login(string username, string password)
    {
        using (var component = new GeoNamesPostalCodesComponent())
        {
            var result = component.Execute("Login", username, password);
            return result;
        }
    }

    public static object PostalCode(string username, object sessionId, string postalCode)
    {
        // body omitted...
    }
}

There are a couple of little problems here, but there is a BIG ONE as well!

GeoNamesPostalCodesComponent inherits from ActiveComponentBase, so the Execute(...)-Method will return List<object> containing the HttpResponseMessage from the GeoNames API as the only item in the list.

We could return result or could return result[0]... We could even do this:

using (var component = new GeoNamesPostalCodesComponent())
{
    var result = (HttpResponseMessage)component.Execute("Login", username, password);
    return result;
}

What we want is the SessionId in the response because we want to use it in

Conventions

Dependency Injection Ready

All classes can be used - and are tested - with Unity.

var configuration = new Pdc.System.AssemblyConfigurator(Assembly.GetExecutingAssembly();
UnityContainer container = new UnityContainer();

About

PdcFramework provides scaffolding for distributed system components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages