Skip to content

Commit

Permalink
docs: remove blog and add Advanced Features
Browse files Browse the repository at this point in the history
  • Loading branch information
credmond-git committed Oct 7, 2024
1 parent 4e908a2 commit 364246b
Show file tree
Hide file tree
Showing 30 changed files with 91 additions and 153 deletions.
12 changes: 0 additions & 12 deletions docs/gestalt-static/blog/2019-05-28-first-blog-post.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/gestalt-static/blog/2019-05-29-long-blog-post.md

This file was deleted.

24 changes: 0 additions & 24 deletions docs/gestalt-static/blog/2021-08-01-mdx-blog-post.mdx

This file was deleted.

Binary file not shown.
29 changes: 0 additions & 29 deletions docs/gestalt-static/blog/2021-08-26-welcome/index.md

This file was deleted.

23 changes: 0 additions & 23 deletions docs/gestalt-static/blog/authors.yml

This file was deleted.

19 changes: 0 additions & 19 deletions docs/gestalt-static/blog/tags.yml

This file was deleted.

26 changes: 26 additions & 0 deletions docs/gestalt-static/docs/advanced/reload-strategies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
sidebar_position: 1
---

# Reload Strategies
Gestalt is idempotent, as in on calling `loadConfigs()` a config tree is built and will not be updated, even if the underlying sources have changed.
By using Reload strategies you can tell Gestalt when the specific config source has changed to dynamically update configuration on the fly. Once the config tree has been rebuilt, Gestalt will trigger its own Gestalt Core Reload Listener. So you can get an update that the reload has happened.

When adding a ConfigSource to the builder, you can choose to a reload strategy. The reload strategy triggers from either a file change, a timer event or a manual call from your code. Each reload strategy is for a specific source, and will not cause all sources to be reloaded, only that source.
Once Gestalt has reloaded the config it will send out its own Gestalt Core Reload event. you can add a listener to the builder to get a notification when a Gestalt Core Reload has completed. The Gestalt Cache uses this to clear the cache when a Config Source has changed.

```java
Gestalt gestalt = builder
.addSource(FileConfigSourceBuilder.builder()
.setFile(devFile)
.addConfigReloadStrategy(new FileChangeReloadStrategy())
.build())
.addCoreReloadListener(reloadListener)
.build();
```

| Reload Strategy | Details |
|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| FileChangeReload | Specify a FileConfigSource, and the FileChangeReload will listen for changes on that file. When the file changes it will tell Gestalt to reload the file. Also works with symlink and will reload if the symlink change. |
| TimedConfigReloadStrategy | Provide a ConfigSource and a Duration then the Reload Strategy will reload every period defined by the Duration |
| ManualConfigReloadStrategy| You can manually call reload to force a source to reload. |
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
sidebar_position: 5
---

# Tags Example
When adding a config source you are able to apply zero or more Tags to the source. Those tags are then applied to all configuration within that source. Tags are optional and can be omitted.
When retrieving the config it will first search for an exact match to the tags, if provided, then search for the configs with no tags. It will then merge the results.
If you provide 2 tags in the source, when retrieving the configuration you must provide those two exact tags.

```java
// head.shot.multiplier = 1.3
// max.online.players = 32
ConfigSourcePackage pveConfig = ClassPathConfigSourceBuilder.builder()
.setResource("/test-pve.properties")
.setTags(Tags.of("mode", "pve"))
.build();

// head.shot.multiplier = 1.5
ConfigSourcePackage pvpConfig = ClassPathConfigSourceBuilder.builder()
.setResource("/test-pvp.properties")
.setTags(Tags.of("mode", "pvp"))
.build();

// head.shot.multiplier = 1.0
// gut.shot.multiplier = 1.0
ConfigSourcePackage defaultConfig = ClassPathConfigSourceBuilder.builder()
.setResource("/test.properties")
.setTags(Tags.of())
.build(); // Tags.of() can be omitted

Gestalt gestalt = builder
.addSource(pveConfig)
.addSource(pvpConfig)
.addSource(defaultConfig)
.build();

// retrieving "head.shot.multiplier" values change depending on the tag.
float pvpHeadShot = gestalt.getConfig("head.shot.multiplier", Float.class, Tags.of("mode", "pve")); // 1.3
float pveHeadShot = gestalt.getConfig("head.shot.multiplier", Float.class, Tags.of("mode", "pvp")); // 1.5
float coopHeadShot = gestalt.getConfig("head.shot.multiplier", Float.class, Tags.of("mode", "coop")); // 1.0 fall back to default
float defaultHeadShot = gestalt.getConfig("head.shot.multiplier", Float.class); // 1.0

// Gut shot is only defined in the default, so it will always return the default.
float pvpGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "pve")); // 1.0
float pveGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "pvp")); // 1.0
float coopGutSoot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "coop")); // 1.0
float defaultGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class); // 1.0

// Max online players is only defined in the pvp, so it will only return with the pvp tags.
float pvpGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "pve")); // 32
float pveGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "pvp")); // not found
float coopGutSoot = gestalt.getConfig("gut.shot.multiplier", Float.class, Tags.of("mode", "coop")); // not found
float defaultGutShot = gestalt.getConfig("gut.shot.multiplier", Float.class); // not found
```

* **Note**: The config node processor string replacement doesn't accept tags, so it will always replace the configs with the tag-less ones.
8 changes: 7 additions & 1 deletion docs/gestalt-static/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ const config: Config = {
position: 'left',
label: 'Tutorial',
},
{to: '/blog', label: 'Blog', position: 'left'},
{
type: 'docSidebar',
sidebarId: 'advancedSidebar',

position: 'left',
label: 'Advanced Features',
},
{
href: 'https://github.com/gestalt-config/gestalt',
label: 'GitHub',
Expand Down
3 changes: 2 additions & 1 deletion docs/gestalt-static/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
*/
const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
tutorialSidebar: [{type: 'autogenerated', dirName: 'tutorial'}],
advancedSidebar: [{type: 'autogenerated', dirName: 'advanced'}],

// But you can create a sidebar manually
/*
Expand Down

0 comments on commit 364246b

Please sign in to comment.