Skip to content

Commit

Permalink
chore: More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Sep 28, 2024
1 parent 2753581 commit 80e70c9
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 46 deletions.
4 changes: 4 additions & 0 deletions packages/celest/lib/src/runtime/http/middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ Handler rootMiddleware(Handler inner) {
final requestZone = Zone.current.fork(
specification: ZoneSpecification(
handleUncaughtError: (self, parent, zone, error, stackTrace) {
if (error is HijackException) {
completer.completeError(error, stackTrace);
return;
}
Logger.root.shout(
'An unexpected error occurred',
error,
Expand Down
1 change: 1 addition & 0 deletions packages/celest/lib/src/runtime/serve.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ Future<void> serve({
ProcessSignal.sigint.watch(),
if (!Platform.isWindows) ProcessSignal.sigterm.watch(),
]).first;
print('Shutting down...');
await server.close();
}
4 changes: 2 additions & 2 deletions packages/celest/lib/src/runtime/targets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ abstract base class CloudEventSourceTarget extends CloudFunctionTarget {
);
},
(Object e, StackTrace st) {
print('An unexpected error occurred: $e');
print(st);
stderr.writeln('An unexpected error occurred: $e');
stderr.writeln(st);
connection.sink.addError(e, st);
connection.sink.close();
},
Expand Down
4 changes: 4 additions & 0 deletions packages/celest_cloud/lib/src/cloud/base/base_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import 'package:celest_cloud/src/util/operations.dart';
import 'package:celest_core/celest_core.dart';
import 'package:grpc/grpc_or_grpcweb.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:protobuf/protobuf.dart';

abstract mixin class BaseService {
@protected
Logger? get logger;

@protected
Future<Res> run<Req extends Object?, Res>(
String name, {
required Req request,
Expand All @@ -34,6 +37,7 @@ abstract mixin class BaseService {
}
}

@protected
Stream<OperationState<Metadata, Response>> streamOperation<
Metadata extends GeneratedMessage, Response extends GeneratedMessage>(
String name, {
Expand Down
4 changes: 3 additions & 1 deletion packages/celest_cloud/lib/src/cloud/projects/projects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ final class Projects with BaseService {
Stream<OperationState<OperationMetadata, Project>> create({
required String parent,
required String projectId,
required String displayName,
String? displayName,
Iterable<Region>? regions,
Map<String, String>? annotations,
bool validateOnly = false,
}) async* {
Expand All @@ -38,6 +39,7 @@ final class Projects with BaseService {
projectId: projectId,
project: Project(
displayName: displayName,
regions: regions,
annotations: annotations,
),
validateOnly: validateOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ final class CommunitySubscriptionPlan implements SubscriptionPlan {

final class BuilderSubscriptionPlan implements SubscriptionPlan {
const BuilderSubscriptionPlan({
required this.currencyCode,
this.currencyCode,
required this.instanceType,
});

final String currencyCode;
final String? currencyCode;
final pb.InstanceType instanceType;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,6 @@ class ProjectEnvironmentDatabase extends $pb.GeneratedMessage {
factory ProjectEnvironmentDatabase({
$core.String? host,
$core.String? token,
$core.String? systemDatabaseId,
}) {
final $result = create();
if (host != null) {
Expand All @@ -1426,9 +1425,6 @@ class ProjectEnvironmentDatabase extends $pb.GeneratedMessage {
if (token != null) {
$result.token = token;
}
if (systemDatabaseId != null) {
$result.systemDatabaseId = systemDatabaseId;
}
return $result;
}
ProjectEnvironmentDatabase._() : super();
Expand All @@ -1446,7 +1442,6 @@ class ProjectEnvironmentDatabase extends $pb.GeneratedMessage {
createEmptyInstance: create)
..aOS(1, _omitFieldNames ? '' : 'host')
..aOS(2, _omitFieldNames ? '' : 'token')
..aOS(3, _omitFieldNames ? '' : 'systemDatabaseId')
..hasRequiredFields = false;

@$core.Deprecated('Using this can add significant overhead to your binary. '
Expand Down Expand Up @@ -1500,19 +1495,6 @@ class ProjectEnvironmentDatabase extends $pb.GeneratedMessage {
$core.bool hasToken() => $_has(1);
@$pb.TagNumber(2)
void clearToken() => clearField(2);

/// The system database ID, used for attaching.
@$pb.TagNumber(3)
$core.String get systemDatabaseId => $_getSZ(2);
@$pb.TagNumber(3)
set systemDatabaseId($core.String v) {
$_setString(2, v);
}

@$pb.TagNumber(3)
$core.bool hasSystemDatabaseId() => $_has(2);
@$pb.TagNumber(3)
void clearSystemDatabaseId() => clearField(3);
}

const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,11 @@ const ProjectEnvironmentDatabase$json = {
'2': [
{'1': 'host', '3': 1, '4': 1, '5': 9, '10': 'host'},
{'1': 'token', '3': 2, '4': 1, '5': 9, '10': 'token'},
{
'1': 'system_database_id',
'3': 3,
'4': 1,
'5': 9,
'10': 'systemDatabaseId'
},
],
};

/// Descriptor for `ProjectEnvironmentDatabase`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List projectEnvironmentDatabaseDescriptor =
$convert.base64Decode(
'ChpQcm9qZWN0RW52aXJvbm1lbnREYXRhYmFzZRISCgRob3N0GAEgASgJUgRob3N0EhQKBXRva2'
'VuGAIgASgJUgV0b2tlbhIsChJzeXN0ZW1fZGF0YWJhc2VfaWQYAyABKAlSEHN5c3RlbURhdGFi'
'YXNlSWQ=');
'VuGAIgASgJUgV0b2tlbg==');
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,9 @@ const GetProjectRequest$json = {

/// Descriptor for `GetProjectRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getProjectRequestDescriptor = $convert.base64Decode(
'ChFHZXRQcm9qZWN0UmVxdWVzdBKjAQoEbmFtZRgBIAEoCUKOAeBBAvpBGgoYY2xvdWQuY2VsZX'
'N0LmRldi9Qcm9qZWN0ukhrugFoCg12YWxpZF9wcm9qZWN0EiFuYW1lIG11c3QgYmUgYSB2YWxp'
'ZCBwcm9qZWN0IG5hbWUaNHRoaXMubWF0Y2hlcygnXm9yZ2FuaXphdGlvbnMvW14vXSsvcHJvam'
'VjdHMvW14vXSskJylSBG5hbWU=');
'ChFHZXRQcm9qZWN0UmVxdWVzdBKNAQoEbmFtZRgBIAEoCUJ54EEC+kEaChhjbG91ZC5jZWxlc3'
'QuZGV2L1Byb2plY3S6SFa6AVMKDXZhbGlkX3Byb2plY3QSIW5hbWUgbXVzdCBiZSBhIHZhbGlk'
'IHByb2plY3QgbmFtZRofdGhpcy5tYXRjaGVzKCdwcm9qZWN0cy9bXi9dKyQnKVIEbmFtZQ==');

@$core.Deprecated('Use listProjectsRequestDescriptor instead')
const ListProjectsRequest$json = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,9 @@ class BuilderSubscriptionPlan extends $pb.GeneratedMessage {
$pb.GeneratedMessage.$_defaultFor<BuilderSubscriptionPlan>(create);
static BuilderSubscriptionPlan? _defaultInstance;

/// Required. The preferred currency for payment.
/// Optional. The preferred currency for payment.
///
/// If not provided, it will be inferred from the user's location.
@$pb.TagNumber(1)
$core.String get currencyCode => $_getSZ(0);
@$pb.TagNumber(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ const BuilderSubscriptionPlan$json = {

/// Descriptor for `BuilderSubscriptionPlan`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List builderSubscriptionPlanDescriptor = $convert.base64Decode(
'ChdCdWlsZGVyU3Vic2NyaXB0aW9uUGxhbhJ+Cg1jdXJyZW5jeV9jb2RlGAEgASgJQlngQQK6SF'
'O6AVAKDnZhbGlkX2N1cnJlbmN5Eh1tdXN0IGJlIGEgdmFsaWQgY3VycmVuY3kgY29kZRofdGhp'
'cy5tYXRjaGVzKCdeW2EtekEtWl17Myw0fSQnKVIMY3VycmVuY3lDb2RlEo4BCg1pbnN0YW5jZV'
'90eXBlGAIgASgOMiMuY2VsZXN0LmNsb3VkLnYxYWxwaGExLkluc3RhbmNlVHlwZUJE4EECukg+'
'ugE7ChN2YWxpZF9pbnN0YW5jZV90eXBlEhltdXN0IHNldCBhbiBpbnN0YW5jZSB0eXBlGgl0aG'
'lzICE9IDBSDGluc3RhbmNlVHlwZQ==');
'ChdCdWlsZGVyU3Vic2NyaXB0aW9uUGxhbhKBAQoNY3VycmVuY3lfY29kZRgBIAEoCUJc4EEBuk'
'hWugFQCg52YWxpZF9jdXJyZW5jeRIdbXVzdCBiZSBhIHZhbGlkIGN1cnJlbmN5IGNvZGUaH3Ro'
'aXMubWF0Y2hlcygnXlthLXpBLVpdezMsNH0kJynQAQFSDGN1cnJlbmN5Q29kZRKOAQoNaW5zdG'
'FuY2VfdHlwZRgCIAEoDjIjLmNlbGVzdC5jbG91ZC52MWFscGhhMS5JbnN0YW5jZVR5cGVCROBB'
'ArpIProBOwoTdmFsaWRfaW5zdGFuY2VfdHlwZRIZbXVzdCBzZXQgYW4gaW5zdGFuY2UgdHlwZR'
'oJdGhpcyAhPSAwUgxpbnN0YW5jZVR5cGU=');

@$core.Deprecated('Use enterpriseSubscriptionPlanDescriptor instead')
const EnterpriseSubscriptionPlan$json = {
Expand Down
6 changes: 3 additions & 3 deletions packages/celest_core/lib/src/util/uuid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'dart:typed_data';
final _rand = Random();

class Uuid {
const Uuid._(this.value);
const Uuid(this.value);

factory Uuid.v7() => Uuid._(_uuidv7());
factory Uuid.v7() => Uuid(_uuidv7());

factory Uuid.parse(String uuid) {
final buffer = Uint8List(16);
Expand All @@ -17,7 +17,7 @@ class Uuid {
}
buffer[i++] = int.parse(uuid.substring(j, j + 2), radix: 16);
}
return Uuid._(buffer);
return Uuid(buffer);
}

final Uint8List value;
Expand Down

0 comments on commit 80e70c9

Please sign in to comment.