Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring for az-functions #310

Merged
merged 2 commits into from
Sep 28, 2024
Merged

refactoring for az-functions #310

merged 2 commits into from
Sep 28, 2024

Conversation

mgupta83
Copy link
Contributor

@mgupta83 mgupta83 commented Sep 28, 2024

Summary by Sourcery

Refactor several components to use singleton patterns for instance management and update logging to a consistent custom-log format. Adjust import paths to align with the new directory structure and remove unused code from the ApolloServerRequestHandler.

Enhancements:

  • Refactor ApolloServerRequestHandler to use a singleton pattern for instance management.
  • Update logging across various modules to use a consistent custom-log format.
  • Refactor InfrastructureServicesBuilder to implement a singleton pattern for instance management.
  • Refactor PortalTokenValidation to use a singleton pattern for instance management.
  • Update import paths for various modules to reflect new directory structure.

Chores:

  • Remove unused health check logic from ApolloServerRequestHandler.

@mgupta83 mgupta83 requested a review from gidich as a code owner September 28, 2024 05:22
Copy link
Contributor

sourcery-ai bot commented Sep 28, 2024

Reviewer's Guide by Sourcery

This pull request implements a significant refactoring of the Azure Functions codebase, focusing on improving the structure, initialization process, and logging practices. The changes include the introduction of singleton patterns, centralized initialization, standardized logging, and various file relocations to enhance code organization.

Sequence Diagram

sequenceDiagram
    participant App as Function App
    participant PTV as PortalTokenValidation
    participant CDB as CosmosDbConnection
    participant ISB as InfrastructureServicesBuilder
    participant Domain as DomainImpl
    App->>PTV: initialize()
    App->>PTV: getInstance().Start()
    App->>CDB: getInstance()
    App->>CDB: connect()
    App->>ISB: initialize()
    App->>ISB: getInstance()
    App->>Domain: new DomainImpl()
    App->>Domain: startup()
Loading

File-Level Changes

Change Details Files
Implemented singleton pattern and centralized initialization
  • Added getInstance() and initialize() methods to several classes
  • Created a new initializeFunctionApp() function to centralize the initialization process
  • Modified constructors to be private in classes implementing the singleton pattern
data-access/src/functions/http-graphql/init/apollo-server-request-handler.ts
data-access/src/infrastructure-services-impl/infrastructure-services-builder.ts
data-access/seedwork/auth-seedwork-oidc/portal-token-validation.ts
data-access/src/functions/core/initialize-function-app.ts
Standardized logging format
  • Replaced console.log statements with a standardized 'custom-log' format
  • Updated logging messages to include more context and follow a consistent structure
data-access/src/functions/http-graphql/init/apollo-server-request-handler.ts
data-access/seedwork/services-seedwork-datastore-mongodb/connect.ts
data-access/seedwork/services-seedwork-datastore-mongodb/cosmos-db-connection.ts
data-access/src/functions/core/telemetry/tracer.ts
data-access/src/infrastructure-services-impl/blob-storage/az/impl.ts
data-access/src/infrastructure-services-impl/cognitive-search/az/impl.ts
data-access/src/infrastructure-services-impl/content-moderator/az/impl.ts
data-access/src/infrastructure-services-impl/datastore/mongodb/impl.ts
data-access/src/infrastructure-services-impl/vercel/api/impl.ts
data-access/seedwork/auth-seedwork-oidc/verified-token-service.ts
data-access/seedwork/event-bus-seedwork-node/node-event-bus.ts
data-access/src/app/domain/domain-impl.ts
Refactored file structure and import paths
  • Updated import statements to reflect new file locations
  • Moved files to more appropriate directories
  • Adjusted file paths in configuration files
data-access/src/functions/http-graphql/schema/builder/codegen.yml
data-access/src/functions/http-graphql/init/graphql-context-builder.ts
data-access/src/functions/http-graphql/schema/builder/resolver-builder.ts
data-access/src/functions/core/queue.context-builder.ts
data-access/src/functions/core/timer.context-builder.ts
data-access/src/functions/http-graphql/schema/types/member.resolvers.ts
data-access/src/functions/http-graphql/schema/builder/schema-builder.ts
data-access/src/functions/http-graphql/schema/types/community.resolvers.ts
data-access/src/functions/http-graphql/schema/types/role.resolvers.ts
data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts
data-access/src/functions/http-graphql/schema/types/service.resolvers.ts
data-access/src/functions/http-graphql/schema/types/staff-role.resolvers.ts
data-access/src/functions/timer-gl-daily-summary/gl-transaction.ts
data-access/src/app/external-dependencies/graphql-api.ts
Removed health check implementation in Apollo Server
  • Commented out the MongoDB connection check in the health check function
data-access/src/functions/http-graphql/init/apollo-server-request-handler.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @mgupta83 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider reviewing the extensive use of singletons. While appropriate for some global services, overuse can lead to tight coupling. Explore if dependency injection could be a better alternative in some cases.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mgupta83 mgupta83 merged commit 8aaf6bc into main Sep 28, 2024
7 checks passed
@mgupta83 mgupta83 deleted the mg-app-startup branch September 28, 2024 05:36
@mgupta83 mgupta83 linked an issue Sep 28, 2024 that may be closed by this pull request
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.

Refactor data-access for az functions v4
1 participant