robertwb commented on code in PR #33705:
URL: https://github.com/apache/beam/pull/33705#discussion_r1924473063


##########
sdks/go/pkg/beam/runners/prism/internal/environments.go:
##########
@@ -46,16 +47,26 @@ import (
 
 func runEnvironment(ctx context.Context, j *jobservices.Job, env string, wk 
*worker.W) error {
        logger := j.Logger.With(slog.String("envID", wk.Env))
-       // TODO fix broken abstraction.
-       // We're starting a worker pool here, because that's the loopback 
environment.

Review Comment:
   Was this TODO just obsolete? (I'm not seeing a pool started below, changed 
or not.)



##########
sdks/go/pkg/beam/runners/prism/internal/environments.go:
##########
@@ -83,6 +96,33 @@ func runEnvironment(ctx context.Context, j *jobservices.Job, 
env string, wk *wor
        }
 }
 
+func selectAnyOfEnv(ap *pipepb.AnyOfEnvironmentPayload) *pipepb.Environment {
+       // Prefer external, then process, then docker, unknown environments are 
0.
+       ranks := map[string]int{

Review Comment:
   This doesn't handle nested AnyOf. Do we care?



##########
sdks/go/pkg/beam/runners/prism/internal/environments.go:
##########
@@ -83,6 +96,33 @@ func runEnvironment(ctx context.Context, j *jobservices.Job, 
env string, wk *wor
        }
 }
 
+func selectAnyOfEnv(ap *pipepb.AnyOfEnvironmentPayload) *pipepb.Environment {
+       // Prefer external, then process, then docker, unknown environments are 
0.
+       ranks := map[string]int{
+               urns.EnvDocker:   1,
+               urns.EnvProcess:  5,
+               urns.EnvExternal: 10,
+       }
+
+       envs := ap.GetEnvironments()
+
+       slices.SortStableFunc(envs, func(a, b *pipepb.Environment) int {
+               rankA := ranks[a.GetUrn()]
+               rankB := ranks[b.GetUrn()]
+
+               // Reverse the comparison so our favourite is at the front

Review Comment:
   Alternatively we could give the ranks golf-style scoring, or pick the last 
one in the list below. If this is the most idiomatic I'm fine with that. 



-- 
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]

Reply via email to