TSultanov commented on code in PR #26026:
URL: https://github.com/apache/beam/pull/26026#discussion_r1183801086
##########
playground/backend/internal/db/datastore/datastore_db.go:
##########
@@ -63,19 +69,42 @@ func (d *Datastore) deleteObsoleteSnippets(ctx
context.Context, snipKey *datasto
Namespace(utils.GetNamespace(ctx)).
FilterField("persistenceKey", "=", persistenceKey)
- // At the moment, datastore emulator doesn't allow != filters,
- // hence this crutches
- //
https://cloud.google.com/datastore/docs/tools/datastore-emulator#known_issues
- // When it's fixed, post-query filter could be replaced with
- //
- // FilterField("__key__", "!=", snipKey)
+ // At the moment, datastore emulator doesn't allow != filters,
+ // hence this crutches
+ //
https://cloud.google.com/datastore/docs/tools/datastore-emulator#known_issues
+ // When it's fixed, post-query filter could be replaced with
+ //
+ // FilterField("__key__", "!=", snipKey)
return d.deleteSnippets(ctx, snippetQuery, snipKey)
}
-// PutSnippet puts the snippet entity to datastore
+// PutSnippet puts the snippet entity to datastore using cloud function proxy
func (d *Datastore) PutSnippet(ctx context.Context, snipId string, snip
*entity.Snippet) error {
logger.Debugf("putting snippet %q, persistent key %q...", snipId,
snip.Snippet.PersistenceKey)
+
+ var err error
+ if d.externalFunctions != nil {
+ err = d.externalFunctions.PutSnippet(ctx, snipId, snip)
+ }
+ if err != nil || d.externalFunctions == nil {
+ if err != nil {
+ logger.Errorf("Datastore: PutSnippet(): error during
the PutSnippet() call to the cloud function, "+
+ "accessing the datastore directly, err: %s\n",
err.Error())
+ }
+ if d.externalFunctions == nil {
+ logger.Warnf("Datastore: PutSnippet(): external
functions are not set, " +
+ "accessing the datastore directly")
+ }
+ return d.PutSnippetDirect(ctx, snipId, snip)
Review Comment:
The fallback is useful for local development as with it the application will
work with datastore emulator regardless of whether functions runtime was also
started or not.
In the GKE deployment the fallback will fail as there are no permissions to
write to the datastore.
Removing the fallback will also complicate ToB integration tests, though
having them use the emulated cloud function will probably make them more true
to life
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]