Abacn commented on a change in pull request #17173:
URL: https://github.com/apache/beam/pull/17173#discussion_r837834112
##########
File path: sdks/go/pkg/beam/io/datastoreio/datastore.go
##########
@@ -55,20 +64,25 @@ func init() {
// datastoreio.Read(s, "project", "Item", 256, reflect.TypeOf(Item{}), itemKey)
func Read(s beam.Scope, project, kind string, shards int, t reflect.Type,
typeKey string) beam.PCollection {
s = s.Scope("datastore.Read")
- return query(s, project, kind, shards, t, typeKey)
+ return query(s, project, kind, shards, t, typeKey, datastoreNewClient)
}
-func query(s beam.Scope, project, kind string, shards int, t reflect.Type,
typeKey string) beam.PCollection {
+func datastoreNewClient(ctx context.Context, projectID string, opts
...option.ClientOption) (clientType, error) {
+ return datastore.NewClient(ctx, projectID, opts...)
+}
+
+func query(s beam.Scope, project, kind string, shards int, t reflect.Type,
typeKey string, newClient newClientFuncType) beam.PCollection {
imp := beam.Impulse(s)
- ex := beam.ParDo(s, &splitQueryFn{Project: project, Kind: kind, Shards:
shards}, imp)
+ ex := beam.ParDo(s, &splitQueryFn{Project: project, Kind: kind, Shards:
shards, newClientFunc: newClient}, imp)
g := beam.GroupByKey(s, ex)
- return beam.ParDo(s, &queryFn{Project: project, Kind: kind, Type:
typeKey}, g, beam.TypeDefinition{Var: beam.XType, T: t})
+ return beam.ParDo(s, &queryFn{Project: project, Kind: kind, Type:
typeKey, newClientFunc: newClient}, g, beam.TypeDefinition{Var: beam.XType, T:
t})
}
type splitQueryFn struct {
- Project string `json:"project"`
- Kind string `json:"kind"`
- Shards int `json:"shards"`
+ Project string `json:"project"`
+ Kind string `json:"kind"`
+ Shards int `json:"shards"`
+ newClientFunc newClientFuncType
Review comment:
Thanks! Comments addressed.
--
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]