/Microservice

Xigadee is an open-source Microservice framework, developed by Paul Stancer and Guy Steel at Hitachi Consulting. The libraries provide a simple and consistent framework for building modern Microservice enterprise solutions.

Primary LanguageC#

Xigadee

Xigadee is an open-source Microservice framework, developed by Paul Stancer and Guy Steel at Hitachi Consulting, and released under the Apache 2 license by Hitachi Consulting in 2016. You are free to use it within your own commercial applications without restriction.

The framework is a result of our experience - and frustration - over the past five years, in building large-scale distributed cloud applications for our enterprise customers.

We found that when constructing Microservices, we could spend as much time on building and testing the repeatable "plumbing" code (messaging, monitoring, communication, security etc.) as we did on the actual application business logic.

So our goal with Xigadee is to solve that challenge. To provide a consistent development approach, and more importantly - a set of reusable tools that we can apply to any type of Microservice application - while removing the drudgery and overhead of "re-inventing the Microservice-wheel" each time we construct a new distributed solution.

A quick demonstration

The Xigadee libraries are built using Microsoft's .NET technology, and have specific accelerators to target Platform-as-a-Service (PaaS) technologies in the Azure stack.

All the libraries utilise a simple declarative programming model to aid in the construction of the Microservice.

A quick sample of code from this unit test shows how a Microservice can be quickly constructed within a few lines of code. This code can be found in the 'PersistenceSingle' method:

PersistenceClient<Guid, Sample1> repo;

var p1 = new MicroservicePipeline("Local")
    .AddChannelIncoming("request")
        .AttachPersistenceManagerHandlerMemory(
              keyMaker: (Sample1 e) => e.Id
            , keyDeserializer: (s) => new Guid(s)
            , versionPolicy: ((e) => e.VersionId.ToString("N").ToUpperInvariant(), (e) => e.VersionId = Guid.NewGuid(), true)
        )
        .AttachPersistenceClient(out repo)
    .Revert()
    ;

p1.Start();

var sample = new Sample1() { Message = "Hello mom" };
var id = sample.Id;
//Run a set of simple version entity tests.
//Create
Assert.IsTrue(repo.Create(sample).Result.IsSuccess);
//Read
var result = repo.Read(id).Result;
Assert.IsTrue(result.IsSuccess);
Assert.IsTrue(result.Entity.Message == "Hello mom");

This service creates a quick memory-based entity store for the POCO class, Sample1, that supports CRUD (Create/Read/Update/Delete) functions for the entity, with optimistic locking, and additional versioning and search methods, based on a key field (Id) and optional version field (VersionId) defined in the entity.

If we were to use the Xigadee Azure library, we could replace the following method:

.AttachPersistenceManagerHandlerMemory(

with this method, which would switch it to use a DocumentDb (now CosmosDb) backed entity store:

.AttachPersistenceManagerDocumentDbSdk(

or this method to use a Azure Blob Storage collection instead:

.AttachPersistenceManagerAzureBlobStorage(

Refactoring

As mentioned earlier, Xigadee is designed to allow quick rapid application development, through easy refactoring of its pipeline based code. Below we have broken the initial Microservice in to two independent services (PersistenceClientServer method on the same test class), and connected the services together using a manual communication bridge.

//Create an internal test communication bridge
var fabric = new ManualFabricBridge();
var bridgeRequest = new ManualCommunicationBridgeAgent(fabric, CommunicationBridgeMode.RoundRobin);
var bridgeResponse = new ManualCommunicationBridgeAgent(fabric, CommunicationBridgeMode.Broadcast);

PersistenceClient<Guid, Sample1> repo;

var p1 = new MicroservicePipeline("Server")
   .AddChannelIncoming("request")
       .AttachPersistenceManagerHandlerMemory(
             keyMaker: (Sample1 e) => e.Id
           , keyDeserializer: (s) => new Guid(s)
           , versionPolicy: ((e) => e.VersionId.ToString("N").ToUpperInvariant(), (e) => e.VersionId = Guid.NewGuid(), true)
           )
       .AttachListener(bridgeRequest.GetListener())
       .Revert()
   .AddChannelOutgoing("response")
       .AttachSender(bridgeResponse.GetSender())
       ;

var p2 = new MicroservicePipeline("Client")
   .AddChannelIncoming("response")
       .AttachListener(bridgeResponse.GetListener())
       .Revert()
   .AddChannelOutgoing("request")
       .AttachSender(bridgeRequest.GetSender())
       .AttachPersistenceClient("response",out repo)
       .Revert()
       ;

p1.Start();
p2.Start();

The same unit tests can be run, but the system is now functioning as two independent services. These can now be split in to separate executables and run independently. We now need a reliable form of communication between the two services to deliver the messages being sent between them.

Communication

The Xigadee Azure libraries contain specific implementations for the Azure Service Bus that can be easily applied to a Microservice pipeline.

Feedback

Xigadee is in active development across a number of development projects, and is still very much a work-in-progress. We are still working on improving the code, extending the unit-test coverage, adding new features, and providing more detailed documentation.

We are currently getting ready to ship release 1.1 of the Framework, which has some key improvements in creating custom application logic. Our next version will be 2.0 which will be built under the .NET Standard 2.0, which will allow Xigadee applications to work with both traditional .NET Framework libraries, but also to use the new .NET Core multi-platform capabilities, such as Linux and ARM based systems.

We welcome feedback and suggestions for future versions of the Framework. More importantly, if you are using the libraries and discover a bug, please let us know so we can fix it.

Quick guides

Or if you want a more detailed introduction on the Xigadee pipeline and on how to build a new Microservice application using the libraries, then read the following:

If you are new to Microservice development, then the following links gives you an overview of the technology and how to compose a Microservice based application.

NuGet Packages

Xigadee is made up of a set of libraries, which are listed below. They support different areas of Microservice functionality. These capabilities can be added to your project through the relevant NuGet packages.

  • Xigadee
    • This is the core root library that is used to create Microservice and serverless based solutions.
  • Xigadee Azure
    • This library allows for the seamless integration with many of the Azure platform PAAS services.
  • Xigadee Api Server
    • This package allows for the rapid development of API based services, and includes integration with the Unity DI framework.
  • Xigadee Api Client
    • This package speeds up the development of client libraries that consume API services.
  • Xigadee Console
    • This package is designed to help in building simple console based test harnesses, for your Microservice applications.
  • Xigadee Framework
    • This package is used to provide deeper integration in to the Windows platform, and supports features which are not part of the .NET Standard library set.

To read what's new in the latest NuGet release packages, please click here.

Legal Stuff

Copyright © Hitachi Consulting 2012-2017

Licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Hitachi Consulting Created by: Paul Stancer