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

Best Practices for Using Generated gRPC Dart Code as a Dependency #58

Open
Ja7ad opened this issue Jan 11, 2025 · 4 comments
Open

Best Practices for Using Generated gRPC Dart Code as a Dependency #58

Ja7ad opened this issue Jan 11, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@Ja7ad
Copy link

Ja7ad commented Jan 11, 2025

We have generated gRPC Dart code in the repository under the following path:

https://github.com/pactus-project/pactus/tree/main/www/grpc/gen/dart

www/grpc/gen/dart

To ensure proper usage and integration of this generated code in other projects, here are the recommended best practices:


1. Referencing the Generated Code

To use the generated code in your Dart/Flutter project, add it to the pubspec.yaml file as a Git dependency:

dependencies:
  pactus_grpc:
    git:
      url: https://github.com/pactus-project/pactus.git
      path: www/grpc/gen/dart
      ref: <version-tag>
  • Replace <version-tag> with the specific tag or branch name you want to use (e.g., v1.0.0).
  • Use semantic versioning for tags to ensure consistent and predictable updates.

2. Keep the Generated Code Updated

Ensure the generated gRPC Dart code is always updated in the repository whenever .proto files are modified. This ensures compatibility and consistency across projects using this package.


3. Versioning Recommendations

  • Use meaningful and stable version tags (vX.Y.Z) to reference the gRPC code.
  • Avoid referencing the main branch unless explicitly required, as it might include unstable changes.

4. Importing the Package

After adding the dependency, import the generated files into your Dart/Flutter project:

import 'package:pactus_grpc/<generated_file>.dart';

Replace <generated_file> with the appropriate file name based on your usage.


5. Managing Updates

If there are updates to the tag or generated code:

  • Update the ref in your pubspec.yaml.
  • Run the following commands to refresh dependencies:
flutter pub get
flutter pub cache repair

6. Testing Integration

After integrating the package into your Flutter project:

  • Test the package thoroughly to ensure proper gRPC communication with the backend.
  • Report any issues with the generated code or integration steps.
@Ja7ad Ja7ad added the enhancement New feature or request label Jan 11, 2025
@Ja7ad
Copy link
Author

Ja7ad commented Jan 11, 2025

@esmaeil-ahmadipour
Copy link
Collaborator

esmaeil-ahmadipour commented Jan 11, 2025

Javad, we will make sure to implement these tasks in separate issues.

1-Review Existing gRPC Documentation
2-Add Security Guidelines for gRPC Integration
3-Create Practical gRPC Example
4-Integrate gRPC Code Generation into CI/CD Pipeline
5-Write Debugging Guide for gRPC Issues
6-Align All Updates with Existing Documentatioد

While we are able to search and find the documentation link ourselves, we kindly request that you provide us with the link.


@Ja7ad

@Ja7ad
Copy link
Author

Ja7ad commented Jan 11, 2025

Javad, we will make sure to implement these tasks in separate issues.

1-Review Existing gRPC Documentation 2-Add Security Guidelines for gRPC Integration 3-Create Practical gRPC Example 4-Integrate gRPC Code Generation into CI/CD Pipeline 5-Write Debugging Guide for gRPC Issues 6-Align All Updates with Existing Documentatioد

While we are able to search and find the documentation link ourselves, we kindly request that you provide us with the link.

@Ja7ad

I think don't need to generate gRPC proto again via pipeline, you can use this practice.

@esmaeil-ahmadipour
Copy link
Collaborator

@Ja7ad , we talk about it in the GUI team to make it easier and better.

@esmaeil-ahmadipour esmaeil-ahmadipour closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants