Skip to content

Comments

prepare PR 1#1

Open
devslovecoffee wants to merge 1 commit intomainfrom
pr-1
Open

prepare PR 1#1
devslovecoffee wants to merge 1 commit intomainfrom
pr-1

Conversation

@devslovecoffee
Copy link
Collaborator

@devslovecoffee devslovecoffee commented Aug 1, 2024

Description by Cal

PR Description

This PR introduces new fields and configurations related to caching and storage, including updates to entity caching configurations and the addition of Redis support.

Diagrams of code changes
sequenceDiagram
    participant User
    participant System
    participant EntityCachingConfig
    participant RedisConfig

    User->>System: Request to enable entity caching
    System->>EntityCachingConfig: Set enabled to true
    EntityCachingConfig->>System: Return updated config
    System->>RedisConfig: Configure Redis settings
    RedisConfig->>System: Return Redis config
    System->>User: Response with caching enabled

Loading

Key Issues

None

Files Changed

File: /engine/crates/engine-config-builder/src/from_sdl_config.rs Updated pattern matching in `EntityCachingConfig::Enabled` to include `storage` field.
File: /engine/crates/engine/response/src/lib.rs Added `used_fields` field with default value in `GraphqlOperationAnalyticsAttributes` struct.
File: /engine/crates/parser-sdl/src/federation.rs Added `EntityCacheStorage` enum and implemented conversion functions for Redis configurations.
File: /engine/crates/parser-sdl/src/rules/subgraph_directive.rs Refactored setting `entity_caching` in `SubgraphDirectiveVisitor` to use pattern matching.
File: /engine/crates/runtime-local/src/lib.rs Added conditional compilation for `redis` module.
File: /gateway/crates/config/src/entity_caching.rs Added `storage` and `redis` fields with configurations in `EntityCachingConfig` struct.
# Description

Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.

Type of change

  • 💔 Breaking
  • 🚀 Feature
  • 🐛 Fix
  • 🛠️ Tooling
  • 🔨 Refactoring
  • 🧪 Test
  • 📦 Dependency
  • 📖 Requires documentation update

Copy link
Collaborator Author

@devslovecoffee devslovecoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.

Copy link
Collaborator Author

@devslovecoffee devslovecoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.

Copy link
Collaborator Author

@devslovecoffee devslovecoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.

#[serde(deny_unknown_fields)]
pub struct EntityCachingRedisConfig {
#[serde(default = "EntityCachingRedisConfig::default_url")]
pub url: url::Url,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion
Consider adding validation logic in the EntityCachingRedisConfig struct to ensure that the url is a valid Redis URL when deserializing, which can prevent runtime errors.

entity_caching: entity_caching.as_ref().map(|config| match config {
EntityCachingConfig::Disabled => EntityCaching::Disabled,
EntityCachingConfig::Enabled { ttl } => EntityCaching::Enabled { ttl: *ttl },
EntityCachingConfig::Enabled { ttl, .. } => EntityCaching::Enabled { ttl: *ttl },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion
Ensure that the handling of additional fields in the pattern matching is consistent across all usages to avoid potential bugs.


#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct EntityCachingRedisConfig {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion
Consider adding a method to EntityCachingRedisConfig to validate the configuration, ensuring that the url is correctly formatted and the key_prefix is not empty, which can prevent runtime errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant