Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Add retry conig for gcp-datastore #2636

Open
@NorthernDarkness

Description

@NorthernDarkness

GCP native java client allows to configure retries, but there is no way to do so if spring-data-datastore is used.

The native client is instantiated in a private method, so no way to change this. If a user defined Datastore bean with configured retries is exposed, this will not work because of namespaces. It is not possible to have both NamespaceProvider and Datastore at the same time. To add a custom datastore client, the entire namespace related instantiation logic have to be copied on user side. Suggestion is to add RestryConfigurationProperties read config from it and configure in getDatastore() method:

` private Datastore getDatastore(String namespace) {
DatastoreOptions.Builder builder = DatastoreOptions.newBuilder()
.setProjectId(this.projectId)
.setRetrySettings(getRetrySettings())//the magic happens here
.setHeaderProvider(new UserAgentHeaderProvider(this.getClass()))
.setCredentials(this.credentials);
if (namespace != null) {
builder.setNamespace(namespace);
}

	if (this.host != null) {
		builder.setHost(this.host);
	}
	return builder.build().getService();
}`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions