Skip to content

Commit

Permalink
doc(server): add basic architecture overview of resource manager (#2401)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Jun 6, 2023
1 parent 7b6cf28 commit 0af6764
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
53 changes: 53 additions & 0 deletions server/resourcemanager/README.md
@@ -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

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
@@ -0,0 +1,6 @@
# Wiki Index


## Architecture

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

0 comments on commit 0af6764

Please sign in to comment.