/workspace/cache
The module exports the default checkWorkspaceCache method which returns the async cacheWorkspace method which resolves into a JSON workspace.
Default templates can be overwritten in the workspace or by providing a CUSTOM_TEMPLATES xyzEnvironment variable which references a JSON with templates to be merged into the workspace.
- Source
Requires
- module:/provider/getSrc
- module:/utils/processEnv
- module:/utils/telemetry
Methods
(inner) assign_workspace_templates(workspace_templates, templates_object, typeopt) → {Object}
The method assigns objects in a templates object to the workspace.templates provided as workspace_templates param.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
workspace_templates | object | The workspace.templates object. | ||
templates_object | Object | An object of templates to be assigned with the template key to the workspace templates. | ||
type | string | <optional> | 'core' | The type value to assign to the template to identify the origin. |
- Source
templates_object with _core: true property.
- Type:
- Object
(inner) cacheReason(forceopt) → {string}
Returns the reason for the workspace to be cached. The workspace has not been cached yet if the timestamp is 0.
| Name | Type | Attributes | Description |
|---|---|---|---|
force | boolean | <optional> | The workspace cache is cleared with the force param flag. |
- Source
The reason [force, expired, initial].
- Type:
- string
(async, inner) cacheWorkspace(span) → {Promise.<workspace>}
The workspace is retrived from the source defined in the WORKSPACE xyzEnvironment variable.
Templates defined in the CUSTOM_TEMPLATES xyzEnvironment variable are spread into the default workspace.templates{}.
Each locale from the workspace.locale{} is merged into the workspace.locale{} template.
Locale objects get their key and name properties assigned if falsy.
The workspace is assigned to the module scope workspacePromise variable and the timestamp is recorded.
| Name | Type | Description |
|---|---|---|
span | Span | The workspace.cache span. |
- Source
Resolves to the JSON workspace.
- Type:
- Promise.<workspace>
(inner) checkWorkspaceCache(forceopt) → {Promise.<workspace>}
The async cacheWorkspace method is assigned to the module scope workspacePromise variable. The variable is re-assigned if the WORKSPACE_AGE xyzEnvironment variable is exceeded or the force param is true.
| Name | Type | Attributes | Description |
|---|---|---|---|
force | boolean | <optional> | The workspace cache will be cleared with the force param flag. |
- Source
Resolves to the JSON workspace.
- Type:
- Promise.<workspace>
(inner) tracedCacheWorkspace(reason) → {Promise.<workspace>}
Calls the cacheWorkspace method within a workspace.cache span. The reason for the workspace to be cached is assigned to the span and the root span of the request which triggered the cache.
| Name | Type | Description |
|---|---|---|
reason | string | The reason for the workspace to be cached [initial, expired, force, retry]. |
- Source
Resolves to the JSON workspace.
- Type:
- Promise.<workspace>