问题
I got a desktop application and it's getting bigger and bigger. And i wonder if i can make something like microservices with desktop application? I want to application for now stays desktop. Application it's written in C++. I can exclude some of the modules with some preparations. But is it possible and if anybody have idea how to start with this?
回答1:
Desktop application and microservices are mutually exclusive because Desktop means one machine and microservices implies multiple machines (physical or virtual) that communicate through network using a technology agnostic protocol.
What you can do is to use modularization. This is an alternative to microservices that can work in some scenarios like yours.
回答2:
A microservice-like architecture for the desktop is feasible. In fact, many OSes use services, which are often called daemons. For instance, the X Window system uses a client/server architecture. More recently, IDEs can now use the Language Server Protocol to communicate with one or more language servers that provide syntax highlighting, code completion, compilation feedback, etc.
There are a few things to consider:
- What communication protocols are already available on the target system? On many systems, you can use a D-Bus (https://en.wikipedia.org/wiki/D-Bus)
- What performance do you need? If performance is highly critical, you will need to use a highly optimized protocol for communicating between services, and startup times will need to be small. For good performance, something similar to the Language Server Protocol is probably good enough and will be easier to write, maintain and debug.
- Can you handle the added complexity of splitting processes up? In a monolith, the whole thing is either up or down. With microservices, parts of the system that are running can attempt to call parts that are not. This situation must be handled.
- What are the seams in your applications? Where can you split it up easily? Take a look at Domain Driven Design. Identify potential independent modules, and refactor to confirm. If the refactoring makes sense then split the module into its own process.
来源:https://stackoverflow.com/questions/46451544/c-microservices-with-desktop-application