Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/appengine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.13.11

* Update dependency on `googleapis_auth` and `http`.

## 0.13.10

* Upgrade `package:grpc` to `^4.0.1`.
Expand Down
10 changes: 9 additions & 1 deletion pkgs/appengine/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
include: package:lints/core.yaml
include: package:lints/recommended.yaml

analyzer:
errors:
# TODO: We need to update the grpc generator to escape html entities in
# proto comments.
unintended_html_in_doc_comment: ignore
# proto files import these
implementation_imports: ignore
# Breaking change to fix
constant_identifier_names: ignore

exclude:
- tmp/**

linter:
rules:
- unnecessary_library_directive
8 changes: 3 additions & 5 deletions pkgs/appengine/lib/appengine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine;

import 'dart:async';
import 'dart:io';

Expand Down Expand Up @@ -57,11 +55,11 @@ const Symbol _APPENGINE_CONTEXT = #appengine.context;
/// The returned `Future` will complete when the HTTP server has been shutdown
/// and is no longer serving requests.
Future runAppEngine(
void handler(HttpRequest request), {
void Function(HttpRequest request) handler, {
Function? onError,
int port = 8080,
bool shared = false,
void onAcceptingConnections(InternetAddress address, int port)?,
void Function(InternetAddress address, int port)? onAcceptingConnections,
}) {
void Function(Object, StackTrace)? errorHandler;
if (onError != null) {
Expand Down Expand Up @@ -147,7 +145,7 @@ bool isCronJobRequest(HttpRequest request) {
/// ]);
/// });
/// }
Future withAppEngineServices(Future callback()) {
Future withAppEngineServices(Future Function() callback) {
return appengine_internal.withAppEngineServices(callback);
}

Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/api_impl/stderr_logging_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library stderr_logging;

import 'dart:async';
import 'dart:io' as io;
Expand Down
2 changes: 0 additions & 2 deletions pkgs/appengine/lib/src/appengine_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.appengine_context;

class AppEngineContext {
final String applicationID;
final String partition;
Expand Down
23 changes: 11 additions & 12 deletions pkgs/appengine/lib/src/appengine_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.internal;

import 'dart:async';
import 'dart:io';
Expand Down Expand Up @@ -33,7 +32,7 @@ bool _loggingPackageEnabled = false;

/// Runs the given [callback] inside a new service scope and makes AppEngine
/// services available within that scope.
Future withAppEngineServices(Future callback()) =>
Future withAppEngineServices(Future Function() callback) =>
_withAppEngineServicesInternal((_) => callback());

/// Runs the AppEngine http server and uses the given request [handler] to
Expand All @@ -42,11 +41,11 @@ Future withAppEngineServices(Future callback()) =>
/// The given request [handler] is run inside a new service scope and has all
/// AppEngine services available within that scope.
Future runAppEngine(
void handler(HttpRequest request, ClientContext context),
void onError(Object e, StackTrace s)?, {
void Function(HttpRequest request, ClientContext context) handler,
void Function(Object e, StackTrace s)? onError, {
int port = 8080,
bool shared = false,
void onAcceptingConnections(InternetAddress address, int port)?,
void Function(InternetAddress address, int port)? onAcceptingConnections,
}) {
return _withAppEngineServicesInternal((ContextRegistry contextRegistry) {
final appengineServer = AppEngineHttpServer(contextRegistry,
Expand Down Expand Up @@ -97,7 +96,7 @@ Future runAppEngine(
}

Future _withAppEngineServicesInternal(
Future callback(ContextRegistry contextRegistry)) {
Future Function(ContextRegistry contextRegistry) callback) {
return ss.fork(() async {
final ContextRegistry contextRegistry = await _initializeAppEngine();
final bgServices = contextRegistry.newBackgroundServices();
Expand Down Expand Up @@ -130,7 +129,7 @@ Future<ContextRegistry> _initializeAppEngine() async {
zoneId ??= 'dev-machine';
final bool isProdEnvironment = !isDevEnvironment;

String? _findEnvironmentVariable(String name,
String? findEnvironmentVariable(String name,
{bool onlyInProd = false, bool onlyInDev = false, bool needed = true}) {
if (onlyInProd && !isProdEnvironment) return null;
if (onlyInDev && !isDevEnvironment) return null;
Expand All @@ -142,23 +141,23 @@ Future<ContextRegistry> _initializeAppEngine() async {
return value;
}

final projectId = _findEnvironmentVariable(
final projectId = findEnvironmentVariable(
'GOOGLE_CLOUD_PROJECT',
needed: true,
)!;

// For local testing the gcloud sdk brings now a gRPC-ready datastore
// emulator which will tell the user to use this environment variable.
final dbEmulatorHost = _findEnvironmentVariable('DATASTORE_EMULATOR_HOST',
final dbEmulatorHost = findEnvironmentVariable('DATASTORE_EMULATOR_HOST',
onlyInDev: false, needed: false);

final serviceId =
_findEnvironmentVariable('GAE_SERVICE', onlyInProd: true, needed: true) ??
findEnvironmentVariable('GAE_SERVICE', onlyInProd: true, needed: true) ??
'dummy-service';
final versionId =
_findEnvironmentVariable('GAE_VERSION', onlyInProd: true, needed: true) ??
findEnvironmentVariable('GAE_VERSION', onlyInProd: true, needed: true) ??
'dummy-version';
final instance = _findEnvironmentVariable('GAE_INSTANCE',
final instance = findEnvironmentVariable('GAE_INSTANCE',
onlyInProd: true, needed: true) ??
'dummy-instance';

Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/client_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.client_context;

import 'package:gcloud/db.dart';
import 'package:gcloud/storage.dart';
Expand Down
10 changes: 4 additions & 6 deletions pkgs/appengine/lib/src/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.api.errors;

import 'dart:io';

Expand All @@ -16,7 +15,7 @@ class AppEngineError implements Exception {
}

class NetworkError extends AppEngineError implements IOException {
NetworkError(String message) : super(message);
NetworkError(super.message);

@override
String toString() => 'NetworkError: $message';
Expand All @@ -26,7 +25,7 @@ class ProtocolError extends AppEngineError implements IOException {
static const ProtocolError INVALID_RESPONSE =
ProtocolError('Invalid response');

const ProtocolError(String message) : super(message);
const ProtocolError(super.message);

@override
String toString() => 'ProtocolError: $message';
Expand All @@ -35,15 +34,14 @@ class ProtocolError extends AppEngineError implements IOException {
class ServiceError extends AppEngineError {
final String serviceName;

ServiceError(String message, {this.serviceName = 'ServiceError'})
: super(message);
ServiceError(super.message, {this.serviceName = 'ServiceError'});

@override
String toString() => '$serviceName: $message';
}

class ApplicationError extends AppEngineError {
ApplicationError(String message) : super(message);
ApplicationError(super.message);

@override
String toString() => 'ApplicationError: $message';
Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/grpc_api/datastore_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library grpc_api;

export 'package:fixnum/fixnum.dart' show Int32, Int64;

Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/grpc_api/logging_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library logging_api;

export 'package:fixnum/fixnum.dart' show Int64;

Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/grpc_api_impl/auth_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// TODO(kustermann): At some point we should integrate this library
// into `package:googleapis_auth`.
library auth_utils;

import 'dart:async';

Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/grpc_api_impl/datastore_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library grpc_datastore;

import 'dart:async';

Expand Down
6 changes: 2 additions & 4 deletions pkgs/appengine/lib/src/grpc_api_impl/logging_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library grpc_logging;

import 'dart:async';
import 'dart:io';
Expand Down Expand Up @@ -451,8 +450,7 @@ api.LogSeverity _severityFromLogLevel(LogLevel level) {
///
/// See: https://cloud.google.com/error-reporting/docs/formatting-error-messages
String _formatStackTrace(Object error, StackTrace stackTrace) =>
'Error: $error\n' +
Trace.from(stackTrace).frames.map((f) {
'Error: $error\n${Trace.from(stackTrace).frames.map((f) {
// Find member
String? member = f.member;
if (member == '<fn>') {
Expand All @@ -468,4 +466,4 @@ String _formatStackTrace(Object error, StackTrace stackTrace) =>
}

return ' at $member ($loc)\n';
}).join('');
}).join('')}';
2 changes: 0 additions & 2 deletions pkgs/appengine/lib/src/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.api.logging;

import 'dart:async';

import 'package:gcloud/service_scope.dart' as ss;
Expand Down
1 change: 0 additions & 1 deletion pkgs/appengine/lib/src/server/context_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.context_registry;

import 'dart:async';
import 'dart:io';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library appengine.server.logging_package_adaptor;

import 'package:logging/logging.dart';

Expand Down
5 changes: 2 additions & 3 deletions pkgs/appengine/lib/src/server/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library application;

import 'dart:async';
import 'dart:convert' show utf8;
Expand Down Expand Up @@ -37,8 +36,8 @@ class AppEngineHttpServer {
Future get done => _shutdownCompleter.future;

void run(
applicationHandler(HttpRequest request, ClientContext context), {
void onAcceptingConnections(InternetAddress address, int port)?,
Function(HttpRequest request, ClientContext context) applicationHandler, {
void Function(InternetAddress address, int port)? onAcceptingConnections,
}) {
final serviceHandlers = {
'/_ah/start': _start,
Expand Down
6 changes: 3 additions & 3 deletions pkgs/appengine/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appengine
version: 0.13.10
version: 0.13.11
description: >-
Support for using Dart as a custom runtime on Google App Engine Flexible
Environment.
Expand All @@ -16,9 +16,9 @@ environment:
dependencies:
fixnum: ^1.0.0
gcloud: ^0.8.10
googleapis_auth: ^1.1.0
googleapis_auth: ^2.0.0
grpc: ^4.0.1
http: '>=0.13.3 <2.0.0'
http: ^1.0.0
logging: ^1.0.1
path: ^1.8.0
protobuf: ^3.1.0
Expand Down
10 changes: 7 additions & 3 deletions pkgs/appengine/test/enable_logging_package_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class LoggingMock extends LoggingBase {

LoggingMock();

@override
void log(LogLevel level, String message, {DateTime? timestamp}) {
_logFunctionMock(level, message, timestamp);
}

@override
void reportError(LogLevel level, Object error, StackTrace stackTrace,
{DateTime? timestamp}) {
_reportErrorFunctionMock(
Expand All @@ -32,8 +34,8 @@ class LoggingMock extends LoggingBase {
}

void expectReportError(
void func(
LogLevel level, Object error, StackTrace stackTrace, DateTime c)) {
void Function(
LogLevel level, Object error, StackTrace stackTrace, DateTime c) func) {
_reportErrorFunctionMock = expectAsync4(func);
}

Expand All @@ -43,7 +45,7 @@ class LoggingMock extends LoggingBase {
};
}

void expectLog(void func(LogLevel a, String b, DateTime c)) {
void expectLog(void Function(LogLevel a, String b, DateTime c) func) {
_logFunctionMock = expectAsync3(func);
}

Expand All @@ -53,12 +55,14 @@ class LoggingMock extends LoggingBase {
};
}

@override
Future flush() {
throw "Unexpected method call";
}
}

class CustomStackTrace implements StackTrace {
@override
String toString() => 'custom-stack-trace';
}

Expand Down
3 changes: 1 addition & 2 deletions pkgs/appengine/test/integration/common_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library test.integration.common_e2e;

import 'dart:async';
import 'dart:io';
Expand Down Expand Up @@ -32,7 +31,7 @@ bool onBot() {

Future<dynamic> withAuthenticator(
List<String> scopes,
Future callback(String project, grpc.HttpBasedAuthenticator authenticator),
Future Function(String project, grpc.HttpBasedAuthenticator authenticator) callback,
) async {
var project = Platform.environment[PROJECT_ENV];

Expand Down
Loading