Merge pull request #3040 from owncloud/runtime-adr

This commit is contained in:
Alex Unger authored and GitHub committed 2022-01-31 10:47:11 +01:00
commit 5c8d92ec67
2 files changed
+67

No files matched your search

@@ -0,0 +1,63 @@
---
title: "14. Microservices Runtime"
weight: 14
date: 2022-01-21T12:56:53+01:00
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/ocis/adr
geekdocFilePath: 0014-microservices-runtime.md
---
* Status: proposed
* Deciders: @butonic, @micbar, @dragotin, @mstingl, @pmaier1, @fschade
* Date: 2022-01-21
## Context and Problem Statement
In an environment where shipping a single binary makes it easier for the end user to use oCIS, embedding a whole family of microservices within a package and running it leveraging the use of the Go language has plenty of value. In such environment, a runtime is necessary to orchestrate the services that run within it. Other solutions are hot right now, such as Kubernetes, but for a single deployment this entails orbital measures.
## Decision Drivers
- Start oCIS microservices with a single command (`ocis server`).
- Clear separation of concerns between services.
- Control the lifecycle of the running services.
- Services can be distributed across multiple machines and still be controllable somehow.
## Considered Options
1.The use of frameworks such as:
- asim/go-micro
- go-kit/kit
2. Build and synchronize all services in-house.
3. A hybrid solution between framework and in-house.
## Options
### go-kit/kit
Pros
- Large community behind
- The creator is a maintainer of Go, so the code quality is quite high.
Cons
- Too verbose. Ultimately too slow to make progress.
- Implementing a service would require defining interfaces and a lot of boilerplate.
### asim/go-micro
Pros
- Implementation based in swappable interfaces.
- Multiple implementations, either in-memory or through external services
- Production ready
- Good compromise between high and low level code.
## Decision Outcome
Number 3: A hybrid solution between framework and in-house.
### Design
{{< svg src="ocis/static/runtime.drawio.svg" >}}
First of, every ocis service IS a go-micro service, and because go-micro makes use of urfave/cli, a service can be conveniently wrapped inside a subcommand. Writing a supervisor is then a choice. We do use a supervisor to ensure long-running processes and embrace the "let it crash" mentality. The piece we use for this end is called [Suture](https://github.com/thejerf/suture).
The code regarding the runtime can be found pretty isolated [here](https://github.com/owncloud/ocis/blob/d6adb7bee83b58aa3524951ed55872a5f3105568/ocis/pkg/runtime/service/service.go). The runtime itself runs as a service. This is done so messages can be sent to it using the oCIS single binary to control the lifecycle of its services.
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than diagrams.net -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1116px" height="522px" viewBox="-0.5 -0.5 1116 522" content="&lt;mxfile host=&quot;app.diagrams.net&quot; modified=&quot;2022-01-28T20:20:15.954Z&quot; agent=&quot;5.0 (Macintosh)&quot; etag=&quot;Y2pHtEwL79NUJLN_3S6x&quot; version=&quot;16.5.2&quot; type=&quot;google&quot;&gt;&lt;diagram id=&quot;9MEpEHi-XydFKFkGZPhA&quot; name=&quot;Page-1&quot;&gt;7VlZc9s2EP41eoyGh648VrIdt5NOM1Vnerx0IBIiEYMEC4CWlF/fXRC8BNpxJlaoB/vBIhbg7uLb/RYHJ+EmO36QpEh/FTHlk8CLj5PwZhIE/ixYwA9KTlayWiwrSSJZbGWtYMu+UCv0rLRkMVW9gVoIrlnRF0Yiz2mkezIipTj0h+0F71stSEIdwTYi3JX+yWKdVtLV3Gvl95QlaW3Z92xPRurBVqBSEotDRxTeTsKNFEJXT9lxQzmiV+NSvXf3RG/jmKS5fskL+t/P6erTWt/d3//2T7n5JXsIy3dWyyPhpZ3w72WuWUatz/pUAyFFmccUdfmTcH1ImabbgkTYe4DYgyzVGbfdViuVmh6fdNdvQID0oSKjWp5giH1hYWGrE2dm24c2CsullaWdCNTjiA180mhusYEHC883QBU4UIlIjQ/TvAdTA1sHJj8YgGlxKZhCB6ZJsOBgdR2zR3hM8DHBalHLwUyna3REg+DaIJ05kCaclODL2FD5sz5U4ehQzR2oSBQBKnp8ps5n15ZXCwcspYXEBXFsrJbetWG1dLAqpDieRkcqXF0bUis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="6" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 768px; height: 1px; padding-top: 171px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Runtime</div></div></div></foreignObject><text x="385" y="175" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">Runtime</text></switch></g><rect x="5" y="271" width="120" height="60" rx="9" ry="9" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 301px; margin-left: 6px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">ocs</div></div></div></foreignObject><text x="65" y="305" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">ocs</text></switch></g><rect x="165" y="271" width="120" height="60" rx="9" ry="9" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 301px; margin-left: 166px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"><div>graph</div></Line truncated

After

Width:  |  Height:  |  Size: 19 KiB