This repository has been archived by the owner on Jun 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GITBOOK-1136: Apps-Engine App Lifecycle: Iteration 1
- Loading branch information
1 parent
ce63903
commit 60c4e16
Showing
4 changed files
with
43 additions
and
46 deletions.
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
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 |
---|---|---|
@@ -1,5 +1,27 @@ | ||
# App Lifecycle | ||
# App Development Lifecycle | ||
|
||
Rocket.Chat Apps are inherently distinct from what you may be accustomed to on other platforms, as they operate within a Rocket.Chat server. This allows Rocket.Chat users retain all of their data within their own structure, as the server is no longer required to send data to an externally hosted service that provides additional functionality. | ||
Application development is the process of planning, designing, developing, and putting the app to its intended use. This process typically follows the Application Development Life Cycle (ADLC). ADLC is a set of methodologies that facilitate app development. It guides developers to optimize the development project at every stage. The overall development cycle can vary based on the type of business, customers, and requirements. | ||
|
||
For an App to be added to a Rocket.Chat workspace, it must either be downloaded from our [Marketplace](http://marketplace.rocket.chat) or manually uploaded to the server. Once something is introduced to Rocket.Chat, it moves through several phases. In the following sections, we will elaborate on each phase and delve more deeply into the Rocket.Chat-specific phases. We will also discuss an application's lifecycle methods while it is running inside Rocket.Chat server.  | ||
The significant app development phases include: | ||
|
||
* Discovery phase | ||
* Design phase | ||
* Development phase | ||
* Quality assurance phase | ||
* Release phase | ||
* Maintenance phase | ||
|
||
In addition, there are numerous methods for developing applications, including the waterfall method, rapid application development, agile, and DevOps methodologies. Depending on your organization's app development methodology, these steps may vary. | ||
|
||
Additional Rocket.Chat-specific phases of the app development lifecycle include: | ||
|
||
* App Logging | ||
* App Deployment | ||
* App Installation | ||
* App Testing | ||
|
||
## Rocket.Chat apps | ||
|
||
Rocket.Chat apps are inherently distinct from what you may be accustomed to on other platforms as they operate within a Rocket.Chat server. This allows the users to retain all their data within their own structure, as the server is not required to send data to an externally hosted service that provides additional functionality. | ||
|
||
To add an app to a Rocket.Chat workspace, you must either download it from our [Marketplace](http://marketplace.rocket.chat) or manually [upload it to the server](https://docs.rocket.chat/extend-rocket.chat-capabilities/rocket.chat-marketplace). Once an app is introduced to Rocket.Chat, it goes through several phases. In the next section, we will learn about the app lifecycle states in a Rocket.Chat server. |
21 changes: 0 additions & 21 deletions
21
apps-engine/understanding-app-lifecycle/app-development-lifecycle.md
This file was deleted.
Oops, something went wrong.
35 changes: 16 additions & 19 deletions
35
apps-engine/understanding-app-lifecycle/lifecycle-of-a-running-app.md
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 |
---|---|---|
@@ -1,81 +1,78 @@ | ||
# Lifecycle of a running app | ||
# Lifecycle of a Rocket.Chat App | ||
|
||
App lifecycle refers to the processes involved in enabling an app and the stages it may undergo. The app can connect to some of these processes in order to modify or extend the configuration of the Apps Engine; these are the phases an application goes through while running inside a server — it is more of a lifecycle during runtime.  | ||
For Rocket.Chat apps, app lifecycle refers to the processes involved in enabling an app and the phases it may undergo. The app goes through the lifecycle phases during runtime in a Rocket.Chat server. | ||
|
||
In many of these lifecycle stages, the application's status will change within the Apps Engine. On the Rocket.Chat, only two stages are displayed: enabled and disabled. But technically, there are additional statuses that determine the app's current state. This is useful for developers because it provides insight into the app's phases and how to control various aspects of an app operating on a Rocket.Chat server.  | ||
In many of the lifecycle phases, the app's status will change within the Apps-Engine. In the Rocket.Chat UI, two statuses are displayed, `enabled` and `disabled`. Technically, there are additional statuses that determine the app's current stage. This gives developers an insight into an app's phases. The `App` class has a number of extendable methods to provide control over the various aspects of the app's lifecycle. | ||
|
||
The `App` class has a number of extendable methods that provide control over various aspects of the app's lifecycle. | ||
Here we will learn about the methods that represent the various states of a functioning app:  | ||
|
||
The following methods represent the various states of a functioning application:  | ||
**`Constructed`**: The app has just been created or instantiated. There is little an app can do at this point.  | ||
|
||
**`Constructed`**: The application has just been created or instantiated. There is little an app can do at this point.  | ||
|
||
**`Initialize`**: During this phase, the application is initialized. Here, the application can obtain configuration from the Apps Engine, register objects, and extend functionality. It indicates that the application's initialize() function was invoked and returned true. `initialize` enables the App to govern its internal initialization procedure and override the default one. | ||
**`Initialize`**: During this phase, the app is initialized. Here, the app can obtain configuration from the Apps-Engine, register objects, and extend functionality. It indicates that the app's `initialize()` function was invoked and returned true. This enables the app to govern its internal initialization procedure and override the default one. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async initialize(configurationExtend: IConfigurationExtend, environmentRead: IEnvironmentRead): Promise<void> | ||
``` | ||
{% endcode %} | ||
|
||
* **`extendConfiguration`**: This method is executed as part of the application's default initialization procedure. The configuration accessor enables the application to provide robust functionality such as **API Endpoints** and **Slash Commands** using the[ configuration accessor](https://rocketchat.github.io/Rocket.Chat.Apps-engine/interfaces/accessors\_iconfigurationextend.iconfigurationextend.html). | ||
* **`extendConfiguration`**: This method is executed as part of the app's default initialization procedure. The configuration accessor enables the app to provide robust functionality such as **API Endpoints** and **Slash Commands** using the[ configuration accessor](https://rocketchat.github.io/Rocket.Chat.Apps-engine/interfaces/accessors\_iconfigurationextend.iconfigurationextend.html). | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async extendConfiguration(configuration: IConfigurationExtend, environment: IEnvironmentRead): Promise<void> | ||
``` | ||
{% endcode %} | ||
|
||
**`Enable`**: The app determines whether it is enabled or not. If the parameters are configured correctly, the app will be enabled. This method is executed during the app's activation process. If it returns false, the Apps Engine stops the enabling process and unloads the app's resources configured during initialization. | ||
**`Enable`**: If the app parameters are configured correctly, the app will be enabled. This method is executed during the app's activation process. If it returns false, the Apps-Engine stops the enabling process and unloads the app's resources configured during initialization. | ||
|
||
* **`Auto_enabled`**: the app’s `onEnable()` was called, returned true, and was done automatically (system startup).  | ||
* **`Manually_enabled`**: the app’s `onEnable()` was called, returned true, and was done by the user (such as installing a new one).  | ||
* **`Auto_enabled`**: the app’s `onEnable()` function is called, returns true, and the app is enabled automatically (at system startup).  | ||
* **`Manually_enabled`**: the app’s `onEnable()` function is called, returns true, and the app is enabled by the user (such as installing a new app).  | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async onEnable (environment: IEnvironmentRead, configurationModify: IConfigurationModify): Promise<boolean> | ||
``` | ||
{% endcode %} | ||
|
||
**`Disable`**: The application can be disabled, either automatically in response to a system interaction or manually through the marketplace. For instance - when Community workspaces have limitations, the apps will be disabled automatically depending on the cap on the number of apps that can be installed per workspace. If the app is a subscription app, it will be disabled when the subscription expires. | ||
**`Disable`**: The app can be disabled, either automatically in response to a system interaction or manually through the marketplace. For instance - when Community workspaces have limitations, the apps will be disabled automatically depending on the limit on the number of apps that can be installed per workspace. If the app is a subscription app, it will be disabled when the subscription expires. | ||
|
||
```typescript | ||
async onDisable(configurationModify: IConfigurationModify): Promise<void> | ||
``` | ||
|
||
Several additional app phases associated with disable are as follows: | ||
|
||
<table><thead><tr><th width="340.5">App Phase</th><th>Meaning</th></tr></thead><tbody><tr><td><code>compiler_error_disabled</code></td><td>An error occurred while attempting to compile the app, which rendered it inoperable. Attempts to re-enable it will fail, as it requires an update.</td></tr><tr><td><code>invalid_license_disabled</code></td><td>The app was disabled because its license was invalid.</td></tr><tr><td><code>invalid_installation_disabled</code></td><td>The app was disabled due to an invalid installation or signature validation.</td></tr><tr><td><code>error_disable</code></td><td>The app was disabled due to an unrecoverable error.</td></tr><tr><td><code>manually_disabled</code></td><td>A user manually disabled the application.</td></tr><tr><td><code>invalid_settings_disabled</code></td><td>The app was disabled due to invalid configuration settings.</td></tr></tbody></table> | ||
<table><thead><tr><th width="340.5">App Phase</th><th>Description</th></tr></thead><tbody><tr><td><code>compiler_error_disabled</code></td><td>An error occurred while attempting to compile the app, which rendered it inoperable. Attempts to re-enable it will fail, as it requires an update.</td></tr><tr><td><code>invalid_license_disabled</code></td><td>The app was disabled because its license was invalid.</td></tr><tr><td><code>invalid_installation_disabled</code></td><td>The app was disabled due to an invalid installation or signature validation.</td></tr><tr><td><code>error_disable</code></td><td>The app was disabled due to an unrecoverable error.</td></tr><tr><td><code>manually_disabled</code></td><td>A user manually disabled the application.</td></tr><tr><td><code>invalid_settings_disabled</code></td><td>The app was disabled due to invalid configuration settings.</td></tr></tbody></table> | ||
|
||
**`Install`**: This is only when the application is manually uploaded as a private app or installed through the marketplace. It only occurs once during installation. Upon installation, you can send messages to the admin notifying them about the availability of the application or send the user who is installing configuration steps and instructions on how to get started in a direct message.  | ||
**`Install`**: This is only when the application is manually uploaded as a private app or installed through the marketplace. It only occurs once during installation. After installation, you can send messages to the admin notifying them about the availability of the app or send configuration steps and instructions on how to get started to the user who is installing the app.  | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async onInstall(context: IAppInstallationContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> | ||
``` | ||
{% endcode %} | ||
|
||
**`Uninstall`**: This phase occurs when a user manually uninstalls an application. This is not feasible to occur automatically. Upon uninstallation, you can use this status to perform housekeeping, notify the server or an external service, or send a message to the user. | ||
**`Uninstall`**: This phase occurs when a user manually uninstalls an app. This is not feasible to occur automatically. Upon uninstallation, you can use this status to perform housekeeping, notify the server or an external service, or send a message to the user. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
public async onUninstall(context: IAppUninstallationContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> | ||
``` | ||
{% endcode %} | ||
|
||
**`SettingUpdated`**: Tokens to authenticate with third-party services, etc., can be the settings for an application. When a change is made to one of these settings, the application can respond accordingly. The onSettingUpdated method is executed when an administrator modifies a setting provided by the App via the App Administration Page. This occurs following the update of a configuration. You can now retrieve the modified value. | ||
**`SettingUpdated`**: For instance, the settings for an app can include tokens to authenticate with third-party services. When a change is made to such settings, the app can respond accordingly. The `onSettingUpdated` method is executed when an administrator modifies a setting provided by the app via the **App Administration Page**. This occurs following the update of a configuration. You can now retrieve the modified value. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async onSettingUpdated(setting: ISetting, configurationModify: IConfigurationModify, read: IRead, http: IHttp): Promise<void> | ||
``` | ||
{% endcode %} | ||
|
||
**`PreSettingUpdate`**: This is used to retrieve the before and after values of the modified parameter. Consider, for example, the JIRA app. If the user modifies the server URL, the application can attempt to connect to the new server to perform validations or seamlessly react to the change.  | ||
**`PreSettingUpdate`**: This is used to retrieve the before and after values of a modified parameter. Consider, for example, the JIRA app. If the user modifies the server URL, the app can attempt to connect to the new server to perform validations or seamlessly react to the change.  | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
async onPreSettingUpdate(context: ISettingUpdateContext, configurationModify: IConfigurationModify, read: IRead, http: IHttp): Promise<ISetting> | ||
``` | ||
{% endcode %} | ||
|