xcomponent / reactivexcomponent.net Goto Github PK
View Code? Open in Web Editor NEWC# API for XComponent
License: Apache License 2.0
C# API for XComponent
License: Apache License 2.0
2 main changes need to be considered:
Implement the Websocket Reactive Client API for XComponent.
We need to merge dependency assemblies into the ReactiveXComponent.Net assembly. We should also make sure that the right types are internalized.
ILRepack can be used to accomplish this.
Send event to a specific state machine by using state machine ref
Add a script to launch Linux build on Windows using Docker.
That gives a way to validate the Linux build on a Windows environment.
Header objects for RabbitMq and Websocket have changed in the XComponent version 5. Need to make the proper changes so the Api can communicate with that version.
Implementation of a rabbitmq publisher to send message to xcomponent
Once the websocket bridge is down, the client websocket connection is lost.
It is not re-established manually and/or automatically when the websocket bridge is up.
/!\ The feature is to be implemented /!\
XComponent components can be used in embedded mode (as a library). Need to implement that mode for the Reactive Api.
In MessageEventArgs the MessageReceived field is of type object. We should have a helper to properly cast that object depending on the serialization type.
Like the default client Api natively provided by XComponent, it could be necessary to include a custom serializer layer in the reactivexcomponent api.
Need to add support for SSL for Websocket mode.
API deosn't send the right data to trigger a transition.
The XComponent Runtime supports natively lambda expressions to filter state machines instances according their public members properties. The idea of this feature is to extend the GetSnapshot method to add this lambda expression.
Example:
Imagine a public member with the property "Id".
We want all state machines matching a specific Id:
myComponentStm.GetSnapshot("Id == 1234")
The filter can be checked with the following code:
public static void CheckFilter(string filter) where T : class
{
try
{
var dynamicExpression = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[] { Expression.Parameter(typeof(T)) }, typeof(bool), filter, new object[0]);
dynamicExpression.Compile();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
The Rabbit Mq implementation should wrap the used library and expose an Interface. This way it would be easier to maintain and test (as it would be much easier to mock).
A session enables to create a subscriber
-> subscribe on state machine updates
-> use rx.net (http://reactivex.io)
Due to some known issues with WebsocketSharp we should switch to WebSocket4Net. A more mature WebSocket client.
Add a generated client Api that uses ReactiveXComponent module to communicate with the components.
It's possible to cast the received message to a type using MessageEventArgs.GetMessage(). But that method expects the serialization type as a parameter. The Api should be able to use the right serialization type on its own as it is initialized with an xcApi file and that file contains the info about serialization.
Add possibility to override communication configuration in IXComponentApi.CreateSession().
This change should be made as a patch for version 1.0.0 and also be ported to the default branch.
For example, using RabbitMQ, when deserialization fails (e.g. if the class of the object is unknown) the exception is not reported in any way by the API.
Add a handler/listener so that users can be told when something wrong happens.
Two main functionalities should be added:
PS: This can only be implemented for WebSocket.
A helper to read configuration file (eg: xcApi) exists. We can retrieve statemachine code , component code but not the state code. Improve this helper to include a method to retrieve the state code.
Add a new CreateFromXCApi method with the file path of xcApi as parameter.
Create the foundation of our API:
(no specific implementation such as rabbitmq)
It's just the first step to show how it should work.
Internalize dependencies with IlRepack (RabbitMq, JSON...) This way, the package will be easiest to integrate in client applications.
The current parser is using XmlDocument to parse the Api description file. We should be using XDocument instead.
Add the possibility to decode a message from an anonymous type.
JsonConvert.DeserializeAnonymousType method can be used.
Please look at the example below:
subscriber.Subscribe("MyComponent", args =>
{
var anonymousType = new
{
Type = string.Empty,
Status = string.Empty,
Enabled = false,
Message = string.Empty,
};
var myType = args.GetMessage(anonymousType);
if (myType != null)
{
}
});
This is an update that must be done following the implementation of the built-in error state in XComponent. If an unhandled exception occurs in a triggered method the following sequence happens:
Compile the lib with mono on osx
This might have emerged after migrating to a newer version of RabbitMq.Client library.
The problem is that, in Rabbit Mq Subscriber, each handler is sending an acknowledgement to the bus regardless of whether the message received is intended for that handler or not. This scenario only occurs for private topic subscription as all private state machines updates are published in the same (private) channel.
Rabbit Mq seems to close the channel if an extra aknowledgement is received. And the current implementation of channels disposal doesn't check if the channel is open before closing it.
Also the acknowledgement should be fixed so it is only sent by the right subscriber.
XComponentApi.CreateFromXCApi throws an exception when different components have the same state machine name
xcSession implementation based on rabbitmq
On public IXCSession CreateSession(ConfigurationOverrides configurationOverrides = null) method the folllowing code should use string.IsNullOrEmpty instead of null:
if (configurationOverrides.Host != null)
{
busDetails.Host = configurationOverrides.Host;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.