TSultanov commented on code in PR #26026:
URL: https://github.com/apache/beam/pull/26026#discussion_r1183803809
##########
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)
+ }
+
+ return nil
+}
+
+// PutSnippetDirect puts the snippet entity to datastore
+func (d *Datastore) PutSnippetDirect(ctx context.Context, snipId string, snip
*entity.Snippet) error {
Review Comment:
It's called from
[here](https://github.com/akvelon/beam/blob/7f3c273183f0f12010bac2268047b014efcc708a/playground/backend/functions.go#L97)
--
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]