Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(server): add basic architecture overview of resource manager #2401

Merged
merged 5 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions server/resourcemanager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Resource Manager

`ResourceManager` provides reusable shared operations among resources. This includes the CRUD operations via HTTP, support for different output encodings (yaml or JSON), and Provisioning.


## What is a Resource?

A `Resource` is, conceptually, any entity that can be created, read, updated and/or deleted.
Some examples in Tracetest includes `Test`, `Transaction`, `PollingProfile`, etc.

## How this works
schoren marked this conversation as resolved.
Show resolved Hide resolved

A `ResourceManager` can be instantiated with a few arguments:
- Resource name, singular and plural,
- List of enabled operations,
- Handler

The handler is a class that handles the persistence of entities. It must support **at least** the required methods for the enabled operations.

For example, a resource that wants to enable the `create` operation needs to provide a Handler that has a `Create` method.

The provisioning process is handled by an external `Provisioner` class, but the `ResourceManager` instance handles the actual provisioning, meaning the actual persistence of the provisioning data.

Here is a flow of a `ResourceManager` setup process:

```mermaid
---
title: Instantiating a new ResourceManager
---
stateDiagram-v2

Setup: Instantiate ResourceManager

app --> Setup
Setup --> Registering

state Setup {
validateHandler: check that \n handler implements \n the registered operations
bind: Bind handler methods to http handlers

[*] --> validateHandler
validateHandler --> bind
}

state Registering {
registerRoutes: create mux subrouter \n with http handlers
registerProvisioner: add new ResourceManager \n to provisioner registry
[*] --> registerRoutes
registerRoutes --> registerProvisioner
}

```

6 changes: 6 additions & 0 deletions wiki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Wiki Index


## Architecture

1. [Resource Manager](../server/resourcemanager/README.md)