GithubHelp home page GithubHelp logo

googleapis / google-cloud-java Goto Github PK

View Code? Open in Web Editor NEW
1.8K 178.0 1.0K 888.51 MB

Google Cloud Client Library for Java

Home Page: https://cloud.google.com/java/docs/reference

License: Apache License 2.0

Java 99.97% Shell 0.01% HCL 0.01% Python 0.02% Jinja 0.01%
java cloud-bigquery cloud-storage cloud-datastore google-cloud artisanal gcp

google-cloud-java's Introduction

Google APIs

This repository contains the original interface definitions of public Google APIs that support both REST and gRPC protocols. Reading the original interface definitions can provide a better understanding of Google APIs and help you to utilize them more efficiently. You can also use these definitions with open source tools to generate client libraries, documentation, and other artifacts.

Building

Bazel

The recommended way to build the API client libraries is through Bazel >= 4.2.2.

First, install bazel.

To build all libraries:

bazel build //...

To test all libraries:

bazel test //...

To build one library in all languages:

bazel build //google/example/library/v1/...

To build the Java package for one library:

bazel build //google/example/library/v1:google-cloud-example-library-v1-java

Bazel packages exist in all the libraries for Java, Go, Python, Ruby, Node.js, PHP and C#.

Overview

Google APIs are typically deployed as API services that are hosted under different DNS names. One API service may implement multiple APIs and multiple versions of the same API.

Google APIs use Protocol Buffers version 3 (proto3) as their Interface Definition Language (IDL) to define the API interface and the structure of the payload messages. The same interface definition is used for both REST and RPC versions of the API, which can be accessed over different wire protocols.

There are several ways of accessing Google APIs:

  1. JSON over HTTP: You can access all Google APIs directly using JSON over HTTP, using Google API client library or third-party API client libraries.

  2. Protocol Buffers over gRPC: You can access Google APIs published in this repository through GRPC, which is a high-performance binary RPC protocol over HTTP/2. It offers many useful features, including request/response multiplex and full-duplex streaming.

  3. Google Cloud Client Libraries: You can use these libraries to access Google Cloud APIs. They are based on gRPC for better performance and provide idiomatic client surface for better developer experience.

Discussions

This repo contains copies of Google API definitions and related files. For discussions or to raise issues about Google API client libraries, GRPC or Google Cloud Client Libraries please refer to the repos associated with each area.

Repository Structure

This repository uses a directory hierarchy that reflects the Google API product structure. In general, every API has its own root directory, and each major version of the API has its own subdirectory. The proto package names exactly match the directory: this makes it easy to locate the proto definitions and ensures that the generated client libraries have idiomatic namespaces in most programming languages. Alongside the API directories live the configuration files for the GAPIC toolkit.

NOTE: The major version of an API is used to indicate breaking change to the API.

Generate gRPC Source Code

To generate gRPC source code for Google APIs in this repository, you first need to install both Protocol Buffers and gRPC on your local machine, then you can run make LANGUAGE=xxx all to generate the source code. You need to integrate the generated source code into your application build system.

NOTE: The Makefile is only intended to generate source code for the entire repository. It is not for generating linkable client library for a specific API. Please see other repositories under https://github.com/googleapis for generating linkable client libraries.

Go gRPC Source Code

It is difficult to generate Go gRPC source code from this repository, since Go has different directory structure. Please use this repository instead.

google-cloud-java's People

Contributors

andreamlin avatar aozarov avatar athakor avatar chingor13 avatar dependabot[bot] avatar eaball35 avatar garrettjonesgoogle avatar gcf-owl-bot[bot] avatar google-cloud-policy-bot[bot] avatar jesselovelace avatar justinbeckwith avatar kolea2 avatar lqiu96 avatar mpeddada1 avatar munkhuushmgl avatar mziccard avatar neenu1995 avatar neozwu avatar nnegrey avatar pongad avatar release-please[bot] avatar renovate-bot avatar shinfan avatar stephaniewang526 avatar surferjeffatgoogle avatar suztomo avatar vam-google avatar yihanzhen avatar yoshi-automation avatar yoshi-code-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-cloud-java's Issues

Make authentication simpler

What we do today:

final KeyStore keystore = KeyStore.getInstance("PKCS12");
final FileInputStream fis = new FileInputStream("/path/to/key.p12");
keystore.load(fis, "password".toCharArray());
final PrivateKey key = (PrivateKey) keystore.getKey("privatekey", "password".toCharArray());

final AuthConfig ac = AuthConfig.createFor("[email protected]", key);

final DatastoreServiceOptions options = DatastoreServiceOptions.builder()
    .dataset(datasetId)
    .authConfig(ac)
    .build();

final DatastoreService datastore = DatastoreServiceFactory.getDefault(options);

What we'd like to do:

final Credential credential = DatastoreHelper.getServiceAccountCredential(
    "[email protected]", "/path/to/key.p12");
final DatastoreOptions options = DatastoreHelper.getOptionsfromEnv()
  .dataset(datasetId)
  .credential(credential)
  .build();
final Datastore datastore = DatastoreFactory.get().create(options);

Should Blobs and Buckets be stateless or keep a reference to a StorageService ?

Right now, it looks like our Blob and Bucket objects are stateless, in that they don't keep a reference to a StorageService object. What this means is, given we have the following:

StorageService storage = ... // Get a storage service (irrelevant how here)
Bucket bucket = storage.get("bucket-name");
Blob blob = storage.get("bucket-name", "blobname");

The only way to interact with these objects is by keeping a reference to the StorageService:

BlobReadChannel channel = storage.reader("bucket", "blob");
// or 
BlobReadChannel channel = storage.reader(blob); // I think?

There's no way to do:

BlobReadChannel channel = blob.getReadChannel(); // Or anything like this.

The purpose of this issue is to discuss whether or not these objects should hold a reference to the StorageService which would make things like blob.getReadChannel() or blob.delete() possible rather than always calling storage.getReadChannel(blob) and storage.delete(blob).

The benefits of this are friendlier-looking code (IMO at least....). The downsides are (I think) serialization becomes a bit more confusing, and what does it mean to send one "StorageService-aware" Blob into another StorageService method, ie:

StorageService storageA = ... // Authenticated with read permissions only.
StorageService storageB = ... // Authenticated with read *and* write permissions.
Blob blobA = storageA.get("bucket-name", "blob");
blobA.delete(); // This should fail: blobA is tied to storageA, which has read-only permissions.
storageB.delete(blobA); // Should this "override" the `StorageService`?

I have no idea what the right answer is, but wanted to open the floor for discussion.

/cc @aozarov @jboynes

Testing PubsubService

I would like to contribute to this project by helping out on the Pubsub feature. I forked the repo and implemented a PubsubRpc client. I will now move on to create a PubsubService and Examples with documentation. But, I have a question with testing:

To unit test I can make a mock PubsubRpc client that simulates response json from the rest api, however, I was thinking a better way could be to have a Pubsub emulation available as a local development environment like the Datastore local dev server. I know as a user of GCP that would make my life much easier for testing things out. So not only do we get a good unit testing mechanism, but it will be a valuable tool for developers in general. What are your thoughts on this functionality, and if I decide to add this local dev pubsub environment, do you think it belongs in gcloud-java or somewhere else?

datastore.Datetime.now seems broken

When running this method locally (on a Mac) it returns 14th of January 1970 (1970-01-14T10:49:17.451+01:00)

I suspect that the problem is that it is implemented as:

public static DateTime now() {
  return new DateTime(System.nanoTime() / 1000L);  // nanoTime() may be the culprit?
}

ReadMe file as a snippet of code that is incomplete

It would be great to get a working snippet in the readme page(without looking at the javadoc first):
1/ a static method after the imports?
2/ some real content for the "..." section (or some comments in the snippet to describe what would be the value for "..."

Entity.builder().set(String, long) doesn't exist?

I have the following code:

entity = Entity.builder(key)
  .set("name", "John Doe")
  .set("age", 30L) // I also tried 30 the int value, which failed similarly.
  .set("updated", false)
  .build();

This fails with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hello-datastore: Compilation failure: Compilation failure:
[ERROR] /usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:[18,58] error: incompatible types
[ERROR] 
[ERROR] could not parse error message:   required: KeyFactory
[ERROR] found:    Builder
[ERROR] /usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:29: error: no suitable method found for set(String,long)
[ERROR] .set("age", 30L)
[ERROR] ^
[ERROR] 
[ERROR] method Builder.set(String,Blob) is not applicable
[ERROR] (actual argument long cannot be converted to Blob by method invocation conversion)
[ERROR] method Builder.set(String,List) is not applicable
[ERROR] (actual argument long cannot be converted to List by method invocation conversion)
[ERROR] method Builder.set(String,FullEntity) is not applicable
[ERROR] (actual argument long cannot be converted to FullEntity by method invocation conversion)
[ERROR] method Builder.set(String,Key) is not applicable
[ERROR] (actual argument long cannot be converted to Key by method invocation conversion)
[ERROR] method Builder.set(String,DateTime) is not applicable
[ERROR] (actual argument long cannot be converted to DateTime by method invocation conversion)
[ERROR] method Builder.set(String,boolean) is not applicable
[ERROR] (actual argument long cannot be converted to boolean by method invocation conversion)
[ERROR] method Builder.set(String,String) is not applicable
[ERROR] (actual argument long cannot be converted to String by method invocation conversion)
[ERROR] method Builder.set(String,Value) is not applicable
[ERROR] (actual argument long cannot be converted to Value by method invocation conversion)
[ERROR] /usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:[32,15] error: cannot find symbol
[ERROR] 

If I take away the .set("name", "John Doe") I get a different error...

Configure Travis to automatically push new tags to Maven

Logic here is that we wouldn't want Maven lagging behind the GH repository.

I don't know if it's standard to have a nightly (or master) type build available on Maven (other libraries like gcloud-node don't do that), but at the very least all git tagged versions should be automatically pushed to Maven...

/cc @jboynes

Provide a .buildStorageService() method on the StorageServiceOptions class?

Right now, to create a StorageService object, I need to do:

StorageServiceOptions options =  StorageServiceOptions.builder()
    .projectId("project")
    .build();
StorageService storage = StorageServiceFactory.instance().get(options);

Would it be worthwhile to do this as

StorageService storage =  StorageServiceOptions.builder()
    .projectId("project")
    .build().buildStorageService();

Or maybe we can have a StorageServiceBuilder?

StorageService storage = StorageService.builder()
    .projectId("project")
    .build();

Is StorageService.load the right name?

Right now, to load a Blob into a byte array, we use the load method:

StorageService storage = ...;
bytes[] bytes = storage.load("bucket-name", "blob-name");

Is load the right verb for this? (Not saying it's wrong, just want to discuss this one here.)

Some of the options:

  • load (This is what it is today)
  • download
  • read
  • getBytes
  • readBytes

KeyFactory.kind() requires a cast... didn't expect that at all...

Code I had was:

KeyFactory keyFactory = datastore.newKeyFactory().kind("Person");

Error I was getting was:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hello-datastore: Compilation failure
[ERROR] /usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:[19,58] error: incompatible types
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hello-datastore: Compilation failure
/usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:[19,58] error: incompatible types


        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
/usr/local/google/home/jjg/gcdjavasample/hello-datastore/src/main/java/org/geewax/hellodatastore/HelloDatastore.java:[19,58] error: incompatible types


        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Changing this to

KeyFactory keyFactory = (KeyFactory) datastore.newKeyFactory().kind("Person");

fixed the problem

However the docs at http://googlecloudplatform.github.io/gcloud-java/apidocs/com/google/gcloud/datastore/package-summary.html say I shouldn't need to do this :(

mvn install fails with "secret key not available" ?

What I did:

$ sudo apt-get install mvn2
$ git clone https://github.com/GoogleCloudPlatform/gcloud-java.git
$ cd gcloud-java
$ mvn install

Error I got:

[INFO] Building jar: /usr/local/google/home/jjg/gcdjavasample/gcloud-java/target/gcloud-java-0.0.3-javadoc.jar
[INFO] [failsafe:integration-test {execution: default}]
[INFO] [failsafe:verify {execution: default}]
[INFO] Failsafe report directory: /usr/local/google/home/jjg/gcdjavasample/gcloud-java/target/failsafe-reports
[INFO] [gpg:sign {execution: sign-artifacts}]
gpg: no default secret key: secret key not available
gpg: signing failed: secret key not available
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Exit code: 2
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Exit code: 2
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exit code: 2
    at org.apache.maven.plugin.gpg.GpgSigner.generateSignatureForFile(GpgSigner.java:168)
    at org.apache.maven.plugin.gpg.AbstractGpgSigner.generateSignatureForArtifact(AbstractGpgSigner.java:205)
    at org.apache.maven.plugin.gpg.GpgSignAttachedMojo.execute(GpgSignAttachedMojo.java:140)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39 seconds
[INFO] Finished at: Thu Mar 19 11:10:53 EDT 2015
[INFO] Final Memory: 75M/1366M
[INFO] ------------------------------------------------------------------------

Did we misname Blob as it is really holding the Blob's metadata (name, etc)?

Right now, Blob's are not actually the objects themselves but pointers and metadata about the blob... That being the case, should we re-evaluate the naming of the Blob class?

Some of the options:

  • Blob (This is what it is today)
  • Object
  • StorageObject
  • ObjectMetadata
  • BlobMetadata
  • StorageObjectMetadata
  • BlobInfo

What's the best way for a total n00b to start with this library?

I'm having trouble getting a HelloDatastore project working. Hoping that you can help me get this going...

Here's what I did:

$ git clone https://github.com/GoogleCloudPlatform/gcloud-java.git
$ cd gcloud-java
$ sudo apt-get install maven
$ mvn install
$ export CLASSPATH=~/gcdjavasample/gcloud-java/target/gcloud-java-0.0.3.jar

Here's the file I'm trying to run (HelloDatastore.java):

import com.google.gcloud.datastore.DatastoreService;
import com.google.gcloud.datastore.DatastoreServiceFactory;
import com.google.gcloud.datastore.DatastoreServiceOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;



public class HelloDatastore {
  private static final String DATASET = "gcloud-datastore-demo";

  public static void main(String[] args) {
    DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset(DATASET).build();
    DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
    KeyFactory keyFactory = datastore.newKeyFactory().kind("Person");
    Key key = keyFactory.newKey("Jimmy");

    System.out.println("Trying to get the entity by its key!");

    Entity entity = datastore.get(key);

    if (entity == null) {
      System.out.println("Entity not found! Creating it!");
      entity = Entity.builder(key)
          .set("name", "John Doe")
          .set("age", 30)
          .set("updated", false)
          .build();
      datastore.put(entity);
    } else {
      System.out.println("Entity found! Updating it!");
      boolean updated = entity.getBoolean("updated");
      if (!updated) {
        String[] name = entity.getString("name").split(" ");
        entity = Entity.builder(entity)
            .set("name", name[0])
            .set("last_name", name[1])
            .set("updated", true)
            .remove("old_property")
            .set("new_property", 1.1)
            .build();
        datastore.update(entity);
      }
    }

    System.out.println("Done!");
  }
}

I can get it to compile just fine, then I run into problems running the class. Apparently I need Guava? And google-auth-library-java ? And google-api-java-client ?

What exactly is the best way to get this so that I can run... java HelloDatastore and I'll see some stuff happening.... ?

(Sorry for the dumb question....)

Should we use jarjar to repackage specific dependency versions

I did a simple java main Maven project.
I see many dependencies in my project jars, for example guava 18, httpclient401,jodatime27 etc...
If I wand to use for my other application logic guava 12 or 25 for whatever reasons, we will have a version conflict...
JarJar processing? How is it done for other runtimes? Seems to be a generic Veneer issue.

Remove binary blobs from history?

The repo is currently 274MB when cloned, and just the src tree (i.e., excluding past versions in .git) is 85MB โ€” the actual code takes up negligible space, and the vast majority of that space is taken up by src/test/resources/gcd-head.zip.

This makes it take an unusually large amount of time to clone the repo, and it will likely grow every time this blob is updated to a new version.

Would it be possible to not version these large files (and ideally remove them from history while there are few forks), and get them from Maven or other sources, pinned to a specific version?

Use try-with-resources for Transactions

It would be nice to be able to use the resource pattern around a Transaction:

try (Transaction tx = datastore.newTransaction()) {
  // do stuff
  tx.commit();
}

Default behaviour of close() would be to roll back a transaction. This is to avoid potential errors caused by the application failing to catch unexpected Throwables causing incomplete work to be auto-committed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.