Any Kronos client will be available to use three basic commands
In future I want to add few more, like Count and GetKeys.
Each of requests to the server serialized to binary form is preceded by few bytes of meta-data, including RequestType. In code its represented as a Request class, which in addition to type has two generic methods. At the beginning they might look difficult, but they are quite simple. First of them is responsible for sending any request to the server via special connection interface. It’s generic, because some of them might return another type. For example Get will always return a byte array, but Insert and Delete – void.
The second, protected method, takes care the logic for processing the response. At the beginning I thought that the processing bytes from server will always be the same. Unfortunately, due to one thing I had to change my idea. How to send null by socket? It is impossible to serialize null without any special-magic-combo-values like chain of specific numbers. How to send empty byte array between sockets? Again, it is impossible. Similar to HTTP, I’ve created a special codes.
Back to the PrepareResponse method, it is protected, because some Request processes a response in different way. For example, GetRequest checks if bytes from server contain information about StatusCodes.
You may notice that I have used a Proto attributes from Protobuf library. In next post I’m going to describe the way of working with Protocol Buffers and .NET Core.
Kronos is already available on the github. Feel free to ask, comment and give feedback!
.NET framework in version 4.5 provides a cool improvement into Garbage Collector – server mode. This option allows GC to be more efficient on modern hardware. MSDN contains a great article about this feature, which I really recommend you to read.
ASP.NET has Server mode turned on by default. Nothing stands on the way of enabling server mode on console app. You can do it with app.config and three lines in xml.
My project Kronos is a distributed cache system, where GC will have a lot of work. How to enable GC Server on the .NET Core framework? DNX runtime enables this mode by default 🙂 However as usual, there is an exception for this.
- Windows – by default turned on
- Linux – Not supported
- Windows and Linux – configurable from config json file
Unfortunately Andrew Stanton-Nurse from Microsoft has written a pessimistic message:
I don’t expect it’s going to make RC2. It can probably wait for RTM
If you are interested in this topic, here is a official issue from github.
Packing and publishing nuget from standard .NET project is very simple. Create or generate nuspec file and run
The appearance of the Core framework and project.json file caused the a little change. Due to historical reason, in .NET Core we have two command line interfaces with utilities for packages.
- DNU – DNX utility, used in project < RC2
- Dotnet – the newest CLI, combined tool composed of DNX and DNU
Continue reading XGain #03 – Publishing .NET Core project to nuget
In the third post about XGain I would like to say something about the heart of server. TcpListener is a great class to build server. It has a normal and async methods, you can choose between Socket and TcpClient. Unfortunately writing this same logic for new project might be boring. The most common steps:
- choose entry port
- create new instance of TcpListener
- start listening
- create a main loop for processing
- handle new request
Continue reading XGain #02 – Heart of the TCP/IP server
Previously I’ve described the most popular ways to deal with TCP/IP connection in .NET framework. This time I want to show you one of the most important interface in the XGain server – ISocket.
Network layer is really hard to test and debug. XGain works on the Socket class level and this class doesn’t have an interface. That means testing of any component references to this type is really hard, but everything is possible. Few months ago I found a good podcast with Paweł Klimczyk and Maciej Aniserewicz about mocking frameworks. In full .NET Framework we can use TypeMock to create a fake call to the any method from any type. Unfortunately, this library does not support .NET Core platform.
Continue reading XGain #01 – abstraction over Socket
Almost three months ago I’ve started working on Kronos with only one idea – make it as good as I can and have fun. In the past I had the pleasure to work only with high level networking – HTTP(S). Network layer in distributed systems is one of the most sensitive and in case of project with requirement for high performance, HTTP is not the best idea.
Continue reading XGain #00 – TCP/IP server written in C#
New plugin for Visual Studio 2015 – Microsoft ASP.NET and Web Tools (download here) provides new templates for .NET Core – Console Application and Class Library. These templates are the base structure for all multi-platform projects in .NET.
Let’s start with executable type – Console Application. By default this one contains three files – AssemblyInfo.cs, Program.cs and project.json. Program file provides an entry point for application – just like normal static Main method in .NET Framework. The last one, project.json file is more interesting – it is the successor for old app.config. In this file you can find dependencies, .NET Core frameworks and nuspec information. Continue reading .NET Core project templates
I’ve spent some time on searching for good Continuous Integration (CI) for Kronos. My requirements were simple:
- free for Open Source project
- support for .NET Core (DNX runtimes)
- easy configuration
- good connection with github
Yegor Bugayenko wrote a great article about CI platforms. Here is a table with differences:
ASP.NET team uses AppVeyor. My decision was quite fast – let’s play with this CI.
Continue reading .NET Core and Continuous Integration with AppVeyor
Since last year I was thinking how to increase my skills with multithreading programming and distributed systems. I really like these topics – after reading few books I still want to learn more. With current growth rate of cloud platforms these two skills could be really desirable in the labor market. Also I never had enough experience with operating system other than Windows. In next May I will be completing my Bachelors degree, so it would be great to combine these ideas with my engineer’s thesis. After quick technology research and few conversations with another programmers – I’ve decided what I want to write – distributed cache system, available on Linux – Kronos. Sounds reasonable, yes?
Except one thing – I want to do it with .NET.
Continue reading Kronos #01 – distributed cache system based on .NET Core
Konfiguracja WordPressa pozwala nam na starowanie systemem generowania linków do artykułów i podstron. Jedną z dostepnych opcji są tzw. Pretty Permalinks, czyli ładne linki zwiększające poziom SEO naszego bloga. W przypadku gdy nasz CMS jest zainstalowany na Internet Information Services (IIS) zmiana konfiguracji linków wymaga edycji pliku web.config.
Continue reading (PL) Pretty Permalinks i WordPress na serwerze IIS