googleapis / googleapis/google-cloud-java

[sdk-platform-java] Update the generated samples to reflect client lifecycle best practices

Ouverte
#12,376 3 commentaires 0 réactions 1 personne assignée Réclamée par @lqiu96 Voir sur GitHub
priority: p3 samples type: docs
Langage dominant
Java
Étoiles
2.1k
Forks
1.2k
Merge moyen
1 j 23 h
PR mergées (30 j)
154

Description

The generated samples in each GAPIC client library show use cases of try-with resources. Example: https://github.com/googleapis/google-cloud-java/blob/7346a852311cdcb958ef57066eaab8679f02a64c/java-admanager/ad-manager/src/main/java/com/google/ads/admanager/v1/NetworkServiceClient.java#L325

While this is a good example as a sample to show how a client is created and closed without incurring memory leaks, it may provide our users with an incorrect idea of how to create clients. We expect client libraries to be long-lived and not to be re-created/ closed repeatedly.

We should update the samples with a few options:
1. Samples are updated to not use try-with-resources
2. Samples have wording to describe that they are for example purposed and link to the official docs
3. ... Other options?

High Level Changes:
The samples from the GAPIC clients are generated from the generator. Based on the option we choose, we'll have to update the generator accordingly.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.