Skip to content

Commit

Permalink
Add page for RabbitMQ, fix links, add ELI information, other minor tw…
Browse files Browse the repository at this point in the history
…eaks (#710)
  • Loading branch information
Oschroder authored Aug 20, 2024
1 parent e3f1b10 commit b0da1f0
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 199 deletions.
Binary file added documentation/docs/assets/images/ELI_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion documentation/docs/developer-guide/achitecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ The User Office application leverages a modular architecture with several interc

**SciCat, NICOS, and Asset Management Systems**

- These external systems interface with the User Office application to ensure efficient asset management and integration with external resources, enhancing the overall functionality and data management capabilities.
- These external systems interface with the User Office application to ensure efficient asset management and integration with external resources, enhancing the overall functionality and data management capabilities.
13 changes: 8 additions & 5 deletions documentation/docs/developer-guide/configuration.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
This page provides detailed instructions for configuring your environment. Proper configuration is essential for ensuring the project functions correctly. The configuration is managed through a `.env` file, which contains environment variables for various services and settings required by the application. The default configuration values are provided, but you can override these by setting the appropriate environment variables in your `.env` file.
This page provides detailed instructions for configuring your environment. Proper configuration is essential for ensuring the project functions correctly.

The configuration is managed through a `.env` file, which contains environment variables for various services and settings required by the application. The default configuration values are provided, but you can override these by setting the appropriate environment variables in your `.env` file.

> **_NOTE:_** The `DEPENDENCY_CONFIG` variable is crucial for the User Office application. It enables, disables, or modifies various features based on the specified configuration. You can find the different configuration files in the `apps/backend/src/config` directory.
The `.env` file format is supported by the dotenv library, which loads these variables into the environment when the application starts. If a specific dependency configuration is not provided, the default configuration will be used. For more detailed information, refer to the [dotenv documentation](https://www.npmjs.com/package/dotenv).
The `.env` file format is supported by the dotenv library, which loads these variables into the environment when the application starts. If a specific dependency configuration is not provided, the default configuration will be used.

For more detailed information, refer to the [dotenv documentation](https://www.npmjs.com/package/dotenv).

## Environment Variables

Expand All @@ -24,7 +28,7 @@ To enable local logging via Graylog, uncomment and configure the following varia
- **GRAYLOG_PORT**: The port for the Graylog server.

### ORCID Configuration
The ORCID section is used for integrating with the ORCID API for user identification and authentication.
The ORCID section can be used for integrating with the ORCID API for user identification and authentication.

- **ORCID_TOKEN_URL**: The URL for obtaining ORCID tokens.
- **ORCID_API_URL**: The ORCID API URL.
Expand Down Expand Up @@ -57,7 +61,6 @@ These settings cover the general configuration of the application environment.

- **NODE_ENV**: Specifies the environment (e.g., development, production).
- **DEPENDENCY_CONFIG**: Indicates which dependency configuration to use (`e2e`, `ess`, `stfc`, `test`). Defaults to the standard configuration if not provided.
- **PING_PUBLIC_CRT**: Public certificate for ping operations.
- **DATABASE_URL**: The URL for the database connection.
- **BASE_URL**: The base URL for the application.
- **JWT_TOKEN_LIFE**: The lifetime of JWT tokens.
Expand Down Expand Up @@ -90,4 +93,4 @@ The scheduler endpoint is used for managing scheduled tasks:
### Email Configuration
The email configuration includes a sink email address for testing purposes:

- **SINK_EMAIL**: The email address to receive sink emails.
- **SINK_EMAIL**: The email address to receive sink emails.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ If you add a new page, make sure to update the mkdocs.yml file:

1. Open `mkdocs.yml`.
2. Locate the `nav` section.
3. Add your new page under the appropriate section to ensure it appears in the site navigation.
3. Add your new page under the appropriate section to ensure it appears in the site navigation.
87 changes: 87 additions & 0 deletions documentation/docs/developer-guide/rabbitmq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
RabbitMQ is an open-source message broker that enables applications to communicate with each other asynchronously by sending and receiving messages. It is used within User Office to handle communication between different components of the system, particularly for routing messages related to proposal status actions.

This page provides an overview of how RabbitMQ is integrated into the project, including details on configuration, message handling, and frontend display.

## RabbitMQ in User Office Core

When the status of a proposal changes, a message is sent to specific RabbitMQ exchanges, which then route the message to the appropriate services or components for further processing.

Enable it in the [configuration](configuration.md).

## Configuration of RabbitMQ Exchanges

The RabbitMQ exchanges are configured using the `RabbitMQActionConfig` class. This class defines the exchanges to which messages will be sent when the status of a proposal changes.

@ObjectType()
export class RabbitMQActionConfig extends ProposalStatusActionConfigBase {
@Field(() => [String], { nullable: true })
exchanges?: string[] | null;
}

**Exchanges:** The exchanges property is an array of strings, each representing the name of a RabbitMQ exchange. These exchanges are where messages related to proposal status changes are sent.

## Backend Message Handling

The `rabbitMQActionHandler` function in the backend is responsible for sending messages to RabbitMQ exchanges based on the configuration defined in `RabbitMQActionConfig`.

export const rabbitMQActionHandler = async (
proposalStatusAction: ConnectionHasStatusAction,
proposals: WorkflowEngineProposalType[]
) => {
const config = proposalStatusAction.config as RabbitMQActionConfig;
if (!config.exchanges?.length) {
return;
}

const messageDescription =
'Proposal event successfully sent to the message broker';

return await Promise.all(
config.exchanges.map((exchange) =>
publishMessageToTheEventBus(proposals, messageDescription, exchange)
)
);
};

**Message Publishing:** This function takes in a `proposalStatusAction` and an array of proposals. It then publishes messages to each configured exchange by calling `publishMessageToTheEventBus`.

If no exchanges are configured, the function exits early without performing any actions.

## Frontend Display of RabbitMQ Exchanges

On the frontend, the `RabbitMQActionConfig` component is responsible for displaying the RabbitMQ exchanges where messages are sent. This provides users with information of how and where proposal data is routed.

type RabbitMQActionConfigProps = {
exchanges: RabbitMqActionConfigType['exchanges'];
};

const RabbitMQActionConfig = ({ exchanges }: RabbitMQActionConfigProps) => {
return (
<Typography variant="subtitle1" color="black">
Messages with <i>proposal data</i> are sent to the following RabbitMQ exchanges:{' '}
<ul style={{ margin: 0 }}>
{exchanges?.map((exchange, index) => (
<li key={index}>
<b>{exchange}</b>
</li>
))}
</ul>
</Typography>
);
};

export default RabbitMQActionConfig;

The component renders a list of RabbitMQ exchanges, showing which exchanges are being used to route messages related to proposal data.

## GraphQL Integration

The `RabbitMQActionConfig` class is integrated into the project’s GraphQL API, allowing for dynamic configuration and querying of RabbitMQ settings.

You can retrieve the RabbitMQ configuration using a GraphQL query:

query {
proposalStatusActionConfig {
exchanges
}
}
2 changes: 1 addition & 1 deletion documentation/docs/developer-guide/running_locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ Lints typescript code and log if there are any errors.

If you want to fix all auto-fixable errors and warnings use:

npm run lint:fix
npm run lint:
4 changes: 2 additions & 2 deletions documentation/docs/developer-guide/step-by-step.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Start by adding a new column `is_locked` to the database by creating a new file
DO
$$
BEGIN
IF register_patch('AlterUserAddIsLocked.sql', 'your_username', 'Add is_locked to the users table', '2024-08-08') THEN
IF register_patch('AlterUserAddIsLocked.sql', 'your_username', 'Add is_locked to the users table', '2024-08-08') THEN
BEGIN
ALTER TABLE users ADD COLUMN is_locked BOOL DEFAULT FALSE;
END;
END IF;
END IF;
END;
$$
LANGUAGE plpgsql;
Expand Down
Loading

0 comments on commit b0da1f0

Please sign in to comment.