alexeyinkin commented on code in PR #25610: URL: https://github.com/apache/beam/pull/25610#discussion_r1126138344
########## playground/frontend/playground_components/lib/src/controllers/build_metadata.dart: ########## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:get_it/get_it.dart'; + +import '../api/v1/api.pbgrpc.dart' show GetMetadataResponse; +import '../models/component_version.dart'; +import '../models/sdk.dart'; +import '../repositories/code_repository.dart'; +import '../repositories/example_repository.dart'; +import '../repositories/get_metadata_response_grpc_extension.dart'; + +/// Obtains versions from the backend. +class BuildMetadataController extends ChangeNotifier { + ComponentVersion? _routerVersion; + Future<GetMetadataResponse>? _routerVersionFuture; + + final _runnerVersions = <Sdk, ComponentVersion>{}; + final _runnerVersionFutures = <Sdk, Future<GetMetadataResponse>>{}; + + /// Returns the router version and starts loading if it is not started yet. + ComponentVersion? get routerVersion { Review Comment: `+` ########## playground/frontend/playground_components/lib/src/repositories/backend_urls.dart: ########## @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: avoid_print + +import '../../playground_components.dart'; +import '../constants/backend_urls.dart'; + +const _routerNode = 'router'; + +Future<Uri> getRouterUrl() => _getBackendUrl(_routerNode); +Future<Uri> getRunnerUrl(Sdk sdk) => _getBackendUrl(sdk.id); + +/// Returns options for backend URLs for [node]. +/// +/// If an override is given in [backendUrlOverrides], it is the only option. +/// This can be used for development if the production backend +/// must not be used. +/// +/// Otherwise there are 2 options in the following order: +/// 1. [node] is prepended to the host of the current URL. +/// 2. [node] is inserted into [defaultBackendUrlTemplate] (the production URL). +/// If the two are the same, only one is returned. +/// This results in the following when looking up "node": +/// +/// For production Playground: +/// - node.play.beam.apache.org (the production URL). +/// +/// For production Tour of Beam: +/// - node.play.beam.apache.org (as node.tour.beam.apache.org is blacklisted +/// via [skipBackendUrls]). +/// +/// For any other stage of Playground or Tour of Beam (my-stage.com): +/// - node.my-stage.com +/// - node.play.beam.apache.org +/// This means that if the stage runs its own container for the given +/// backend node, it is used. Otherwise the production backend is used. +List<Uri> _getBackendUrlOptions(String node) { Review Comment: `+` -- 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]
