Skip to content

Commit fd1418b

Browse files
committed
Apply autoformat
1 parent 43d6ce9 commit fd1418b

16 files changed

+448
-424
lines changed

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/exception/amplify_kinesis_exception.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,16 @@ sealed class AmplifyKinesisException extends AmplifyException {
2929
e.message,
3030
recoverySuggestion: e.recoverySuggestion,
3131
),
32-
final RecordCacheLimitExceededException e =>
33-
KinesisLimitExceededException(
34-
message: e.message,
35-
recoverySuggestion: e.recoverySuggestion,
36-
),
32+
final RecordCacheLimitExceededException e => KinesisLimitExceededException(
33+
message: e.message,
34+
recoverySuggestion: e.recoverySuggestion,
35+
),
3736
final RecordCacheDatabaseException e => KinesisStorageException(
3837
e.message,
3938
recoverySuggestion: e.recoverySuggestion,
4039
cause: e.cause,
4140
),
42-
final Exception e => KinesisUnknownException(
43-
e.toString(),
44-
cause: e,
45-
),
41+
final Exception e => KinesisUnknownException(e.toString(), cause: e),
4642
_ => KinesisUnknownException(error.toString()),
4743
};
4844

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/auto_flush_scheduler.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import 'package:aws_kinesis_datastreams_dart/src/impl/record_client.dart';
1818
/// {@endtemplate}
1919
final class AutoFlushScheduler {
2020
/// {@macro aws_kinesis_datastreams.auto_flush_scheduler}
21-
AutoFlushScheduler({
22-
required Duration interval,
23-
required RecordClient client,
24-
}) : _interval = interval,
25-
_client = client;
21+
AutoFlushScheduler({required Duration interval, required RecordClient client})
22+
: _interval = interval,
23+
_client = client;
2624

2725
final Duration _interval;
2826
final RecordClient _client;

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/kinesis_sender.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ final class PutRecordsResult {
3939
/// {@endtemplate}
4040
class KinesisSender {
4141
/// {@macro aws_kinesis_datastreams.kinesis_sender}
42-
KinesisSender({
43-
required KinesisClient kinesisClient,
44-
required int maxRetries,
45-
}) : _kinesisClient = kinesisClient,
46-
_maxRetries = maxRetries;
42+
KinesisSender({required KinesisClient kinesisClient, required int maxRetries})
43+
: _kinesisClient = kinesisClient,
44+
_maxRetries = maxRetries;
4745

4846
final KinesisClient _kinesisClient;
4947
final int _maxRetries;

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/record_client.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ class RecordClient {
7373
);
7474
await _handleFailedRequest(records);
7575
} catch (e) {
76-
_logger.warn(
77-
'Error flushing stream $streamName: $e. Aborting flush',
78-
);
76+
_logger.warn('Error flushing stream $streamName: $e. Aborting flush');
7977
await _handleFailedRequest(records);
8078
rethrow;
8179
}

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/storage/record_storage.dart

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import 'package:aws_kinesis_datastreams_dart/src/exception/amplify_kinesis_excep
55
show defaultRecoverySuggestion;
66
import 'package:aws_kinesis_datastreams_dart/src/exception/record_cache_exception.dart';
77
import 'package:aws_kinesis_datastreams_dart/src/impl/kinesis_record.dart';
8-
import 'package:aws_kinesis_datastreams_dart/src/kinesis_limits.dart'
9-
as limits;
8+
import 'package:aws_kinesis_datastreams_dart/src/kinesis_limits.dart' as limits;
109
import 'package:aws_kinesis_datastreams_dart/src/model/record.dart';
1110
import 'package:meta/meta.dart';
1211

@@ -105,22 +104,20 @@ abstract class RecordStorage {
105104
});
106105

107106
/// Increments the retry count for the specified records.
108-
Future<void> incrementRetryCount(Iterable<int> ids) =>
109-
_wrap(
110-
'Failed to increment retry count',
111-
() => doIncrementRetryCount(ids),
112-
);
107+
Future<void> incrementRetryCount(Iterable<int> ids) => _wrap(
108+
'Failed to increment retry count',
109+
() => doIncrementRetryCount(ids),
110+
);
113111

114112
/// Returns the total number of cached records.
115113
Future<int> getRecordCount() =>
116114
_wrap('Failed to get record count', doGetRecordCount);
117115

118116
/// Deletes all records and resets [cachedSize] to 0.
119-
Future<void> clearRecords() =>
120-
_wrap('Failed to clear cache', () async {
121-
await doClearRecords();
122-
cachedSize = 0;
123-
});
117+
Future<void> clearRecords() => _wrap('Failed to clear cache', () async {
118+
await doClearRecords();
119+
cachedSize = 0;
120+
});
124121

125122
/// Closes the storage and releases resources.
126123
Future<void> close() => _wrap('Failed to close storage', doClose);
@@ -159,10 +156,7 @@ abstract class RecordStorage {
159156
@protected
160157
Future<void> doClose();
161158

162-
Future<T> _wrap<T>(
163-
String message,
164-
Future<T> Function() operation,
165-
) async {
159+
Future<T> _wrap<T>(String message, Future<T> Function() operation) async {
166160
try {
167161
return await operation();
168162
} on RecordCacheException {

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/storage/record_storage_indexeddb.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ final class IndexedDbRecordStorage extends RecordStorage {
196196
}
197197
}
198198

199-
final request = db.open(dbName, 1)
200-
..onupgradeneeded = onUpgradeNeeded.toJS;
199+
final request = db.open(dbName, 1)..onupgradeneeded = onUpgradeNeeded.toJS;
201200
final result = await request.future;
202201
if (result.isA<IDBDatabase>()) {
203202
return result as IDBDatabase;
@@ -223,10 +222,9 @@ final class IndexedDbRecordStorage extends RecordStorage {
223222
final idbCursor = cursor as IDBCursorWithValue;
224223
final value = idbCursor.value;
225224
if (!value.isUndefinedOrNull) {
226-
total +=
227-
(value as JSObject)
228-
.getProperty<JSNumber>('data_size'.toJS)
229-
.toDartInt;
225+
total += (value as JSObject)
226+
.getProperty<JSNumber>('data_size'.toJS)
227+
.toDartInt;
230228
}
231229
idbCursor.continue_();
232230
}).toJS

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/storage/record_storage_memory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:aws_kinesis_datastreams_dart/src/impl/storage/record_storage.dar
88

99
/// {@template aws_kinesis_datastreams.in_memory_record_storage}
1010
/// In-memory [RecordStorage] fallback for web when IndexedDB is unavailable.
11-
/// Records are not persisted.
11+
/// Records are not persisted.
1212
/// {@endtemplate}
1313
final class InMemoryRecordStorage extends RecordStorage {
1414
/// {@macro aws_kinesis_datastreams.in_memory_record_storage}

packages/kinesis/aws_kinesis_datastreams_dart/lib/src/impl/storage/record_storage_sqlite.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ final class SqliteRecordStorage extends RecordStorage {
121121
@override
122122
Future<void> doIncrementRetryCount(Iterable<int> ids) async {
123123
if (ids.isEmpty) return;
124-
await (_db.update(
125-
_db.kinesisRecords,
126-
)..where((t) => t.id.isIn(ids))).write(
124+
await (_db.update(_db.kinesisRecords)..where((t) => t.id.isIn(ids))).write(
127125
KinesisRecordsCompanion.custom(
128126
retryCount: _db.kinesisRecords.retryCount + const Constant(1),
129127
),

packages/kinesis/aws_kinesis_datastreams_dart/test/auto_flush_scheduler_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ void main() {
1616

1717
setUp(() {
1818
mockClient = _MockRecordClient();
19-
when(() => mockClient.flush())
20-
.thenAnswer((_) async => const FlushData());
19+
when(() => mockClient.flush()).thenAnswer((_) async => const FlushData());
2120
});
2221

2322
tearDown(() {
@@ -72,15 +71,16 @@ void main() {
7271

7372
test('rapid start/stop/start does not leak loops', () {
7473
fakeAsync((async) {
75-
final scheduler = AutoFlushScheduler(
76-
interval: const Duration(seconds: 1),
77-
client: mockClient,
78-
)
79-
..start()
80-
..stop()
81-
..start()
82-
..stop()
83-
..start();
74+
final scheduler =
75+
AutoFlushScheduler(
76+
interval: const Duration(seconds: 1),
77+
client: mockClient,
78+
)
79+
..start()
80+
..stop()
81+
..start()
82+
..stop()
83+
..start();
8484

8585
// Only one loop should be active.
8686
async.elapse(const Duration(milliseconds: 2500));

packages/kinesis/aws_kinesis_datastreams_dart/test/in_memory_record_storage_test.dart

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,27 @@ void main() {
111111

112112
group('getRecordsByStream', () {
113113
test('returns records grouped by stream name', () async {
114-
await storage.addRecord(RecordInput.now(data: Uint8List.fromList([1]), partitionKey: 'pk', streamName: 'stream-a'));
115-
await storage.addRecord(RecordInput.now(data: Uint8List.fromList([2]), partitionKey: 'pk', streamName: 'stream-b'));
116-
await storage.addRecord(RecordInput.now(data: Uint8List.fromList([3]), partitionKey: 'pk', streamName: 'stream-a'));
114+
await storage.addRecord(
115+
RecordInput.now(
116+
data: Uint8List.fromList([1]),
117+
partitionKey: 'pk',
118+
streamName: 'stream-a',
119+
),
120+
);
121+
await storage.addRecord(
122+
RecordInput.now(
123+
data: Uint8List.fromList([2]),
124+
partitionKey: 'pk',
125+
streamName: 'stream-b',
126+
),
127+
);
128+
await storage.addRecord(
129+
RecordInput.now(
130+
data: Uint8List.fromList([3]),
131+
partitionKey: 'pk',
132+
streamName: 'stream-a',
133+
),
134+
);
117135

118136
final result = await storage.getRecordsByStream();
119137
expect(result.keys, containsAll(['stream-a', 'stream-b']));
@@ -125,13 +143,18 @@ void main() {
125143
final result = await storage.getRecordsByStream();
126144
expect(result, isEmpty);
127145
});
128-
129146
});
130147

131148
group('clearRecords', () {
132149
test('removes all records', () async {
133150
for (var i = 0; i < 5; i++) {
134-
await storage.addRecord(RecordInput.now(data: Uint8List.fromList([i]), partitionKey: 'pk-$i', streamName: 'stream'));
151+
await storage.addRecord(
152+
RecordInput.now(
153+
data: Uint8List.fromList([i]),
154+
partitionKey: 'pk-$i',
155+
streamName: 'stream',
156+
),
157+
);
135158
}
136159
expect(await getAllRecords(), hasLength(5));
137160

@@ -145,7 +168,13 @@ void main() {
145168
test('returns correct count', () async {
146169
expect(await storage.getRecordCount(), equals(0));
147170
for (var i = 0; i < 3; i++) {
148-
await storage.addRecord(RecordInput.now(data: Uint8List.fromList([i]), partitionKey: 'pk-$i', streamName: 'stream'));
171+
await storage.addRecord(
172+
RecordInput.now(
173+
data: Uint8List.fromList([i]),
174+
partitionKey: 'pk-$i',
175+
streamName: 'stream',
176+
),
177+
);
149178
}
150179
expect(await storage.getRecordCount(), equals(3));
151180
});

0 commit comments

Comments
 (0)