-
Notifications
You must be signed in to change notification settings - Fork 150
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
Adds insights page to Docs #3427
Draft
bomoko
wants to merge
1
commit into
main
Choose a base branch
from
docs/insights
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Lagoon Insights | ||
|
||
*Warning, the Insights System is currently being reworked, so while most of this will still hold in some form, there may be some flux in terms of the details described below* | ||
|
||
Lagoon insights is a rough collection of data related to the state of an environment. | ||
|
||
|
||
# Facts | ||
|
||
The Facts API is used to store arbitrary data against an environment. It is something like a more structured key/value store. | ||
|
||
A fact consists of the following fields | ||
|
||
* id - generated when a fact is inserted. | ||
* environment - *NB* reference to the Environment targeted by the fact. | ||
* name - the fact's name (eg "php-version", "db-size"), an arbitrary string. | ||
* source - *NB* This is a text field used to describe where a fact is "from", properly, how the fact was generated. This is described in more detail below. | ||
* description - arbitrary textual description of the fact. | ||
* keyFact - boolean used internally. Marks a fact as being particularly salient for potentially highlighting in UI or other tools. | ||
* type - the actual _type_ of the fact, defining operations that can be performed with data. Can be `TEXT`, `URL`, or `SEMVER`. | ||
* category - arbitrary string, can be used for categorizing/grouping facts. | ||
* references - Allows further arbitrary text data (such as urls) to be added to a fact. | ||
* service - used to identify which service, where applicable, a fact came from (eg. `cli`, `php`, `node` etc.) | ||
|
||
Importantly, a fact's uniqueness is determined by a combination of its environment, its name, and its source. | ||
|
||
``` | ||
mutation insertFact( | ||
$env: Int! | ||
$name: String! | ||
$source: String! | ||
$description: String! | ||
$value: String! | ||
$service: String | ||
) { | ||
addFact( | ||
input: { | ||
environment: $env | ||
name: $name | ||
source: $source | ||
description: $description | ||
type: TEXT | ||
value: $value | ||
service: $service | ||
} | ||
) { | ||
id | ||
environment { | ||
name | ||
} | ||
name | ||
value | ||
source | ||
description | ||
type | ||
service | ||
} | ||
} | ||
``` | ||
|
||
## Updating facts, patterns and principle | ||
|
||
A typical challenge in working with a live list of continuously updated information like facts is to identify when a fact should be _removed_. | ||
This is where the "source" field is useful. | ||
|
||
Let's say that we have a list of facts that can expand/contract based on the state of a service. If we have, say, a Drupal site where we can install or remove modules more or less arbitrarily, and where we're using the facts DB to keep track of which modules are currently installed on the site. | ||
|
||
There may exist a module that is _currently_ installed, but which remove at some future point. The problem here is that if we have some mechanism for communicating to the Facts API what _currently_ exists, it's not obvious how we remove data that _no longer_ exists. | ||
This is where `source` becomes useful. It's gives us a way of removing _all_ facts from a particular source (like, say, a program that returns the current list of all installed modules on a site), allowing us to only have a list of the most recent data, without the worry of leaving old entries lying around. | ||
|
||
This is what the `deleteFactsFromSource` mutation is for - it allows you to clear a particular set of facts before refreshing the data for that particular set. | ||
|
||
``` | ||
mutation dfbs($env: Int!, $source: String!) { | ||
deleteFactsFromSource(input: { | ||
environment: $env, | ||
source: $source | ||
}) | ||
} | ||
``` | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe take out the NB just because not everyone knows what that stands for.